API Design interview question · Most asked

What makes an API RESTful, and what are good REST design practices?

Summary

REST models the API as resources identified by URLs, manipulated with standard HTTP methods, using stateless requests and standard status codes and representations. Good practice: noun-based plural resources, correct methods and status codes, consistent JSON, pagination, filtering, versioning and clear errors.

Longer Answer

Examples: GET /orders?status=paid, POST /orders (201 + Location), GET /orders/42, PATCH /orders/42, DELETE /orders/42 (204), sub-resources GET /orders/42/items. Use actions sparingly when they don't fit CRUD (POST /orders/42/cancel). Keep naming consistent (snake_case or camelCase), use ISO 8601 dates and UTC, and document with OpenAPI.

Key Points

  • Resources + HTTP methods
  • Correct status codes
  • Consistent naming and formats
  • Pagination, filtering, versioning
  • OpenAPI documentation

More most-asked API Design questions

← All API Design questions