[[["わかりやすい","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 UTC。"],[[["\u003cp\u003eCloud Endpoints Frameworks provides API management features, including an API gateway that handles authentication and other checks before routing requests to the API backend, similar to the Extensible Service Proxy (ESP).\u003c/p\u003e\n"],["\u003cp\u003eEndpoints Frameworks offers API management features such as monitoring, logging, quotas, and a developer portal, all accessible through the Google Cloud console's Endpoints Services page.\u003c/p\u003e\n"],["\u003cp\u003eTo utilize API management with Endpoints, you must deploy an OpenAPI document (version 2.0) that defines your API.\u003c/p\u003e\n"],["\u003cp\u003eAdding API management involves configuring build files (Maven or Gradle), setting the Google Cloud project ID, adding servlet filter configurations in \u003ccode\u003eweb.xml\u003c/code\u003e, and modifying dependencies and the build configuration.\u003c/p\u003e\n"],["\u003cp\u003eAfter building the API and generating the OpenAPI document, you have to deploy it and redeploy the application, to then view the API metrics in the Google Cloud console.\u003c/p\u003e\n"]]],[],null,["# Adding API management\n\nCloud Endpoints Frameworks provides API management features that are comparable to\nthe features that the\n[Extensible Service Proxy (ESP)](/endpoints/docs/frameworks/glossary#extensible_service_proxy)\nprovides for Cloud Endpoints. Endpoints Frameworks includes a\nbuilt-in\n[API gateway](https://en.wikipedia.org/wiki/API_management)\nthat intercepts all requests and performs any necessary checks, such as\nauthentication, before forwarding the request to the API backend. When the backend\nresponds, Endpoints Frameworks gathers and reports telemetry. You can\nview metrics for your API on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console.\n\nThe API management features available in Endpoints Frameworks include:\n\n- [Monitoring](/endpoints/docs/frameworks/monitoring-your-api)\n- [Logging](/endpoints/docs/frameworks/monitoring-your-api#logs)\n- [Quotas](/endpoints/docs/openapi/quotas-overview)\n- [Developer portal](/endpoints/docs/openapi/dev-portal-overview)\n\nFor your API to be managed by Endpoints, you must deploy\nan OpenAPI document that describes your API using version 2.0 of the\n[OpenAPI Specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md).\nThis page describes how to generate and deploy an OpenAPI document that\nenables Endpoints to manage your API.\n\nIf you don't add API management, your API still serves requests, but your\nAPI doesn't appear on the **Endpoints** \\\u003e **Services** page in the\nGoogle Cloud console, and the functionality provided by\nEndpoints, such as logging, monitoring, and setting quotas, isn't\navailable.\n\nTo add API management to your API:\n\n1. Set up your Maven `pom.xml` file or your Gradle `build.gradle` file as\n described in\n [Configuring the build files](/endpoints/docs/frameworks/java/set-up-environment#configuring_the_build_files).\n\n2. Make sure that you set the Google Cloud project ID in the\n build files.\n\n ### Maven\n\n Search for `\u003cendpoints.project.id\u003e`, and replace\n \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with your\n Google Cloud project ID. For example:\n\n `\u003cendpoints.project.id\u003eexample-project-12345\u003c/endpoints.project.id\u003e`\n\n\n \u003cendpoints.project.id\u003eYOUR_PROJECT_ID\u003c/endpoints.project.id\u003e\n\n \u003cbr /\u003e\n\n ### Gradle\n\n 1. Search for `def projectId`, and replace \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with your Google Cloud project ID. For example:\n\n `def projectId = 'example-project-12345'`\n 2. Make sure your `build.gradle` file contains the `replaceProjectId` task, which sets the project ID in the `appengine-web.xml` and `web.xml` files.\n\n\n task replaceProjectId(type: Copy) {\n from 'src/main/webapp/WEB-INF/'\n include '*.xml'\n into \"build/exploded-${archivesBaseName}/WEB-INF\"\n expand(endpoints:[project:[id:projectId]])\n filteringCharset = 'UTF-8'\n }\n\n \u003cbr /\u003e\n\n3. In your API project's `web.xml` file, add the API management servlet filter\n configuration:\n\n \u003c!-- Add a filter that fetches the service config from service management. --\u003e\n \u003cfilter\u003e\n \u003cfilter-name\u003eendpoints-api-configuration\u003c/filter-name\u003e\n \u003cfilter-class\u003ecom.google.api.control.ServiceManagementConfigFilter\u003c/filter-class\u003e\n \u003c/filter\u003e\n\n \u003c!-- Add a filter that performs Endpoints logging and monitoring. --\u003e\n \u003cfilter\u003e\n \u003cfilter-name\u003eendpoints-api-controller\u003c/filter-name\u003e\n \u003cfilter-class\u003ecom.google.api.control.extensions.appengine.GoogleAppEngineControlFilter\u003c/filter-class\u003e\n \u003cinit-param\u003e\n \u003cparam-name\u003eendpoints.projectId\u003c/param-name\u003e\n \u003cparam-value\u003e${endpoints.project.id}\u003c/param-value\u003e\n \u003c/init-param\u003e\n \u003cinit-param\u003e\n \u003cparam-name\u003eendpoints.serviceName\u003c/param-name\u003e\n \u003cparam-value\u003e${endpoints.project.id}.appspot.com\u003c/param-value\u003e\n \u003c/init-param\u003e\n \u003c/filter\u003e\n\n \u003cfilter-mapping\u003e\n \u003cfilter-name\u003eendpoints-api-configuration\u003c/filter-name\u003e\n \u003cservlet-name\u003eEndpointsServlet\u003c/servlet-name\u003e\n \u003c/filter-mapping\u003e\n\n \u003cfilter-mapping\u003e\n \u003cfilter-name\u003eendpoints-api-controller\u003c/filter-name\u003e\n \u003cservlet-name\u003eEndpointsServlet\u003c/servlet-name\u003e\n \u003c/filter-mapping\u003e\n\n4. Modify your API project's build configuration:\n\n ### Maven\n\n 1. Add the API management dependencies:\n\n \u003cdependency\u003e\n \u003cgroupId\u003ecom.google.endpoints\u003c/groupId\u003e\n \u003cartifactId\u003eendpoints-management-control-appengine-all\u003c/artifactId\u003e\n \u003cversion\u003e1.0.14\u003c/version\u003e\n \u003c/dependency\u003e\n\n 2. Include the plugin that you can use to generate client libraries\n and the OpenAPI document, `openapi.json`:\n\n \u003cplugin\u003e\n \u003cgroupId\u003ecom.google.cloud.tools\u003c/groupId\u003e\n \u003cartifactId\u003eendpoints-framework-maven-plugin\u003c/artifactId\u003e\n \u003cversion\u003e2.1.0\u003c/version\u003e\n \u003cconfiguration\u003e\n \u003c!-- plugin configuration --\u003e\n \u003chostname\u003e${endpoints.project.id}.appspot.com\u003c/hostname\u003e\n \u003c/configuration\u003e\n \u003c/plugin\u003e\n\n ### Gradle\n\n 1. Add the API management dependencies:\n\n compile 'com.google.endpoints:endpoints-management-control-appengine:1.0.14'\n compile 'com.google.endpoints:endpoints-framework-auth:1.0.14'\n\n 2. Declare the external dependency so that the plugin is\n retrieved from Maven Central:\n\n classpath 'com.google.cloud.tools:endpoints-framework-gradle-plugin:2.1.0'\n\n 3. Use the server-side Endpoints Frameworks Gradle plugin,\n which generates the OpenAPI document:\n\n apply plugin: 'com.google.cloud.tools.endpoints-framework-server'\n\n 4. Configure the name of your Endpoints service:\n\n endpointsServer {\n // Endpoints Framework Plugin server-side configuration\n hostname = \"${projectId}.appspot.com\"\n }\n\n5. After modifying dependencies, clean your project and then build your API:\n\n ### Maven\n\n ```bash\n mvn clean\n mvn package\n ```\n\n ### Gradle\n\n ```bash\n gradle clean\n gradle build\n ```\n6. Generate the OpenAPI document, `openapi.json`:\n\n ### Maven\n\n ```bash\n mvn endpoints-framework:openApiDocs\n ```\n\n ### Gradle\n\n ```bash\n gradle endpointsOpenApiDocs\n ```\n7. Deploy the OpenAPI document:\n\n gcloud endpoints services deploy openapi.json\n\n The first time you deploy `openapi.json`, a new Endpoints\n service is created with the name\n \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e`.appspot.com`. On\n successful completion, a line similar to the following displays\n the service configuration ID and the service name:\n\n \u003cbr /\u003e\n\n ```\n Service Configuration 2017-02-13r0 uploaded for service example-project-12345.appspot.com\n ```\n\n In the preceding example, `2017-02-13r0` is the service configuration\n ID. The service configuration ID consists of a date stamp followed by a\n revision number. If you deploy `openapi.json` again, the revision number is\n incremented in the service configuration ID.\n\n If you need to display the service configuration ID again, run the following\n command, but replace \u003cvar translate=\"no\"\u003eYOUR_PROJECT_ID\u003c/var\u003e with the\n project ID of your Google Cloud project: \n\n ```\n gcloud endpoints configs list --service=YOUR_PROJECT_ID.appspot.com\n ```\n\n You can create your own OpenAPI document and deploy it, rather than\n using a generated one. Simply replace `openapi.json` above with the path to\n your OpenAPI document. For more information on writing an OpenAPI document,\n see\n [OpenAPI overview](/endpoints/docs/openapi/openapi-overview).\n8. Edit your `appengine-web.xml` file to set the value for an environment\n variable:\n\n \u003cenv-variables\u003e\n \u003cenv-var name=\"ENDPOINTS_SERVICE_NAME\" value=\"${endpoints.project.id}.appspot.com\" /\u003e\n \u003c/env-variables\u003e\n\n Replace `${endpoints.project.id}` with your Google Cloud project ID.\n For example: \n\n \u003cenv-var name=\"ENDPOINTS_SERVICE_NAME\" value=\"example-project-12345.appspot.com\" /\u003e\n\n9. Redeploy your application.\n\n \u003cbr /\u003e\n\n ### Maven\n\n ```java\n mvn appengine:deploy\n ```\n\n ### Gradle\n\n ```java\n gradle appengineDeploy\n ```\n\n \u003cbr /\u003e\n\n10. Test your API by making some requests to it.\n\n11. To\n [view your API metrics](/endpoints/docs/frameworks/monitoring-your-api),\n open the **Endpoints** \\\u003e **Services** page in the Google Cloud console for your project: \n\n\n [Go to the Endpoints Services page](https://console.cloud.google.com/endpoints)\n\n \u003cbr /\u003e"]]