Representational State Transfer
REST is an architectural style for building distributed systems based on hypermedia. REST is independent of any underlying protocol and is not necessarily tied to HTTP. However, most common REST API implementations use HTTP as the application protocol, and this guide focuses on designing REST APIs for HTTP.
REST APIs are designed around a (resources) .
What is an identifer of a resource? Give an example.
The URI for a particular customer order :
https://adventure-works.com/orders/1
GET
,POST
,PUT
,PATCH
ANDDELETE
URIs should be based on
nouns
(the resource) andnot verbs
(the operations on the resource).
https://adventure-works.com/orders // Good
Another factor is that all web requests impose a load on the web server. The more requests, the bigger the load. Therefore, try to avoid "chatty" web APIs that expose a large number of small resources. Such an API may require a client application to send multiple requests to find all of the data that it requires.
This is a bad thing
A successful GET method typically returns HTTP status code
200
(OK).
If the resource cannot be found, the method should return
404
(Not Found).
If a POST method creates a new resource, it returns HTTP status code
201
(Created).
If the delete operation is successful, the web server should respond with HTTP status code
204
, indicating that the process has been successfully handled, but that the response body contains no further information.