API Management on Google Cloud: Apigee, API Gateway, Cloud Endpoints and Designing Secure APIs
Why Manage APIs?
- APIs are how apps, partners and mobile clients use your services
- You need security, rate limits, analytics, versioning, developer onboarding and transformation in one place
- An API gateway or management layer keeps backends simple
The Options
| Product | Best for |
|---|---|
| Apigee | Full enterprise API management: policies, analytics, developer portal, monetization, hybrid and multi-cloud |
| API Gateway | Simple managed gateway for Cloud Run, Cloud Functions and App Engine backends (OpenAPI-based) |
| Cloud Endpoints | Lightweight API management with ESP/ESPv2 proxy (OpenAPI and gRPC) |
| Application Load Balancer + IAP + Cloud Armor | Protect internal and web apps |
| Cloud Service Mesh | Service-to-service traffic management inside GKE or VMs |
Apigee Concepts
| Concept | Meaning |
|---|---|
| API proxy | A facade in front of your backend that applies policies |
| Policies | Reusable steps: verify API key, OAuth, Spike Arrest, Quota, transform, cache, threat protection, JSON-to-XML |
| API product | A bundle of APIs with quota and access rules offered to developers |
| Developer, app and key | Who uses your API, with credentials |
| Environments and organizations | Dev, test, prod separation |
| Analytics and monitoring | Traffic, errors, latency, top apps |
| Developer portal | Documentation and self-service signup |
| Monetization | Charge for API use |
xml
<!-- An Apigee proxy flow snippet: check the key, then limit requests -->
<ProxyEndpoint name="default">
<PreFlow name="PreFlow">
<Request>
<Step><Name>VerifyAPIKey</Name></Step>
<Step><Name>SpikeArrest</Name></Step>
<Step><Name>Quota</Name></Step>
</Request>
</PreFlow>
<HTTPProxyConnection><BasePath>/v1/orders</BasePath></HTTPProxyConnection>
<RouteRule name="default"><TargetEndpoint>orders-backend</TargetEndpoint></RouteRule>
</ProxyEndpoint>
API Gateway Example
yaml
swagger: '2.0'
info: {title: Orders API, version: 1.0.0}
schemes: [https]
produces: [application/json]
paths:
/orders:
get:
operationId: listOrders
x-google-backend: {address: https://orders-abc-uc.a.run.app}
security: [{api_key: []}]
responses: {'200': {description: OK}}
securityDefinitions:
api_key: {type: apiKey, name: key, in: query}
bash
gcloud api-gateway api-configs create orders-v1 --api=orders-api --openapi-spec=openapi.yaml --backend-auth-service-account=orders-sa@my-proj.iam.gserviceaccount.com
gcloud api-gateway gateways create orders-gw --api=orders-api --api-config=orders-v1 --location=asia-northeast1
Authentication Choices
| Method | Use |
|---|---|
| API key | Identify an app, not secure on its own |
| OAuth 2.0 / JWT (OIDC) | User or app identity with tokens |
| Google ID tokens / service accounts | Service-to-service calls on Google Cloud |
| Mutual TLS | High-trust partner connections |
| IAP | Employee access to internal apps |
API Design Best Practices
- Use clear resource names:
/orders/42not/getOrder - Use the right HTTP methods and status codes
- Version the API (
/v1) and avoid breaking changes - Support pagination, filtering and idempotent retries
- Return consistent error messages
- Always use HTTPS, validate input, apply rate limits
- Publish an OpenAPI description and examples
- Use gRPC for fast internal service calls
Practice
- Deploy a Cloud Run service and put API Gateway in front
- Add an API key requirement
- Design the URLs and methods for a library API (books, members, loans)
- Explain when to choose Apigee instead of API Gateway
Conclusion
API Gateway fits simple serverless backends, Cloud Endpoints is a lightweight option and Apigee is the full management platform with policies, quotas, analytics and monetization. Secure APIs with strong authentication and design them cleanly.
Quick Summary: why; options; Apigee; API Gateway; authentication; design.

