[[["容易理解","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 (世界標準時間)。"],[],[],null,["# Handling API versioning\n\nThis page describes how to do versioning for your API and how to deploy to\nmultiple versions.\n\nRecommendations for managing API versions\n-----------------------------------------\n\nIn managing your API versions, consider these recommendations:\n\n- When you want to introduce an incremental, but non-breaking change, keep the API version constant and deploy over the existing API.\n- When you introduce a breaking change to your API, increment the API version.\n- For additional protection, increment the App Engine application version as well, and then deploy the new API version to that new App Engine application version. This lets you use the built-in flexibility of App Engine to quickly switch between App Engine versions and serve from the old working versions if you run into unexpected problems.\n\nThe following table is an illustration of cascading backend API versions to\ndifferent App Engine application versions.\n\nAs shown in the table, incremental, non-breaking updates to v1 of the API are\nrolled out, each overwriting the previous version. When breaking changes are\nintroduced, the API version is incremented to v2 and it is deployed to a new\nApp Engine application version. That allows you to switch back to the\nprevious applications version if needed.\n\nIn the table, notice that application version 2 supports both the latest v1 version\nand the new v2 version of your API. If you don't delete the existing v1 code\nfrom your project, when you deploy the project both `v2` and `vl` (n)\nof your API are deployed to version 2 of your application.\n\nDeploying to multiple application versions\n------------------------------------------\n\nWhen you deploy your backend API, you deploy it to the project ID of the\nGoogle Cloud project you created for your API, and you must also\nspecify the App Engine version you deploy to.\n\n\nYou specify the App Engine app version on the command line when\nyou\n[deploy your app](/appengine/docs/standard/python/tools/uploadinganapp#deploying_an_app).\nThe App Engine app version isn't the same thing as the backend API\nversion number, which you specify in the `version` argument to the\n`@endpoints.api` decorator.\n\nAs shown in the preceding figure, you can deploy multiple API versions to the\nsame App Engine version. And, you can have many App Engine\nversions for an application.\n\n### Accessing API versions deployed to a serving version\n\nThe first\n[App Engine version](/appengine/docs/python/an-overview-of-app-engine#versions_and_instances)\nthat you deploy your API to is the serving version. This version runs at the URL\n`http://`\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com` where\n\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e represents your Google Cloud\nproject ID. You can access all of the API versions deployed to that\nApp Engine application version by using that URL.\n\nThe serving version remains the same until you explicitly change it, in the\n[Google Cloud console](https://console.cloud.google.com/appengine/versions).\n\n### Accessing API versions deployed to a non-serving application version\n\nIf you need to access API versions that are *not* deployed to the currently\nserving App Engine version, you use a *version-specific* URL, similar to\nthe following: \n\n```\nhttps://VERSION-dot-YOUR_PROJECT_ID.appspot.com\n```\n\nReplace \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e with your App Engine version,\nand \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with your Google Cloud project\nID. For example, suppose your App Engine serving version\nis 1, but you want to access an API version deployed to version 2. You would\nuse this URL: `https://2-dot-`\u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com`.\n| **Important:** For backend APIs, only host names formed using `-dot-` in place of literal periods work for versioned apps.\n\nFor more details, see the\n[App Engine documentation](/appengine/docs/standard/python/how-requests-are-routed).\n\n### Accessing API versions deployed to non-serving services (previously modules)\n\nIf you need to access API versions that are *not* deployed to the default\nApp Engine service, you can use a *service-specific* URL using the dot\nsyntax as follows: \n\n```\nhttps://SERVICE-NAME-dot-YOUR_PROJECT_ID.appspot.com/_ah/api/...\n```\n\nFor more details, see the\n[App Engine documentation](/appengine/docs/standard/python/how-requests-are-routed)."]]