Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Architecture d'API Gateway
API Gateway est un système de gestion d'API qui fournit la gestion, la surveillance et l'authentification pour vos API. API Gateway est constitué des éléments suivants :
API Gateway : pour gérer tous les aspects d'une API déployée
Service Control : permet d'appliquer les règles de gestion des API.
Service Management : pour gérer les configurations d'API.
gcloud CLI : pour déployer et gérer vos API
Google Cloud console : permet la journalisation, la surveillance et le partage.
Architecture
Vous trouverez ci-dessous un diagramme général des principaux composants impliqués dans API Gateway :
Dans ce diagramme :
Le fournisseur d'API est responsable de la création et du déploiement d'une API sur API Gateway. Chaque API est définie par un fichier écrit en tant que spécification OpenAPI 2.0.
La spécification OpenAPI définit l'URL publique du point de terminaison REST pour l'API, le service de backend accessible par l'API et d'autres caractéristiques de l'API telles que l'authentification, le format des données et les options de réponse.
Le client d'API envoie une requête REST à une API hébergée sur API Gateway pour accéder aux services de backend. Un client API peut être n'importe quelle application capable d'effectuer un appel REST, comme un navigateur, une application mobile ou une application Web.
Le client API a uniquement besoin de connaître l'URL de l'API, le verbe de la requête (tel que GET, PUT, POST, DELETE), les conditions requises pour l'authentification et le format des données envoyées à l'API ou reçues de celle-ci.
Le client API n'a pas besoin de connaître l'implémentation du backend. En effet, une seule API hébergée sur API Gateway peut être configurée pour accéder à différents backends en fonction des informations transmises dans la requête.
Composants d'API Gateway
API Gateway
API Gateway fournit une solution entièrement gérée et payée à l'utilisation pour l'hébergement de vos API. API Gateway fournit un accès sécurisé à vos services de backend via une API REST bien définie et cohérente entre tous vos services, quelle que soit leur implémentation.
API Gateway est intégré à Google Cloud . Vous pouvez donc utiliser les mêmes outils de développement, de surveillance, de journalisation et de trace que ceux que vous utilisez avec n'importe quel autre produit Google Cloud .
Si vous vous connectez à un service de backend hébergé en dehors de Google Cloud, vous pouvez toujours profiter de tous les services Google Cloud , y compris les services d'authentification et d'autorisation utilisés pour contrôler l'accès à vos API.
API Service Control
L'API Service Control applique les règles de gestion des API lors de l'exécution, telles que l'authentification par clé API, la surveillance et la journalisation. Service Control utilise les méthodes suivantes :
Vérification : vérifie les clés d'authentification et les clés API et indique si un appel doit être autorisé.
Rapport : notifie les systèmes lors d'enregistrements de journalisation et de surveillance
API Service Management
Vous utilisez la spécification OpenAPI pour définir votre API. Vous utilisez ensuite la gcloud CLI pour importer la spécification OpenAPI dans Service Management, ce qui crée la configuration de l'API. D'autres tâches liées à la configuration sont également effectuées ici, telles que le partage de votre API avec d'autres développeurs, l'activation et la désactivation de l'API dans différents projets et la génération de clés API.
CLI gcloud
La gcloud CLI fournit l'outil de ligne de commande gcloud avec lequel vous pouvez appeler divers services Google Cloud . Utilisez Google Cloud CLI pour importer la spécification OpenAPI, ce qui crée la configuration d'API, puis pour déployer la configuration d'API sur API Gateway.
Cloud Console
La consoleGoogle Cloud est l'interface utilisateur graphique de la console Google Cloud . Utilisez la console Google Cloud pour exposer les données de surveillance et de journalisation enregistrées par Service Control, pour configurer l'authentification et l'autorisation, et pour permettre aux développeurs de générer des clés API pour appeler l'API.
Gérer une requête API
Dans une configuration d'API, il existe deux types de points de terminaison :
Point de terminaison de l'API : définit le point de terminaison accessible au public que les clients utilisent pour utiliser vos API.
Point de terminaison du backend : définit le point de terminaison que l'API utilise pour se connecter à votre service de backend. Les paramètres de sécurité, tels que l'accès HTTP ou HTTPS, sont définis par l'implémentation du service de backend.
Les requêtes envoyées à votre point de terminaison d'API sont transmises au point de terminaison de backend, y compris les données transmises dans la requête. Les réponses du service de backend, y compris les données renvoyées par le service, sont renvoyées au client.
Routage des requêtes
Lorsqu'une requête est reçue :
API Gateway crée un jeton de trace pour Cloud Trace.
API Gateway fait correspondre le chemin d'accès des requêtes entrantes avec l'API cible. Après avoir trouvé le chemin correspondant, API Gateway effectue toutes les étapes d'authentification pour l'API spécifiée.
Si la validation JWT est nécessaire, API Gateway valide l'authentification à l'aide de la clé publique appropriée pour le signataire et valide le champ d'audience dans le JWT. Si une clé API est requise, API Gateway appelle l'API Service Control pour la valider.
Service Control recherche la clé pour la valider et s'assure que le projet associé à la clé a activé l'API. Si la clé n'est pas valide ou si le projet n'a pas activé l'API, l'appel est rejeté et il est enregistré via l'API Service Control.
Si Service Control valide la clé, la requête, ainsi que tous les en-têtes d'origine, et l'en-tête de validation JWT le cas échéant, sont transmis au backend.
Lorsqu'une réponse est reçue du backend, API Gateway renvoie la réponse à l'appelant et envoie les informations de date et heure finales à Stackdriver Trace. Les points d'appel sont enregistrés par l'API Service Control, qui écrit les métriques et les journaux dans les destinations appropriées.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/03 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]