Resource naming, HTTP semantics, versioning, and errors—design APIs that are consistent and easy to use.
Good API design reduces support cost and speeds integration. Here are practical guidelines.
API design and REST
REST guidelines
Resources — Nouns in the path: /users, /orders, /orders/123. Use plural. Avoid verbs in URLs; use HTTP methods.
HTTP methods — GET (read), POST (create), PUT/PATCH (update), DELETE (remove). Use correct status codes: 200, 201, 204, 400, 401, 403, 404, 500.
Versioning — Path (/v1/users) or header. Choose one and stick to it. Deprecate old versions with notice.
Errors — Consistent body: e.g. { "error": { "code": "...", "message": "..." } }. Include validation details for 400. Don’t leak stack traces in production.
Pagination — Cursor or offset. Return next link or page info. Consistent shape across list endpoints.
API quality (client survey):
What clients value in APIs
Documentation
OpenAPI (Swagger) for REST. Describe request/response, errors, and auth. Provide try-it-out or Postman collection. Keep docs in sync with the implementation (generate from code or vice versa).
REST API design:
Takeaway
Design for the consumer: predictable URLs, clear errors, and good docs. Version from day one and paginate lists. Consistency matters more than perfection.