REST API Design Best Practices That Scale
Principles and patterns for designing APIs that are intuitive, maintainable, and performant.
A well-designed API is a joy to work with. Here are the principles I follow when designing APIs that developers love and that scale.
Resource-Oriented Design
Think in resources, not actions. URLs should represent nouns, not verbs.
Good: GET /users/123 Bad: GET /getUser?id=123
Use HTTP methods to express actions: - GET: Retrieve resources - POST: Create resources - PUT/PATCH: Update resources - DELETE: Remove resources
Consistent Naming
Use consistent naming conventions: - Plural nouns for collections: /users, /orders - Kebab-case for multi-word resources: /order-items - Consistent response structure across endpoints
Versioning
Version your API from day one. Options include:
- URL path: /v1/users
- Header: Accept: application/vnd.api+json;version=1
I prefer URL versioning for visibility and simplicity.
Pagination
Always paginate list endpoints. Include metadata about total count and next/previous pages.
Support both offset and cursor pagination. Cursor pagination performs better for large datasets.
Error Handling
Return consistent error responses with: - HTTP status code (400, 404, 500) - Error code for programmatic handling - Human-readable message - Details for validation errors
Rate Limiting
Protect your API with rate limits. Return rate limit info in headers so clients can handle limits gracefully.
Documentation
Document every endpoint with: - Description - Request parameters - Response schema - Example requests/responses - Error cases
OpenAPI/Swagger makes documentation interactive and enables code generation.
Good API design requires upfront investment but pays off in reduced support burden and better developer experience.
David Sampson
Senior Full Stack Engineer