[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eAPI Gateway provides secure access to services through a consistent REST API, simplifying consumption for app developers regardless of the underlying service implementation.\u003c/p\u003e\n"],["\u003cp\u003eIt allows for changes in backend service architecture without requiring modifications to the public API or app developers' deployed applications.\u003c/p\u003e\n"],["\u003cp\u003eAPI Gateway is a distributed API management system offering hosting, logging, monitoring, and security features, natively integrated with Google Cloud, to help create, share, maintain, and secure APIs.\u003c/p\u003e\n"],["\u003cp\u003eAn API defines a contract between providers and consumers, specifying entry points, data formats, and authentication, ensuring predictable changes over time and providing an interface for applications to consume data or functionalities from another application.\u003c/p\u003e\n"],["\u003cp\u003eAPI Gateway supports authentication methods like API keys and Google ID tokens, allowing you to control access to your API and manage what authenticated users can do.\u003c/p\u003e\n"]]],[],null,["# About API Gateway\n=================\n\nWeb-based services today provide a huge variety of functionality, meaning everything from map, weather, and image services, to games, auctions, and many other service types. Service providers have many options for how to implement, deploy, and manage their services. For example, one service might be developed in Java or .NET, while another uses Node.js.\n\nBackend implementations can also vary for a single service provider. A service provider might have legacy services implemented using one architecture, and new services implemented using a completely different architecture.\n\nRegardless of implementation, web-based services all require a way to make the services available to app developers. Often these services are exposed as a set of HTTP endpoints. Depending on the service, the endpoint might also return data, formatted as XML or JSON, to the client app.\n\nAbout Google Cloud services\n---------------------------\n\nWhen developing your services on the Google Cloud, you have many options for how you implement the services, such as [Cloud Run functions](/functions/docs), [Cloud Run](/run/docs), and [App Engine standard environment](/appengine/docs). The flexibility of Google Cloud means you choose the correct backend architecture for your service requirements.\n\nApp developers are the customers of backend services. App developers consume your services to implement apps for mobile devices or tablets, through apps running in a browser, or through any other type of app that can make a service request.\n\nExposing services publicly over the web can be challenging. To be successful, a service provider must:\n\n- Authenticate access to the service\n- Secure data transport between clients and the service\n- Protect the service from malicious attacks\n- Scale the service as usage increases or decreases\n- Provide the backend operations team with a way to monitor and track service usage\n- Track usage to provide accurate billing information\n\nAlso, if your services use different interfaces and protocols, then accessing these services can be a challenge to app developers. Developers must not only learn and understand each service interface, but they must also monitor the different services for changes, and then update and redeploy apps as necessary.\n\nAPI Gateway\n-----------\n\nAPI Gateway enables you to provide secure access to your services through a well-defined REST API that is consistent across all of your services, regardless of service implementation. A consistent API:\n\n- Makes it easy for app developers to consume your services\n- Enables you to change the backend service implementation without affecting the public API\n- Enables you to take advantage of the scaling, monitoring, and security features built into the Google Cloud Platform (GCP)\n\nThe following image shows app developers making requests to your backend services through API Gateway:\n\nUsing API Gateway, app developers consume your REST APIs to implement apps. Because all APIs are hosted on API Gateway, app developers see a consistent interface across all backend services.\n\nBy deploying your APIs on API Gateway, you can update the backend service, or even move the service from one architecture to another, without having to change the API. As long as the API to your service stays consistent, app developers won't have to modify deployed apps because of underlying changes on your backend.\n\nAPI Gateway is a distributed API management system that also provides hosting, logging, monitoring, and other features to help you create, share, maintain, and secure your APIs. API Gateway is natively integrated with Google Cloud and handles all the tasks involved in processing concurrent API calls, including traffic management, authorization, and monitoring.\n\nWhat is an API?\n---------------\n\nAn API is an interface that makes it possible for one application to consume capabilities or data from another application. By defining stable and well-documented entry points, APIs enable developers to access and reuse application logic built by other developers.\n\nFor example, the following table describes an example of a REST API that could return information about a book:\n\nUsing this information, you could make the following cURL request to this API to get information about a book: \n\n curl -X GET https://www.mybooksapi.com/books/info?isbn=0385504217\n\nBecause this service has a well-defined API, including a description of data formats and HTTP response codes, the app developer does not need to know anything about the underlying implementation of the backend service.\n\nSince applications that consume APIs are sensitive to changes, APIs also imply a contract between API providers and API consumers. The contract assures that over time the API will change in a predictable manner. For example, the book API might be updated to add additional query parameters, such as `title` or `author`, or change the response JSON to add additional information about the book.\n\n### Defining an API\n\nYou define an API deployed on API Gateway as an OpenAPI 2.0 spec.\nThe key components of an API definition include:\n\n- The URL, or entry point, of the backend service\n- The data format of any data passed on a request to the API\n- The data format of any data returned by the service in the response from the API\n- The authentication mechanism used to control access to the service\n\nAfter you define your API, use the [gcloud](/sdk/gcloud/reference) command line interface to upload it to an API config on GCP:\n\n### Deploying an API config on API Gateway\n\nTo create your API, you deploy the API config on API Gateway.\nUse the `gcloud` command to deploy the API config:\n\nAfter the API config is deployed, your clients can make REST calls to the API.\n\n### Managing an API\n\nOnce deployed and running, you can monitor API activity, such as usage metrics and logs. When a client makes a request to your API, API Gateway logs information about the request and response. API Gateway also tracks latency, traffic, and errors.\n\nOver time, you might want to update a deployed API to add new capabilities, improve performance, or to fix issues with the API. To update a deployed API, you update the OpenAPI spec for the API definition, then upload and redeploy the API.\n\n### Controlling API access\n\nAPI Gateway lets you configure your API to require authentication before the client can access the API. API Gateway supports the same authentication mechanism and syntax as used by [Cloud Endpoints](/endpoints/docs), including using:\n\n- [API keys](/endpoints/docs/openapi/restricting-api-access-with-api-keys)\n- [Authentication methods at Google](https://cloud.google.com/docs/authentication/#service_accounts)\n- [Google ID tokens](/endpoints/docs/openapi/glossary#google_id_token)\n\nYou can also use the Google Cloud console to share your API with other developers so they can enable your API and generate API keys to call it.\n\nAlong with defining an authentication mechanism to verify a user's identity, your API also needs to decide what the authenticated user can do with your API. For more information, see [Authentication methods at Google](https://cloud.google.com/docs/authentication).\n\nWhat's next\n-----------\n\n- [API Gateway Architecture](/api-gateway/docs/architecture-overview)"]]