Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Arquitectura de API Gateway
API Gateway es un sistema de administración de API que brinda administración, supervisión y autenticación para tus API. Los componentes que conforman API Gateway incluyen los siguientes:
API Gateway: Para administrar todos los aspectos de una API implementada
Service Control: para aplicar las reglas de administración de API
Service Management: para administrar las configuraciones de API
gcloud CLI: Para implementar y administrar tus APIs
Google Cloud console: Para registrar, supervisar y compartir
Arquitectura
A continuación, se muestra un diagrama de alto nivel de los componentes principales de API Gateway:
En este diagrama, se ilustra lo siguiente:
El proveedor de la API es responsable de crear e implementar una API en API Gateway. Cada API se define con un archivo escrito como una especificación de OpenAPI 2.0.
La especificación de OpenAPI define la URL pública del extremo de REST para la API, el servicio de backend al que accede la API y cualquier otra característica de la API, como la autenticación, el formato de datos y las opciones de respuesta.
El cliente de la API realiza una solicitud de REST a una API alojada en API Gateway para acceder a los servicios de backend. Un cliente de API puede ser cualquier app capaz de realizar una llamada a REST, como un navegador, una app para dispositivos móviles o una app web.
El cliente de la API solo necesita conocer la URL de la API, el verbo de la solicitud (como GET, PUT, POST, DELETE), los requisitos de autenticación y el formato de los datos que se envían a la API o se reciben de ella.
El cliente de API no necesita saber nada sobre la implementación del backend. De hecho, una sola API alojada en API Gateway se puede configurar para acceder a diferentes backends según la información que se pasa en la solicitud.
Componentes de API Gateway
API Gateway
API Gateway proporciona una solución de pago por uso completamente administrada para alojar tus API. API Gateway proporciona acceso seguro a tus servicios de backend mediante una API de REST bien definida que sea coherente en todos tus servicios, sin importar la implementación del servicio.
API Gateway se integra en Google Cloud para que puedas usar las mismas herramientas de desarrollo, supervisión, registro y seguimiento que usas con cualquier otro producto de Google Cloud .
Si te conectas a un servicio de backend alojado fuera de Google Cloud, aún puedes aprovechar todos los servicios de Google Cloud , incluidos los de autenticación y autorización que se usan para controlar el acceso a tus APIs.
Service Control API
La API de Service Control aplica reglas de administración de API en el entorno de ejecución, como autenticación de clave de API, supervisión y registro. Service Control proporciona los métodos siguientes:
Verificación: comprueba la autenticación y las claves de API, y también indica cuándo se debe permitir una llamada.
Informe: notifica a los sistemas de registro para el registro y la supervisión.
API de Administración de servicios
Usas la especificación de OpenAPI para definir tu API. Luego, usa gcloud CLI para subir la especificación de OpenAPI a Service Management, que crea la configuración de la API. Aquí también tienen lugar otras tareas relacionadas con la configuración, como compartir la API con otros desarrolladores, habilitar o inhabilitar la API en proyectos diferentes y generar claves de API.
gcloud CLI
La CLI de gcloud proporciona la herramienta de línea de comandos de gcloud que puedes usar para realizar llamadas a varios servicios de Google Cloud . Usas la Google Cloud CLI para subir tu especificación de OpenAPI, que crea la configuración de la API y, luego, implementarla en API Gateway.
Consola de Cloud
Google Cloud console es la interfaz gráfica de usuario para Google Cloud console. Usa la Google Cloud consola para exponer los datos de supervisión y registro que registra Control de servicios, configurar la autenticación y la autorización, y para que los desarrolladores generen claves de API para llamar a la API.
Cómo controlar una solicitud a la API
En una configuración de API, hay dos tipos de extremos:
Extremo de API: Define el extremo disponible públicamente que los clientes usan para consumir tus APIs.
Extremo de backend: Define el extremo que usa la API para conectarse a tu servicio de backend. La implementación del servicio de backend define la configuración de seguridad, como el acceso HTTP o HTTPS.
Las solicitudes a tu extremo de API se pasan al extremo de backend, incluidos los datos que se pasaron como parte de la solicitud. Las respuestas del servicio de backend, incluidos los datos que devuelve el servicio, se pasan al cliente.
Solicitar enrutamiento
Cuando se recibe una solicitud, ocurre lo siguiente:
API Gateway crea un token de seguimiento para Cloud Trace.
API Gateway coincide con la ruta de las solicitudes entrantes con la API de destino. Después de encontrar una ruta que coincide, API Gateway realiza los pasos de autenticación necesarios para la API especificada.
Si se requiere una validación de JWT, API Gateway valida la autenticación por medio de la clave pública adecuada para el firmante y valida el campo del público en el JWT. Si se requiere una clave de API, API Gateway llama a la API de Service Control para validar la clave.
Service Control busca la clave para validarla y se asegura de que el proyecto asociado a esa clave haya habilitado la API. Si la clave no es válida o si el proyecto no habilitó la API, se rechaza la llamada y se la registra por medio de la API de Service Control.
Si Service Control valida la clave correctamente, la solicitud se reenvía al backend con todos los encabezados originales, y con un encabezado de validación de JWT si corresponde.
Cuando se recibe una respuesta del backend, API Gateway le muestra la respuesta al emisor y envía la información final sobre el tiempo a Trace. Los puntos de llamada se registran mediante la API de Service Control, que escribe las métricas y los registros en sus destinos correspondientes.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-03 (UTC)"],[[["\u003cp\u003eAPI Gateway is a fully managed system for API management, providing a secure, consistent REST API for backend services and handling authentication, monitoring, and logging.\u003c/p\u003e\n"],["\u003cp\u003eThe API provider defines APIs using OpenAPI specs, and API clients access these APIs without needing to know the backend implementation, while the client is only required to know the URL and the format of the API.\u003c/p\u003e\n"],["\u003cp\u003eService Control API handles API management rules at runtime, including API key validation, logging, and monitoring through methods like Check and Report.\u003c/p\u003e\n"],["\u003cp\u003eService Management API manages API configurations, such as creating the API config, sharing the API, and enabling or disabling the API in projects.\u003c/p\u003e\n"],["\u003cp\u003eWhen an API request is received, API Gateway routes the request to the correct backend service after performing authentication and validation, then returns the backend's response to the client, while also logging the call and sending metrics.\u003c/p\u003e\n"]]],[],null,["# API Gateway Architecture\n========================\n\nAPI Gateway is an API management system that provides management, monitoring, and authentication for your APIs. The components that make up API Gateway include:\n\n- **API Gateway**: for managing all aspects of a deployed API\n- **Service Control**: for applying API management rules\n- **Service Management**: for managing API configurations\n- **gcloud CLI**: for deploying and managing your APIs\n- **Google Cloud console**: for logging, monitoring and sharing\n\nArchitecture\n------------\n\nThe following is a high level diagram of the major components involved in API Gateway:\n\nIn this diagram:\n\n- **The API provider** is responsible for creating and deploying an API on API Gateway. Each API is defined by a file written as an OpenAPI 2.0 spec.\n\n The OpenAPI spec defines the publicly facing URL of the REST endpoint for the API, the backend service accessed by the API, and any other characteristics of the API such as authentication, data format, and response options.\n- **The API client** makes a REST request to an API hosted on API Gateway to access backend services. An API client can be any app capable of making a REST call, such as a browser, mobile app, or web app.\n\n The API client only needs to know the URL of the API, the request verb (such as `GET`, `PUT`, `POST`, `DELETE`),\n any authentication requirements, and the format of any data sent to or received from the API.\n\n The API client does not need to know anything about the backend implementation. In fact, a single API hosted on API Gateway can be configured to access different backends based on information passed in the request.\n\nAPI Gateway components\n----------------------\n\n### API Gateway\n\nAPI Gateway provides a fully managed, pay-per-use solution for hosting your APIs. API Gateway provide secure access to your backend services through a well-defined REST API that is consistent across all of your services, regardless of the service implementation.\n\nAPI Gateway is integrated with Google Cloud so that you can use the same development, monitoring, logging, and trace tools that you use with any other Google Cloud product.\n\nIf you are connecting to a backend service hosted outside of Google Cloud, you can still take advantage of all Google Cloud services, including the authentication and authorization services used to control access to your APIs.\n\n### Service Control API\n\n[Service Control API](https://cloud.google.com/service-control/) applies API management rules at runtime, such as API key authentication, monitoring, and logging. Service Control provides the following methods:\n\n- **Check**: verifies authentication and API keys, and indicates whether a call should be permitted\n- **Report**: notifies the systems of record for logging and monitoring\n\n### Service Management API\n\nYou use the [OpenAPI specification](/endpoints/docs/openapi/openapi-overview) to define your API. You then use the gcloud CLI to upload the OpenAPI spec to Service Management, which creates the API config. Other configuration-related tasks also happen here, such as sharing your API with other developers, enabling or disabling the API in different projects, and generating API keys.\n\n### gcloud CLI\n\nThe [gcloud CLI](https://cloud.google.com/sdk/docs) provides the [gcloud](/sdk/gcloud/reference) command-line tool that you can use to make calls to various Google Cloud services. You use the Google Cloud CLI to upload your OpenAPI spec, which creates the API config, and then to deploy the API config to API Gateway.\n\n### Cloud console\n\n[Google Cloud console](https://console.cloud.google.com/) is the graphical user interface for Google Cloud console. Use the Google Cloud console to expose monitoring and logging data recorded by Service Control, to configure authentication and authorization, and for developers to generate API keys to call the API.\n\nHandling an API request\n-----------------------\n\nIn an API configuration, there are two types of endpoints:\n\n- **API endpoint**: defines the publicly available endpoint that clients use to consume your APIs.\n- **Backend endpoint**: defines the endpoint that the API uses to connect to your backend service. Security settings, such as HTTP or HTTPS access, are defined by the implementation of the backend service.\n\nRequests to your API endpoint are passed to the backend endpoint, including any data passed as part of the request. Responses from the backend service, including any data returned by the service, are passed back to the client.\n\n### Request routing\n\nWhen a request is received:\n\n1. API Gateway creates a trace token for Cloud Trace.\n\n2. API Gateway matches the path of the incoming requests with the target API. After finding a matching route, API Gateway performs any authentication steps for the specified API.\n\n3. If JWT validation is necessary, API Gateway validates the authentication using the appropriate public key for the signer, and validates the audience field in the JWT. If an API key is required, API Gateway calls the Service Control API to validate the key.\n\n4. Service Control looks up the key to validate it, and ensures that the project associated with the key has enabled the API. If the key isn't valid or the project hasn't enabled the API, the call is rejected and it is logged via the Service Control API.\n\n5. If Service Control successfully validates the key, the request along with all original headers, plus a JWT validation header, if appropriate, is forwarded to the backend.\n\n6. When a response is received from the backend, API Gateway returns the response to the caller and sends the final timing information to Trace. The call points are logged by the Service Control API, which then writes metrics and logs to their appropriate destinations.\n\nWhat's next\n-----------\n\n- [API Gateway Deployment Model](/api-gateway/docs/deployment-model)"]]