Organízate con las colecciones
Guarda y clasifica el contenido según tus preferencias.
Arquitectura de API Gateway
API Gateway es un sistema de gestión de APIs que proporciona gestión, monitorización y autenticación para tus APIs. Entre los componentes que forman API Gateway se incluyen los siguientes:
Pasarela de APIs: para gestionar todos los aspectos de una API implementada
Service Control: para aplicar reglas de gestión de APIs
Service Management: para gestionar las configuraciones de las APIs
CLI de gcloud: para desplegar y gestionar tus APIs
Google Cloud Consola: para registrar, monitorizar y compartir
Arquitectura
A continuación, se muestra un diagrama general de los componentes principales que intervienen en API Gateway:
En este diagrama:
El proveedor de la API es el responsable de crear y desplegar una API en API Gateway. Cada API se define mediante un archivo escrito como una especificación de OpenAPI 2.0.
La especificación de OpenAPI define la URL pública del endpoint REST de la API, el servicio 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 envía una solicitud REST a una API alojada en API Gateway para acceder a los servicios de backend. Un cliente de API puede ser cualquier aplicación capaz de hacer una llamada REST, como un navegador, una aplicación móvil o una aplicación web.
El cliente de la API solo necesita saber la URL de la API, el verbo de la solicitud (como GET, PUT, POST o DELETE),
los requisitos de autenticación y el formato de los datos enviados o recibidos de la API.
El cliente de la 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 en función de la información que se transmita en la solicitud.
Componentes de API Gateway
API Gateway
API Gateway ofrece una solución totalmente gestionada y de pago por uso para alojar tus APIs. API Gateway proporciona acceso seguro a tus servicios de backend a través de una API REST bien definida que es coherente en todos tus servicios, independientemente de la implementación del servicio.
API Gateway está integrado con Google Cloud para que puedas usar las mismas herramientas de desarrollo, monitorizació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, puedes seguir aprovechando todos los servicios de Google Cloud , incluidos los servicios de autenticación y autorización que se usan para controlar el acceso a tus APIs.
API Service Control
La API Service Control aplica reglas de gestión de APIs en el tiempo de ejecución, como la autenticación de claves de API, la monitorización y el registro. Service Control proporciona los siguientes métodos:
Comprobar: verifica la autenticación y las claves de API, e indica si se debe permitir una llamada.
Informe: notifica a los sistemas de registro para el registro y la monitorización.
API Service Management
Utiliza la especificación de OpenAPI para definir tu API. A continuación, usa gcloud CLI para subir la especificación de OpenAPI a Service Management, lo que crea la configuración de la API. Aquí también se realizan otras tareas relacionadas con la configuración, como compartir tu API con otros desarrolladores, habilitar o inhabilitar la API en diferentes proyectos y generar claves de API.
CLI de gcloud
La CLI de gcloud proporciona la herramienta de línea de comandos gcloud, que puedes usar para hacer llamadas a varios servicios de Google Cloud . Utilizas la CLI de Google Cloud para subir tu especificación de OpenAPI, que crea la configuración de la API, y, a continuación, para desplegar la configuración de la API en API Gateway.
consola de Cloud
La consolaGoogle Cloud es la interfaz gráfica de usuario de la consola Google Cloud . Usa la Google Cloud consola para exponer los datos de monitorización y registro que ha registrado Service Control, configurar la autenticación y la autorización, y permitir que los desarrolladores generen claves de API para llamar a la API.
Gestionar una solicitud a la API
En una configuración de API, hay dos tipos de endpoints:
Punto de conexión de la API: define el punto de conexión disponible públicamente que usan los clientes para consumir tus APIs.
Endpoint de backend: define el endpoint que usa la API para conectarse a tu servicio de backend. Los ajustes de seguridad, como el acceso HTTP o HTTPS, se definen mediante la implementación del servicio de backend.
Las solicitudes a tu endpoint de la API se transfieren al endpoint de backend, incluidos los datos que se hayan enviado como parte de la solicitud. Las respuestas del servicio de backend, incluidos los datos que devuelva el servicio, se reenvían al cliente.
Enrutamiento de solicitudes
Cuando se recibe una solicitud:
API Gateway crea un token de traza para Cloud Trace.
API Gateway compara la ruta de las solicitudes entrantes con la API de destino. Después de encontrar una ruta que coincida, API Gateway realiza los pasos de autenticación de la API especificada.
Si es necesario validar el JWT, API Gateway valida la autenticación mediante la clave pública adecuada del firmante y valida el campo de audiencia del JWT. Si se necesita una clave de API, API Gateway llama a la API Service Control para validar la clave.
Service Control busca la clave para validarla y comprueba que el proyecto asociado a la clave tenga habilitada la API. Si la clave no es válida o el proyecto no ha habilitado la API, la llamada se rechaza y se registra a través de la API Service Control.
Si Service Control valida la clave correctamente, la solicitud, junto con todos los encabezados originales y un encabezado de validación de JWT (si procede), se reenvía al backend.
Cuando se recibe una respuesta del backend, API Gateway devuelve la respuesta a la persona que ha llamado y envía la información de tiempo final a Trace. La API Service Control registra los puntos de llamada y, a continuación, escribe las métricas y los registros en sus destinos correspondientes.
[[["Es fácil de entender","easyToUnderstand","thumb-up"],["Me ofreció una solución al problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Es difícil de entender","hardToUnderstand","thumb-down"],["La información o el código de muestra no son correctos","incorrectInformationOrSampleCode","thumb-down"],["Me faltan las muestras o la información que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-19 (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)"]]