Cloud Endpoints in Google Cloud: The Complete Guide to Securing, Monitoring and Managing Your APIs
A deep, plain-English walkthrough of how Cloud Endpoints places a smart gatekeeper in front of your APIs, checking identity, enforcing quotas, recording every call and giving you clear visibility, whether your backend runs on Cloud Run, Kubernetes, virtual machines or App Engine.
Imagine a large office building with a reception desk at the front door. Visitors do not wander straight into offices. The receptionist asks who they are, checks that they have an appointment, limits how many people can enter at once, writes every visit in a logbook and guides each guest to the right floor. The people working upstairs can focus on their jobs without worrying about who walks in. In the world of software, your API is the building and Cloud Endpoints is the reception desk. It stands in front of your service, checks every request, and passes only the good ones through, while recording everything that happens. This guide explains the whole service in simple language, from the basic idea to production-grade design.
1What Cloud Endpoints Is and Why It Exists
Cloud Endpoints is an API management service that helps you develop, deploy, secure, monitor and control access to your APIs.
The problem it solves
An API, or application programming interface, is a doorway that lets other programs talk to your service. A mobile app asks your API for a customer’s orders. A partner system sends your API a payment request. As soon as an API is opened to the outside world, many questions appear. Who is calling? Are they allowed to? Is one caller sending a million requests and starving everyone else? How many calls did we get yesterday, how fast were they, and how many failed? Which version of the API is each partner using?
If every team answers these questions by writing code inside its own service, the work is repeated again and again, and each service ends up with its own half-finished security and its own slightly different logging. Cloud Endpoints moves these shared concerns out of your business code and into a proxy that sits in front of your service. Your code stays focused on the business problem, while the proxy handles identity checks, usage limits, logging, metrics and tracing in one consistent way.
Cloud Endpoints is the reception desk of your service. The desk checks identification, counts visitors, enforces visiting limits and keeps the logbook, so the staff upstairs do not need to do any of that themselves.
What it is used for
Teams use Cloud Endpoints to protect public and partner-facing APIs, to require API keys or tokens, to apply per-customer usage limits, to see traffic and error patterns, and to publish a clear description of what an API offers. It works for traditional web APIs that exchange structured text over the web and for high-performance gRPC services.
2Core Concepts You Must Know First
A small vocabulary makes the rest of the guide easy, so learn these eight terms before moving on.
API
A set of web addresses and rules through which programs request data or actions from your service.
API Specification
A written description of an API listing its paths, methods, inputs and outputs. Endpoints reads it to learn what to protect and manage.
Proxy
A program that sits in front of your service, receives each request first and decides whether and how to pass it along.
Managed Service
The Endpoints record of your API inside Google Cloud, created when you deploy a specification and given a unique service name.
Service Configuration
A versioned snapshot of the rules for your API, produced from your specification and used by the proxy to make decisions.
API Key
A simple secret string that identifies the project calling your API, mainly used for tracking and quotas rather than strong security.
Quota
A limit on how many requests a caller may make over a period, protecting your service from overuse.
Consumer
The project or application that calls your API, and the unit against which usage is tracked and limited.
The API is the building, the specification is the floor plan, the proxy is the receptionist, the service configuration is the receptionist’s rulebook, an API key is a visitor card and a quota is the number of visits allowed per day.
3Where Endpoints Fits Among API Management Choices
Google Cloud offers more than one way to manage APIs, and choosing well saves rework.
The neighbors
API Gateway is a fully managed gateway service that is built on the same proxy technology used by Endpoints. You deploy an API configuration and Google runs the gateway for you, so there is no proxy for you to place or operate. Apigee is a full enterprise API management platform with a developer portal, advanced analytics, monetization, mediation and policy tooling, and it suits large programs with many partners. Cloud Endpoints sits between these: you run a proxy yourself, close to your backend, and gain strong control with a lightweight setup.
| Question | Cloud Endpoints | API Gateway | Apigee |
|---|---|---|---|
| Who runs the proxy? | You deploy and operate it | Google runs it for you | Google runs a full platform |
| Typical effort | Moderate | Low | Higher, but powerful |
| Control over placement | High, beside your backend | Lower, managed gateway | Platform managed |
| Developer portal and monetization | Limited | Not a focus | Rich features |
| Best for | Teams wanting a light, flexible proxy | Teams wanting a simple managed gateway | Large API programs with many partners |
Google’s product guidance for API management evolves, and newer projects are sometimes steered toward API Gateway or Apigee. Check the current official documentation before choosing for a brand-new system, and treat the concepts in this guide as useful across all three.
API Gateway is a building with a reception desk that the landlord staffs. Endpoints is a desk you bring and staff yourself, placed exactly where you want it. Apigee is an entire visitor-management department with badges, brochures, analytics and a gift shop.
4Architecture and Main Components
Endpoints is made of a few clearly separated pieces, each with one job.
The big picture
Two parts live outside your service. The management plane is the Google Cloud side, where your API specification is uploaded, checked and turned into a managed service with a versioned configuration. The data plane is the proxy that you deploy beside your backend, which handles live traffic. When a request arrives, the proxy asks the Google control service whether the call is allowed, using the configuration it downloaded. If the answer is yes, the proxy forwards the request to your backend and returns the response. While doing so, it reports metrics and logs back to Google Cloud for monitoring, logging and tracing.
flowchart LR
CL["API Clients"] --> PX["Proxy: ESP or ESPv2"]
PX --> BE["Your Backend Service"]
PX --> SC["Service Control"]
SM["Service Management and Configuration"] --> PX
SC --> MON["Cloud Monitoring"]
SC --> LOG["Cloud Logging"]
PX --> TR["Cloud Trace"]
SPEC["API Specification"] --> SM
Each piece in one line
The specification describes the API. Service Management stores it and creates configuration versions. The proxy sits in front of the backend and enforces the rules. Service Control checks keys and quotas and receives usage reports. Monitoring, Logging and Trace turn those reports into dashboards, searchable logs and request timelines.
The specification is the building directory. Service Management is the head office that prints the rulebook. The proxy is the receptionist who follows it. Service Control is the office the receptionist phones to confirm a visitor is allowed, and monitoring is the manager reading the visitor logbook.
5The Proxy: ESP and ESPv2
The proxy is the working heart of Endpoints, and it comes in two generations.
The original proxy
The Extensible Service Proxy, known as ESP, is the original proxy. It is based on a widely used web server and is available as a ready-made container image. It supports web APIs described in a common specification format and also gRPC services.
The newer proxy
ESPv2 is the newer generation, built on Envoy, a modern high-performance proxy widely used in cloud systems. It supports the same kinds of APIs and adds features, better performance and a path that matches how Google’s other gateway products work. For new work, ESPv2 is the usual choice, and it can also be deployed as a standalone service on Cloud Run, which makes a fully serverless setup possible.
What the proxy does for each request
For every call, the proxy checks that the request matches a path and method in the specification. It checks credentials such as API keys or tokens against the rules. It asks the control service about quota. It forwards the request to the backend, observes the response and records the outcome. It can also translate between formats, for example converting an ordinary web request into a gRPC call for the backend.
| Feature | ESP | ESPv2 |
|---|---|---|
| Foundation | Web server based | Envoy based |
| Specification support | OpenAPI and gRPC | OpenAPI and gRPC |
| Deployment as standalone Cloud Run service | Not the main path | Supported |
| Direction for new projects | Older generation | Preferred generation |
HTTP to gRPC translation
A team builds a fast internal gRPC backend but wants mobile and web clients to use ordinary web requests. The proxy translates between the two, so the backend stays efficient and clients stay simple.
ESP is the veteran receptionist who has served well for years. ESPv2 is the newer receptionist with better training and modern equipment. Both follow the same rulebook, but the newer one is where the investment goes.
6Describing Your API: OpenAPI and gRPC
Everything in Endpoints begins with a written description of the API.
OpenAPI for web APIs
For ordinary web APIs, you write an OpenAPI specification. It lists each path, the methods allowed on it, the inputs it accepts, the outputs it returns and how callers must prove their identity. A single source of truth like this has many benefits. It documents the API for humans, it can be used to generate client libraries and test tools, and Endpoints reads it to build the rules for the proxy.
gRPC for high-performance services
For gRPC services, the description comes from the service definition file together with a compiled descriptor and a small configuration file that sets the service name, authentication rules and quota details. gRPC is popular for efficient communication between services, and Endpoints can protect it in the same way as web APIs.
Google extensions
Endpoints adds its own extra fields to the specification, which let you describe things the standard format does not cover. These extensions set the service name and host, tell the proxy where the real backend lives, define metrics and quotas, and control some behavior such as how long to wait for the backend. They keep all management rules in the same document as the API description.
Endpoint Settings
Names the service, sets how it is allowed to be called from browsers and controls the entry address.
Backend Settings
Points the proxy to the real backend address and says how to identify itself and how long to wait.
Management Settings
Defines the metrics that count usage and the quota limits applied to them.
Authentication Settings
Describes who may issue tokens, which audiences are accepted and where to find the keys that verify them.
Keep the specification in version control and treat it as the contract of your API. Reviews of API changes then happen through reviews of that document, which catches breaking changes before callers do.
The specification is the building’s blueprint with the receptionist’s instructions written in the margins. Anyone can read it to understand the building, and the receptionist reads the same page to know the rules.
7Managed Services, Configurations and Rollouts
Deploying an API to Endpoints creates records that are versioned and can be rolled out safely.
The managed service
When you deploy your specification, Endpoints creates a managed service with a unique name, which usually follows a pattern based on the project and a host name. This name is the identity of your API inside Google Cloud, and it is what callers’ projects enable in order to use your API.
Configuration versions
Every deployment of a changed specification produces a new service configuration with its own identifier. Older versions are kept. This means you can always see what rules were active at a given time and can return to an earlier version if a change causes problems.
Rollouts
A rollout decides which configuration the proxies actually use. Proxies can be set to follow the latest version automatically, which is convenient, or to use a pinned version, which is safer for production because nothing changes until you decide. When a proxy starts, it downloads the configuration it was told to use and then enforces it.
Write or change the specification
Update the description of paths, authentication and quotas and review the change.
Deploy it to Endpoints
The service validates the specification and creates a new configuration version with an identifier.
Choose the rollout
Decide whether proxies follow the newest version or are pinned to a specific one.
Proxies pick up the configuration
New or restarted proxies download the chosen version and begin enforcing it.
Observe and roll back if needed
Watch error rates and latency, and point proxies back to an earlier version if the change misbehaves.
Deploying a new specification and assuming running proxies have instantly changed behavior. Depending on how they are configured, they may need to be restarted or redeployed to adopt the new version. Always confirm which configuration each proxy is actually running.
Each configuration is a numbered edition of the reception desk rulebook. The head office prints a new edition when rules change. Each receptionist keeps working from the edition they were handed until told to switch, and old editions stay on the shelf in case you need to go back.
8Deployment Options: Where the Proxy Runs
Because you run the proxy, you choose where it lives, and each platform has its own pattern.
Cloud Run
ESPv2 can run as its own Cloud Run service in front of a backend that is also on Cloud Run, or in front of other backends. This gives a fully serverless setup, where both proxy and backend scale automatically and you manage no machines.
Google Kubernetes Engine
The proxy can be deployed as a sidecar container in the same pod as the backend, so each backend copy has its own proxy, or as a separate shared deployment. The sidecar pattern keeps traffic between proxy and backend inside the pod.
Compute Engine
On virtual machines, the proxy is run as a container beside the backend or as a separate group of machines in front of it, usually behind a load balancer.
App Engine flexible environment
The proxy runs next to the application as part of the deployment, a common setup for older services using that platform.
Other environments
The proxy can also run on other clouds or on-premises servers, because it only needs to reach the Google control services to fetch configuration and report usage.
flowchart LR
C["Client"] --> LB["Load Balancer or Cloud Run URL"]
LB --> P1["Proxy Instance"]
P1 --> B1["Backend on Cloud Run"]
LB --> P2["Proxy Sidecar in Pod"]
P2 --> B2["Backend on GKE"]
P1 -.-> G["Google Control Services"]
P2 -.-> G
| Platform | Typical proxy pattern | Operations effort |
|---|---|---|
| Cloud Run | Standalone proxy service | Low, fully serverless |
| GKE | Sidecar or shared deployment | Moderate |
| Compute Engine | Container beside the backend or a separate group | Moderate to higher |
| App Engine flexible | Proxy beside the application | Moderate |
Leaving the backend directly reachable from the internet while also placing a proxy in front. Callers can then bypass every rule. Restrict the backend so that only the proxy can reach it.
9Internal Working: Life of a Request
Follow a single call from a client to your backend and back to see what the proxy does.
The client sends a request
It includes the path, method, body and credentials such as an API key or a token.
The proxy matches it to the specification
If the path or method is not defined, the request is rejected right away, before touching your backend.
Credentials are checked
API keys are checked with the control service. Tokens are verified locally using keys fetched from the issuer, and the audience and issuer are compared against the rules.
Quota is evaluated
The proxy reports the call against the caller’s limits. If the limit is exceeded, the proxy responds with a standard too-many-requests error.
The request is forwarded
The proxy passes the call to the backend, along with useful details such as the caller’s verified identity, and waits for the response.
The response returns and usage is reported
The proxy sends the answer to the client, then reports metrics, logs and trace information to Google Cloud for later analysis.
sequenceDiagram
participant C as Client
participant P as Proxy
participant SC as Service Control
participant B as Backend
C->>P: Request with credentials
P->>P: Match path and method
P->>SC: Check key and quota
SC-->>P: Allowed
P->>B: Forward request
B-->>P: Response
P-->>C: Response
P->>SC: Report usage and logs
Calls to undefined paths, calls with missing credentials and calls over quota are refused at the proxy. Your backend never spends effort on them, which protects it during abuse or mistakes.
A visitor arrives. The receptionist checks that the room they ask for exists, checks their ID, checks they have not exceeded today’s visit limit, and only then calls upstairs. Afterwards, the visit is logged in the book.
10Authentication Methods
Endpoints supports several ways for callers to prove who they are, and each suits a different situation.
API Keys
A simple string that identifies the calling project. Good for tracking and quotas, but not strong proof of identity, because keys can be copied.
Service Account Tokens
Signed tokens from a Google service account, ideal for one backend system calling another with strong, verifiable identity.
Google ID Tokens
Tokens that prove a person signed in with a Google account, suited to apps where users sign in through Google.
Firebase Authentication
Tokens from the Firebase sign-in service, popular for mobile and web applications with end-user sign-in.
Custom or Third-party Tokens
Tokens from an identity provider that follows the common token standard, which lets companies reuse an existing sign-in system.
How token checking works
A token is a small signed message that carries claims, such as who the user is, who issued the token and who it is meant for. The proxy checks the signature using the issuer’s public keys, which it fetches and caches. It checks that the issuer is trusted, that the audience matches your API and that the token has not expired. Because the check is done locally with cached keys, it adds very little delay to each call.
| Method | Identifies | Strength | Best for |
|---|---|---|---|
| API key | A project or application | Low, a shared secret | Usage tracking and quotas |
| Service account token | A machine identity | High | Service-to-service calls |
| Google ID token | A user with a Google account | High | Apps using Google sign-in |
| Firebase token | An app end user | High | Mobile and web apps |
| Third-party token | A user from another provider | High | Existing company sign-in |
Problem
Relying on an API key alone to protect sensitive data or actions.
Why It’s Harmful
Keys are easily copied from apps, logs or screenshots, and a stolen key gives full access to whatever the key allows.
Correct Approach
Use keys for identification and quotas, and combine them with token-based authentication for real proof of identity.
An API key is like a library card number that anyone could read over your shoulder. A signed token is like a government ID with a hologram and a photo that the receptionist can actually verify.
11Securing the Backend: Identity Between Proxy and Service
The proxy protects the front, but the backend must also trust that traffic really came through it.
Proving the proxy’s identity
A common setup is for the proxy to attach its own identity token when calling the backend. On Cloud Run, for example, the backend can be set to accept only authenticated callers, and the proxy’s service account is the only one granted permission to invoke it. A direct call from anyone else is then refused by the platform before the backend sees it.
Passing the caller’s identity along
After verifying a user’s token, the proxy can pass details of that verified identity to the backend in a standard header. The backend can use this to apply its own rules, for example showing a customer only their own orders. The backend should trust this header only when it knows the request came through the proxy, which is why locking down direct access is so important.
Network protection
Backends can be placed on private networks, with firewall rules that accept traffic only from the proxy. Encryption in transit should be used between client and proxy, and ideally between proxy and backend. Perimeter controls can further limit which networks may reach the services.
Make the backend private
Require authenticated callers or restrict network access so only the proxy can reach it.
Give the proxy a dedicated identity
Use a service account that has permission only to call this backend.
Forward verified caller details
Let the backend read the identity that the proxy verified, and use it for fine-grained decisions.
Encrypt everything in transit
Use secure connections on both sides of the proxy.
Trusting the forwarded identity header on a backend that is also directly reachable. An attacker could simply send that header themselves. Trust it only when direct access is impossible.
The receptionist checks IDs at the front door, but the staff upstairs also need a locked staircase so people cannot sneak up the back stairs and claim the receptionist already approved them.
12Quotas and Rate Limiting
Quotas keep one caller from using more than a fair share and protect your backend from overload.
Metrics and limits
Quota in Endpoints works in two steps. First you define a metric, which is a countable thing such as “read requests”. Then you define limits on that metric, such as a number of requests per minute for each consumer project. Methods in your API are tied to metrics, and each call counts a set amount against the metric, which lets you charge more for heavy operations than for light ones.
Who the limit applies to
Limits are applied per consumer, which usually means per project identified by its API key. Limits can be set per minute and per day. If a consumer goes over its limit, further calls are refused with a standard error until the period resets. Different callers can be given different limits through separate quota settings in their own projects, which supports tiered plans such as free and paid.
| Quota concept | Meaning | Example |
|---|---|---|
| Metric | A countable measure of usage | Read requests |
| Cost per call | How much each method uses of a metric | A search counts as five reads |
| Limit | Maximum allowed over a period | Six hundred per minute |
| Unit of enforcement | The caller being counted | Each consumer project |
Tiered plans
A company offers a free plan with low limits and a paid plan with high limits. Customers on the paid plan have higher quota applied in their consumer project, while everyone shares the same API.
Protecting an expensive endpoint
A search method that touches a large database counts as ten units, while a simple lookup counts as one. A caller cannot overwhelm the database by hammering the expensive method, even while the cheap one remains generous.
Quota counts are shared across proxy instances through the control service, so a caller cannot dodge the limit by spreading calls over many proxy copies. Small delays between a call and the quota update mean the limit is approximate near its edge.
Quota is like a meal-ticket system at a canteen. Each employee gets a fixed number of tickets per day. A soup costs one ticket and a full meal costs three, so nobody can empty the kitchen by ordering without limit.
13Consumers, API Keys and Access Management
Callers must be known to Google Cloud before they can use a protected API.
How a consumer gets access
For an API that requires keys, a calling application creates a key in its own Google Cloud project and enables your managed service in that project. The key then identifies the project when calls arrive. The owner of the API can see usage by consumer project, apply different limits to different projects and block a project that misbehaves.
Restricting what a key can do
Keys can be restricted so that they work only for specific APIs and only from certain sources, such as particular websites, mobile applications or network addresses. Restrictions reduce the damage if a key leaks, because a stolen key that is locked to certain places or services is far less useful.
Controlling who may use the API
Identity and Access Management controls who can manage the Endpoints service itself, such as deploying new configurations or viewing usage. Separate permissions exist for people who administer the service, people who may only view reports, and consumers who may enable the API in their projects. Keep administrative rights narrow, since they control what every caller experiences.
Restrict every key
Limit each key to the API and the sources it needs, never leaving keys unrestricted.
One key per application
Separate keys let you track, limit and revoke each application on its own.
Rotate regularly
Change keys on a schedule so that long-forgotten copies stop working.
Keep keys out of source code
Store them in a secrets service, not in repositories or public pages.
Sharing a single unrestricted key across every client application. One leak then forces you to break every client at once to replace it, and you cannot tell which client caused the abuse.
Giving one master visitor pass to every guest means you cannot tell who entered, and losing it means changing every lock. Giving each guest a separate, time-limited pass lets you cancel just one.
14Monitoring, Logging and Tracing
Because every call passes through the proxy, Endpoints gives you a rich picture of traffic with almost no extra work.
Metrics and dashboards
Endpoints reports metrics such as request counts, error rates, response times and the sizes of requests and responses, broken down by method, by response code and by consumer. These appear in dashboards and can drive alerts, so you can see which methods are slow, which consumers produce the most traffic and how the error rate changes after a release.
Logs
The proxy writes a record of each request, including the method, path, response code, latency and the consumer identity. These logs go to Cloud Logging, where they can be searched, filtered and exported. Because they include consumer identity, they help to answer questions such as who was calling an endpoint when errors rose.
Tracing
The proxy can add trace information to requests, which lets Cloud Trace show how long each part of a call took, including the time spent in the proxy and in the backend. Passing trace headers on to downstream services gives an end-to-end timeline of one request across several services.
Error Rate
The share of calls returning errors, split by client mistakes and server problems.
Latency
How long calls take, especially the slowest few percent that users notice most.
Traffic by Consumer
Which callers use the API most, useful for planning capacity and spotting abuse.
Quota Rejections
How often callers hit their limits, showing whether limits are too tight or traffic is unhealthy.
Authentication Failures
Spikes of rejected credentials may point to a broken client release or an attack.
Create alerts on error rate and the slowest response times for key methods, not only on raw traffic. Those are the signals that match real user pain.
The reception logbook records every visitor, how long they waited and which floor they visited. The manager reads it each morning to spot slow elevators, crowded hours and visitors who keep being turned away.
15Documentation and Developer Experience
An API is only useful if others can understand and use it easily.
The specification as documentation
Because your API is described in a standard format, many tools can turn it into readable documentation, interactive try-it-out pages and ready-made client libraries in several languages. This means developers can explore your API without reading code, and your documentation stays in step with the real behavior when it is generated from the same specification.
Developer portal options
Endpoints has offered a developer portal feature for publishing API documentation and letting developers try calls and manage keys. Features around portals have changed over time, and organizations that need a rich, branded portal with onboarding, analytics and monetization often choose Apigee instead. Check the current documentation for what Endpoints provides today.
Versioning
APIs change over time, and callers depend on stable behavior. A common approach is to put a version in the path, so a new version can live beside the old one for a transition period. Endpoints can host several versions in the same specification or as separate services. Announce changes early, keep old versions running for a stated time and use usage data to know when it is safe to retire them.
Safe retirement of an old version
Logs show that only two partner projects still call version one. The team contacts them, waits for migration, confirms traffic has dropped to zero and then removes the old version without surprising anyone.
Making breaking changes to an existing version, such as renaming a field. Callers break at once, and you have no warning. Add new versions and keep the old ones until usage proves they are safe to remove.
Documentation is the building’s welcome booklet, and versioning is like keeping the old entrance open while a new one is built. Visitors may need months to learn the new route, and you can see from the logbook when nobody uses the old door any more.
16Performance, Reliability and Scaling
Because the proxy sits on the path of every call, its health and speed matter for your whole API.
The proxy adds a small delay
Every call passes through one more hop, which adds a small delay, usually a few milliseconds. Local token checks and cached configuration keep this low. The control service call for key and quota checks is done efficiently and does not stand in the way of most requests, but it is still worth measuring in your own setup.
Scaling the proxy
The proxy must scale with the backend. On Cloud Run it scales automatically. On Kubernetes, a sidecar scales with each backend copy, or a separate deployment can be scaled with its own settings. On virtual machines, a group of proxy machines behind a load balancer can scale out on demand. In all cases, the proxy should have at least as much capacity as the backend behind it, or it becomes the bottleneck.
What happens when the control service is unreachable
Proxies cache configuration and keys, so they can continue to serve most calls during brief connectivity problems with the control services. Behavior around key checks and quota during longer outages depends on settings and versions, so test failure scenarios and understand them before an incident rather than during one.
Performance Strengths
- Local token verification keeps delay low
- Cached configuration avoids constant lookups
- Bad calls are rejected before reaching the backend
- Scales with the platform it runs on
Performance Trade-offs
- One extra hop adds a small delay to each call
- An undersized proxy becomes the bottleneck
- Dependence on control services for keys and quota
A reception desk adds a few seconds to every visit, but it keeps troublemakers from clogging the offices. If the building doubles in size and the desk stays the same, queues form in the lobby, so staff the desk to match the building.
17Design Patterns for API Architecture
Experienced teams reuse a few well-tested layouts.
Sidecar Proxy Pattern
On Kubernetes, the proxy runs in the same pod as each backend, so the proxy scales exactly with the backend and traffic between them never leaves the pod.
Serverless Front Door Pattern
ESPv2 runs as its own Cloud Run service in front of private Cloud Run backends. Everything scales automatically, and only the proxy is publicly reachable.
Single Entry for Many Backends Pattern
One proxy fronts several backend services, routing different paths to different backends. Clients see one consistent API while teams own their services independently.
Tiered Access Pattern
Different consumers receive different quota levels through their own projects, giving free, standard and premium plans on the same API.
Protocol Translation Pattern
A gRPC backend is exposed as a web API through translation, so efficient internal communication and friendly external access coexist.
flowchart TD
C["Clients"] --> PX["ESPv2 on Cloud Run: public"]
PX --> A["Orders Service: private"]
PX --> B["Customers Service: private"]
PX --> D["Inventory Service: private"]
PX -.-> M["Metrics, Logs and Traces"]
Anti-patterns to avoid
Problem
Leaving backends open to the internet next to the proxy.
Why It’s Harmful
Attackers can skip authentication, quotas and logging entirely by calling the backend directly.
Correct Approach
Make backends private and allow only the proxy’s identity to call them.
Problem
Putting business logic into the proxy layer or the specification.
Why It’s Harmful
The proxy is meant for cross-cutting concerns. Business rules hidden there are hard to test and easy to forget.
Correct Approach
Keep the proxy for identity, quota, routing and observability, and keep business rules in the backend.
Problem
Letting the specification drift away from the real backend behavior.
Why It’s Harmful
Documentation lies, generated clients break and the proxy may reject valid calls or accept invalid ones.
Correct Approach
Treat the specification as the contract, test the backend against it and update both together.
18Understanding and Controlling Cost
Endpoints cost has two parts, the service itself and the infrastructure you run for the proxy.
What you pay for
At the time of writing, Endpoints charges based on the number of API calls handled, with a free monthly allowance and a lower price per call as volume grows. In addition, you pay for the compute that runs the proxy, such as Cloud Run instances, Kubernetes resources or virtual machines, and for any logging, monitoring and trace data stored. Exact prices and allowances change, so always check the official pricing page before budgeting.
Ways to spend wisely
Right-size the proxy
Give the proxy enough capacity for peak traffic without running far more instances than needed.
Block bad traffic early
Reject unauthenticated or over-quota calls at the proxy so the backend does no wasted work.
Tune logging
Keep detailed logs where they help, and exclude noisy, low-value entries such as health checks.
Cache where safe
Use caching in front of or behind the proxy for responses that rarely change, reducing the number of calls.
Compare options
For small or simple needs, a fully managed gateway may cost less in effort than running your own proxy.
Counting only the per-call charge and forgetting that someone must operate and upgrade the proxy. The time of your engineers is part of the real cost.
19Best Practices and Common Mistakes
A short checklist of habits that separate calm API teams from stressed ones.
Best practices
Design the API first
Write the specification before the code, and review it as the contract between providers and callers.
Layer your security
Use tokens for identity, keys for tracking and quotas, private backends and encrypted connections.
Set sensible quotas
Protect expensive methods with higher costs per call and give each plan clear limits.
Pin configuration in production
Use a fixed configuration version in production and promote new versions deliberately after testing.
Version your API
Add new versions instead of changing old ones, and retire old versions only after usage data confirms it is safe.
Monitor what users feel
Alert on error rates and slow responses for key methods, and track traffic per consumer.
Automate deployment
Keep specifications and proxy deployments in version control and ship them through a tested pipeline.
Common mistakes
Never testing what happens when the proxy restarts, the control service is slow or configuration is invalid. Practice these failures in a safe environment first.
The proxy is software you run, so it needs version upgrades and security patches. Track new releases and schedule updates as part of normal maintenance.
If the accepted audience in your authentication settings does not match what callers send, valid users are rejected. Verify these values end to end during testing.
Leaving default timeouts for slow backends can cut off long operations or hold connections too long. Set backend timeouts deliberately for each method that needs it.
20Real-world and Industry Scenarios
Stories show how the pieces combine in real organizations.
A Fintech Opening an API to Partners
A payments company lets partners initiate transfers through an API. Each partner has its own project and key, tokens prove the partner’s identity, and quotas stop any partner from overloading the system. Logs show exactly which partner made which call, which simplifies audits and disputes.
A Retailer Powering Its Mobile App
A retailer’s mobile app signs users in through Firebase and calls an API protected by Endpoints. The proxy verifies each user’s token, and the backend uses the forwarded identity to return only that customer’s orders. Dashboards show slowdowns right after each app release.
A Logistics Company Modernizing Internal Services
A logistics firm runs many gRPC services on Kubernetes. Endpoints translates ordinary web requests from its web portal into gRPC calls, so the portal team uses simple web calls and the service teams keep their fast internal protocol.
A Software Vendor Offering Free and Paid Plans
A software vendor sells API access with a free tier and paid tiers. Different quota levels are applied to customers’ projects, and usage reports per consumer feed the billing process.
A Startup Choosing Simplicity
A small startup begins with ESPv2 on Cloud Run in front of a single backend. Later, as its needs grow into developer portals and monetization, it evaluates moving to a fuller platform, keeping the same API specification as a starting point.
21Advantages, Disadvantages and Trade-offs
No service is perfect, and a mature team knows both sides before committing.
Advantages
- Consistent authentication, quotas and logging across all APIs
- Rejects bad traffic before it reaches the backend
- Supports both web APIs and gRPC, including translation
- Runs beside your backend on many platforms, including other clouds
- Built-in metrics, logs and traces with little effort
- Specification doubles as documentation and a contract
Disadvantages / Trade-offs
- You must deploy, scale, update and secure the proxy yourself
- Adds a small delay to every call
- Developer portal and monetization features are limited
- Google’s product guidance may steer new projects toward other options
- Specific to Google Cloud’s management services
Choosing your approach
| Need | Best fit | Why |
|---|---|---|
| Simple managed gateway, minimal operations | API Gateway | Google runs the gateway |
| Light proxy next to your backend, full control of placement | Cloud Endpoints | You decide where and how it runs |
| Large partner program, portals and monetization | Apigee | Full API management platform |
| Internal service-to-service traffic only | Service mesh or platform authentication | No need for a public API layer |
| High-performance internal protocol with web clients | Endpoints with translation | Bridges gRPC and ordinary web calls |
Choosing the API layer is like choosing how to staff a building entrance. A landlord-run desk is easiest. Your own desk gives you control. A full visitor department makes sense for a huge campus with thousands of guests.
22Frequently Asked Questions
Quick answers to the questions beginners ask most often.
No. Your API runs on your own backend, such as Cloud Run, Kubernetes or virtual machines. Endpoints provides the proxy and management layer in front of it.
ESP is the original proxy based on a web server. ESPv2 is the newer generation built on Envoy, and it is generally the preferred choice for new deployments, including standalone use on Cloud Run.
Both use similar proxy technology. With Endpoints you deploy and run the proxy yourself. With API Gateway, Google runs the gateway for you, so there is less to operate but also less control.
Web APIs described with OpenAPI and gRPC services described with their service definitions. It can also translate web requests into gRPC calls for the backend.
No. Keys identify a project and support quotas, but they are easy to copy. Combine them with token-based authentication, and keep backends private.
You define metrics and limits in your specification and tie methods to metrics with a cost per call. The proxy reports each call and refuses calls from consumers who have exceeded their limits.
Yes. Endpoints can validate tokens from any provider that follows the common token standard, as long as you configure the issuer, the accepted audience and the location of the verification keys.
Make the backend private. Require authenticated callers or restrict network access so only the proxy’s identity can reach it, and do not trust forwarded identity details on a directly reachable backend.
A new configuration version is created. Proxies adopt it according to their rollout setting, either automatically or only when pinned to the new version, and you can return to an earlier version if needed.
In Cloud Monitoring dashboards for metrics, Cloud Logging for request records and Cloud Trace for timing. All three use data reported by the proxy for every call.
It adds a small delay, since each call passes one more hop. Local token checks and cached configuration keep it low, but you should measure it in your own environment and size the proxy properly.
It depends on your needs. Check the current official guidance, since newer projects are sometimes recommended to use API Gateway or Apigee. Endpoints remains a good fit when you want a lightweight proxy that you control, placed next to your backend.
23Summary and Key Takeaways
Cloud Endpoints is the reception desk of your API. You describe the API in a specification, deploy it to create a versioned managed service and run a proxy, ESP or the newer ESPv2, beside your backend on Cloud Run, Kubernetes, virtual machines or other platforms. For every call, the proxy matches the path, checks the caller’s key or token, applies quotas, forwards the request and reports metrics, logs and traces. Together with a private backend and layered authentication, this gives you a secure, observable and fair API without filling your business code with cross-cutting concerns. It is one of several options, alongside the fully managed API Gateway and the full-featured Apigee, so the right choice depends on how much control, convenience and platform capability you need. Teams that treat the specification as a contract, secure the backend properly, set sensible quotas and watch the right signals run APIs that stay trustworthy as they grow.
Key Takeaways
- A proxy in front of your service — Endpoints moves authentication, quotas, logging and tracing out of your code and into a consistent gatekeeper.
- The specification is the contract — an OpenAPI or gRPC description drives the rules, the documentation and the generated clients, so keep it accurate and in version control.
- Prefer ESPv2 for new work — it is Envoy based, supports web and gRPC APIs, and can run as a standalone service on Cloud Run for a fully serverless setup.
- Layer your security — use keys for tracking and quotas, tokens for real identity, private backends and encryption, and never leave the backend directly reachable.
- Use quotas with costs per method — protect expensive operations and offer tiered plans through per-consumer limits.
- Pin configurations and version the API — roll out changes deliberately, keep old versions until usage shows they are safe to retire and avoid breaking callers.
- Choose the right tool — compare Endpoints with API Gateway and Apigee, check current official guidance, and monitor error rate, latency and traffic per consumer.