API 服務的名稱在 Google Cloud上不得重複。因為 Endpoints 會使用與 DNS 相容的名稱來識別服務,因此建議您使用 API 的網域名稱或子網域名稱做為服務名稱。使用這個方法時,「Endpoints Services」(Endpoints 服務) 頁面中顯示的服務名稱,會與用來要求您的 API 時所使用的名稱相符。Endpoints 對服務名稱有以下要求:
網域名稱的長度上限為 253 個字元。
網域名稱開頭必須為小寫英文字母。
網域名稱中以點分隔的每個部分都具有下列需求條件:
開頭必須為小寫字母。
不得以破折號結尾。
剩餘字元可為小寫字母、數字或破折號。
長度上限為 63 個半形字元。
您可以註冊自訂網域 (如 example.com),也可以使用 Google 代管的網域。
使用 Google 代管的網域
Google 擁有並管理 cloud.goog 和 appspot.com 網域。如果您要使用 Google 代管的網域,就必須使用您的Google Cloud 專案 ID 做為服務名稱的一部分。因為Google Cloud 專案具備全域不重複的專案 ID,因此這項要求可確保您擁有不重複的服務名稱。
如果不想使用 Google 代管的網域,則可採用您已獲授權使用的自訂網域 (例如 myapi.mycompany.com)。在部署 API 設定之前,請先按照「驗證網域擁有權」中的步驟進行。
info.title
info.title 欄位是 API 的易記名稱。 Google Cloud 控制台的「Endpoints」 >「Services」頁面會顯示您在 info.title 欄位中設定的文字。如果每個 Google Cloud 專案擁有多個 API,在您第一次開啟頁面時,API 名稱會顯示在清單中。您可以按一下 API 名稱以開啟另一個頁面,該頁面會顯示 API 的指標、部署記錄和其他資訊。
info.version
Google Cloud 主控台中的「Endpoints」 >「Services」頁面會顯示 API 的版本號碼。在首次部署 API 設定之前,請先執行下列操作:
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eCloud Endpoints supports APIs described using version 2.0 of the OpenAPI specification, allowing configuration of features like authentication and quotas within an OpenAPI document.\u003c/p\u003e\n"],["\u003cp\u003eEndpoints uses specific fields within the OpenAPI document, including \u003ccode\u003ehost\u003c/code\u003e, \u003ccode\u003einfo.title\u003c/code\u003e, \u003ccode\u003einfo.version\u003c/code\u003e, and \u003ccode\u003eoperationId\u003c/code\u003e, for service identification and display within the Google Cloud console.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ehost\u003c/code\u003e field determines the service name, which must be unique on Google Cloud and is recommended to match the API's domain or subdomain name for consistency and potential use with Cloud Endpoints Portal.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003einfo.title\u003c/code\u003e field provides a user-friendly name for the API, displayed in the Endpoints Services page, and \u003ccode\u003einfo.version\u003c/code\u003e specifies the API's version number.\u003c/p\u003e\n"],["\u003cp\u003eAlthough optional in the OpenAPI Specification, \u003ccode\u003eoperationId\u003c/code\u003e is required by Endpoints for internal operation identification, and its value must be unique within the API.\u003c/p\u003e\n"]]],[],null,["# Configuring Cloud Endpoints\n\nOpenAPI \\| [gRPC](/endpoints/docs/grpc/configure-endpoints \"View this page for the Cloud Endpoints gRPC docs\")\n\n\u003cbr /\u003e\n\nCloud Endpoints supports APIs that are described using version 2.0 of\nthe [OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md).\nYou describe the API [surface](/endpoints/docs/openapi/glossary#surface) and\nconfigure Endpoints features such as\n[authentication rules](/endpoints/docs/openapi/authentication-method) or\n[quotas](/endpoints/docs/openapi/quotas-overview) in an\n[OpenAPI document](/endpoints/docs/openapi/glossary#open_api_doc).\n\nEndpoints makes special use of the following required fields in\nyour OpenAPI document:\n\n- `host`\n- `info.title`\n- `info.version`\n- `operationId`\n\nThis page provides information about how Endpoints uses the\npreceding fields. With this information, you can finish preparing your OpenAPI\ndocument for [deployment](/endpoints/docs/openapi/deploy-endpoints-config).\n\nPrerequisites\n-------------\n\nAs a starting point, this page assumes that you have:\n\n- A [Google Cloud project](/resource-manager/docs/creating-managing-projects).\n- Basic knowledge of [OpenAPI](/endpoints/docs/openapi/openapi-overview).\n- An OpenAPI document in the format described in the [Swagger basic structure](https://swagger.io/docs/specification/2-0/basic-structure/) documentation.\n\n`host`\n------\n\nCloud Endpoints uses the name you configure in the `host` field of your OpenAPI document as the name of your service.\n\nThe name of your API service must be unique on Google Cloud. Because\nEndpoints uses DNS-compatible names to identify services, we\nrecommend that you use your API's domain name or subdomain name as the service\nname. With this approach, the service name that appears on the **Endpoints\nServices** page matches the name used in requests to your API.\nEndpoints has the following requirements for the service name:\n\nYou can either register your own custom domain (such as `example.com`), or\nyou can use a domain managed by Google.\n\n### Use a domain managed by Google\n\nGoogle owns and manages the `cloud.goog` and the `appspot.com` domains. If you want to use a domain managed by Google, you must use your Google Cloud project ID as part of the service name. Because Google Cloud projects have a globally unique project ID, this requirement ensures that you have a unique service name.\n\n\u003cbr /\u003e\n\nThe domain name that you use depends on the backend that hosts your API:\n\n- For APIs that are hosted on the App Engine flexible environment, you must\n use the `appspot.com` domain, and the service name must be in the following\n format, where \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e is your\n Google Cloud project ID:\n\n ```\n YOUR_PROJECT_ID.appspot.com\n ```\n\n When you deploy your API to App Engine, a DNS entry with a name in\n the format \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com` is created\n automatically.\n- For APIs that are hosted on Compute Engine, Google Kubernetes Engine, or\n Kubernetes, you must use the `cloud.goog` domain, and the service name must\n be in the following format, where \u003cvar translate=\"no\"\u003eYOUR_API_NAME\u003c/var\u003e is\n the name of your API:\n\n ```\n YOUR_API_NAME.endpoints.YOUR_PROJECT_ID.cloud.goog\n ```\n\n To use this domain as the API's domain name, read\n [Configuring DNS on the `cloud.goog` domain](/endpoints/docs/openapi/cloud-goog-dns-configure).\n\n### Use a custom domain\n\nIf you don't want to use a domain managed by Google, you can use a custom domain\n(for example, `myapi.mycompany.com`) that you are authorized to use.\nBefore you deploy the API configuration, follow the steps in\n[Verify ownership of the domain](/endpoints/docs/openapi/verify-domain-name).\n\n`info.title`\n------------\n\nThe `info.title` field is a user-friendly name for your API. The\n**Endpoints** \\\u003e **Services** page in the Google Cloud console displays the\ntext that you configure in the `info.title` field. If you have more than\none API per Google Cloud project, the API name is displayed in a list when you\nfirst open the page. You can click on the API name to open another page\nthat displays the API's metrics, deployment history, and other information.\n\n`info.version`\n--------------\n\nThe **Endpoints** \\\u003e **Services** page in the Google Cloud console displays the\nversion number for your API. Before deploying your API configuration for the\nfirst time:\n\n- Set the version number in the `info.version` field to the applicable\n API version,for example, `1.0`.\n\n- Set the `basePath` field to the major version number, for example, `/v1`.\n\nFor additional information on versioning your API, see\n[API lifecycle management](/endpoints/docs/openapi/lifecycle-management).\n\n`operationId`\n-------------\n\nAlthough the `operationId` is an optional field in the OpenAPI Specification,\nEndpoints requires this field because it is used for internal\nidentification of the operation. The string that you use for the `operationId`\nmust be unique within your API. See the description for\n[`operationId`](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#operation-object)\nin the OpenAPI Specification for guidance on naming.\n\nWhat's next\n-----------\n\n- [Deploying the Endpoints configuration](/endpoints/docs/openapi/deploy-endpoints-config)\n- [Deploying the API backend](/endpoints/docs/openapi/deploy-api-backend)\n- [Configuring authentication](/endpoints/docs/openapi/authentication-method)"]]