REST: Representational State Transfer is a web design philosophy rather than a specific technology or language. REST APIs are based upon resources, identifiers, and representations.
Resources: Anything accessed by clients (data, services, objects, etc)
Identifiers: URIs (uniform resource identifiers) do distinctly key each resource (like URLs for HTTP). URI best practices include relative simplicity (not too many routes in the address) and consistency in naming conventions.
Representations: responses to requests made of a given resource (like other data or format changes)
APIs should optimize toward meaningful interactions to limit request count and avoid being “chatty”– that is, making many small requests.
REST APIs should use standardized operations– in the case of HTTP, these operations are GET
, POST
, PUT
, PATCH
, and DELETE
.
Status codes can thus be standardized, like:
Successful GET
: 200
Unsuccessful GET
: 404
Successful POST
: 201
Successful DELETE
: 204