REST API Conventions
A set of architectural constraints and naming conventions for designing consistent, predictable HTTP APIs around resources.
Description
REST API conventions establish a shared vocabulary between API producers and consumers by mapping CRUD operations to HTTP methods (GET, POST, PUT, PATCH, DELETE) and organizing endpoints around noun-based resources. Following these conventions means clients can predict behavior: GET is safe and idempotent, PUT replaces a resource entirely, PATCH applies a partial update, and DELETE removes it. Status codes, header usage, and content types all follow well-understood patterns.
Beyond method mapping, REST conventions encompass consistent use of plural nouns for collection endpoints, nested resources for expressing ownership (e.g., /users/{id}/orders), and query parameters for filtering and pagination. A well-designed REST API feels intuitive to consumers because it leverages HTTP semantics rather than inventing custom RPC-style operations. Deviations from these conventions -- such as using POST for reads or encoding actions in URL paths -- create friction and increase onboarding time for new developers.
Enforcing conventions across a team typically involves an API style guide, linting rules in CI (e.g., Spectral for OpenAPI specs), and code review checklists. Consistency is the primary goal: an API that follows its own conventions reliably is far more usable than one that follows "perfect" REST theory inconsistently.
Prompt Snippet
Design all endpoints using plural resource nouns (e.g., /api/v1/invoices, not /api/v1/invoice). Map standard CRUD to HTTP methods: GET for retrieval, POST for creation, PUT for full replacement, PATCH with JSON Merge Patch (RFC 7396) for partial updates, DELETE for removal. Return 201 Created with a Location header on successful POST, and 204 No Content on successful DELETE. Enforce these conventions via Spectral linting rules in CI against the OpenAPI spec.
Tags
Related Terms
RESTful Resource Naming
The practice of naming API endpoints using plural nouns and hierarchical paths to represent resources and their relationships.
HTTP Status Code Selection
Choosing semantically correct HTTP status codes so clients can programmatically handle success, client errors, and server errors.
OpenAPI / Swagger Specification
A machine-readable YAML/JSON specification format for describing REST API endpoints, request/response schemas, authentication, and examples.
HATEOAS
A REST constraint where API responses include hypermedia links that guide clients through available state transitions without hardcoded URLs.