What is an API Endpoint? Definition, Examples, Best Practices
An API endpoint is a specific URL + HTTP method that performs one operation — like GET /api/users or POST /api/orders. The address where requests go.
What is an API endpoint?
An API endpoint is a specific URL combined with an HTTP method that performs one well-defined operation in an API. The endpoint POST /api/users creates a new user; GET /api/users/42 reads user 42; DELETE /api/users/42 removes user 42. Each endpoint is the address where a request is sent and the contract for what happens when that request arrives.
An API typically has dozens to hundreds of endpoints — one per operation. The collection of endpoints defines the API's surface area. RESTful APIs organize endpoints by resource (users, orders, products); GraphQL APIs collapse them into a single endpoint with query-shaped requests; gRPC defines them as RPC method names rather than HTTP paths.
Anatomy of an API endpoint
A REST endpoint has three components:
- Base URL. The protocol + host (+ port + optional path prefix). Example:
https://api.example.com. - Path. The route to a specific resource. Example:
/users/42. - HTTP method. Verb that determines the operation. GET, POST, PUT, PATCH, DELETE.
Combined: POST https://api.example.com/users is the "create user" endpoint.
POST https://api.example.com/users
Content-Type: application/json
Authorization: Bearer ...
{
"name": "Alice",
"email": "alice@example.com"
}The full URL plus the HTTP method together identify the endpoint. GET /users and POST /users are two different endpoints sharing the same path.
REST endpoint design conventions
RESTful API design has well-established conventions:
- Use nouns, not verbs, in paths.
/usersnot/getUsers. The HTTP method is the verb. - Plural collection names.
/usersfor the collection,/users/42for an item. Some teams prefer singular; consistency matters more than the choice. - Hierarchical paths reflect relationships.
/users/42/orders= orders belonging to user 42./users/42/orders/100= order 100 of user 42. - Use HTTP status codes. 200 for success, 201 for created, 204 for no-content responses, 400 for client errors, 401/403 for auth, 404 for not-found, 500 for server errors.
- Pagination via query strings.
/users?page=2&limit=20or cursor-based/users?cursor=abc123. - Filtering via query strings.
/users?role=admin&status=active. - Versioning. Include API version in URL (
/v1/users) or Accept header. URL versioning is more common.
Common endpoint patterns
| Operation | HTTP Method | Endpoint Pattern | Example |
|---|---|---|---|
| List collection | GET | /resources | GET /users |
| Read item | GET | /resources/:id | GET /users/42 |
| Create item | POST | /resources | POST /users |
| Update item (full) | PUT | /resources/:id | PUT /users/42 |
| Update item (partial) | PATCH | /resources/:id | PATCH /users/42 |
| Delete item | DELETE | /resources/:id | DELETE /users/42 |
| Nested collection | GET | /resources/:id/sub | GET /users/42/orders |
| Action on item | POST | /resources/:id/action | POST /users/42/activate |
| Search | GET | /resources?q=... | GET /users?q=alice |
Endpoint vs URL vs API
- API. The complete interface — collection of all endpoints, their schemas, authentication, error formats. Example: "the Stripe API".
- Endpoint. One specific operation in the API. Example: "the create-charge endpoint" (
POST /v1/charges). - URL. The address part of an endpoint. The endpoint is URL + method.
Endpoint design best practices
Be consistent
Pick a convention (kebab-case vs snake_case, plural vs singular, versioning style) and apply it across all endpoints. /users/42 + /order_items/100 + /PaymentMethods is confusing; pick one style.
Use HTTP semantics correctly
POST creates. PUT replaces. PATCH partially updates. DELETE removes. GET reads (no side effects). Don't use POST for everything (RPC-over-HTTP); don't use GET for state changes.
Return appropriate status codes
Don't return 200 for everything with an "error" field in the body — that's not RESTful and breaks tooling. Use proper HTTP status codes: 4xx for client errors, 5xx for server errors.
Document with OpenAPI/Swagger
OpenAPI (formerly Swagger) generates interactive docs and client SDKs from machine-readable endpoint specs. Treat the spec as part of your code, not optional documentation.
Version explicitly
Putting v1 in the path (/v1/users) lets you ship breaking changes in v2 without breaking existing clients. Header-based versioning works too but is less discoverable.
Idempotency for non-idempotent operations
POST endpoints that create resources should accept an Idempotency-Key header for safe retries. See our idempotency glossary entry for details.
Endpoint security
- HTTPS only. Never accept API requests over HTTP.
- Authentication on every endpoint. Bearer tokens, API keys, OAuth, or signed requests. Public endpoints (status, health) can be unauthenticated but should be explicit.
- Rate limiting. Per-endpoint or per-user rate limits prevent abuse. Return 429 Too Many Requests with a Retry-After header.
- Input validation. Schema-validate every request body, query string, and path parameter. Reject malformed input with 400.
- Authorization per endpoint. Authentication says who; authorization says what they're allowed to do. Check permissions on each endpoint, not just at the gateway.
Endpoint testing
Each endpoint should be tested at multiple levels:
- Unit tests. Each endpoint's handler logic in isolation.
- Integration tests. Endpoint hit through the full HTTP stack with real DB connections.
- Contract tests. Endpoint behavior matches the OpenAPI spec; clients can rely on it.
- Load tests. Endpoint behavior under concurrent load — latency percentiles, error rates, capacity ceilings.
- Synthetic monitoring. Production endpoints checked on a schedule to catch regressions before users do.
Common endpoint mistakes
- Stuffing actions in path.
POST /createUser(RPC-style) instead ofPOST /users(RESTful). - Verbose query strings.
?action=deleteinstead of using DELETE method. - Returning 200 for errors. Bodies like
{success: false, error: ...}with HTTP 200. Use 4xx/5xx instead. - Missing trailing slash inconsistency.
/usersworks but/users/404s (or vice versa). Pick one and redirect the other consistently. - Sensitive data in URL. Tokens, passwords, PII in path/query strings end up in server logs, browser history, and referrer headers. Put sensitive data in headers or body instead.
- Inconsistent error formats. Some endpoints return
{error: "..."}, others{message: "..."}, others{errors: [...]}. Standardize on one format.
Endpoint discovery
How API consumers find your endpoints:
- OpenAPI/Swagger spec. Machine-readable, generates interactive docs (Swagger UI, Redoc) and SDKs.
- API documentation site. Human-readable docs explaining each endpoint with examples.
- HATEOAS / hypermedia. Responses include links to related endpoints. Less common in practice; conceptually pure REST.
- API marketplace. Public APIs may be listed in directories like RapidAPI or Postman API Network.
FAQ: API endpoints
What's the difference between an API and an API endpoint?
An API is the complete interface — all endpoints together. An endpoint is one specific operation within the API. Stripe's API has hundreds of endpoints (one per operation: create charge, list customers, retrieve subscription, etc.).
Are GET /users and POST /users the same endpoint?
No. They share the same URL but different HTTP methods, so they're different endpoints. Each does a different operation (read vs. create).
Should I use plural or singular endpoint names?
Plural is more common (/users, /orders). Singular works too. The important thing is consistency across all endpoints in your API.
How many endpoints should an API have?
As many as needed for the API's scope. Small focused APIs have 5-20 endpoints. Large platform APIs (Stripe, AWS) have hundreds. Endpoint count itself isn't a quality metric.
What's the difference between REST and GraphQL endpoints?
REST APIs have many endpoints (one per operation). GraphQL APIs have one endpoint (typically /graphql) where the client sends a query describing exactly what data to return.
How do I version API endpoints without breaking clients?
Include version in URL (/v1/users, /v2/users). Run both versions in parallel during transition. Deprecate the old version with clear sunset dates. Document breaking changes in v2.
Test API endpoints with LoadFocus
If you're testing API endpoints under load — concurrent requests, latency under traffic, error rates at scale — LoadFocus runs JMeter and k6 scripts from 25+ cloud regions with up to 12,500 VUs. Sign up for a free tier at loadfocus.com/signup — no credit card — and run your first endpoint load test in under 5 minutes.
Related LoadFocus Tools
Put this concept into practice with LoadFocus — the same platform that powers everything you just read about.