REST (Representational State Transfer) is an architectural style for building web services. A RESTful API (Application Programming Interface) is a web service that adheres to the REST constraints and allows developers to interact with the application via HTTP(S) requests.
|
GET
|
Retrieve a resource or a collection of resources
|
|
|
POST
|
Create a new resource
|
|
|
PUT
|
Update an existing resource
|
|
|
PATCH
|
Update a part of an existing resource
|
|
|
DELETE
|
Delete an existing resource
|
|
|
Accept - specifies the format of the response (e.g. application/json)
|
|
Authorization - provides authentication information
|
|
Content-Type - specifies the format of the request body (e.g. application/json)
|
|
If-Match - ensures that the resource hasn't been updated since the client last retrieved it
|
|
If-None-Match - ensures that the resource hasn't been modified since the client last retrieved it
|
|
200
|
OK - Successful request
|
|
201
|
Created - Resource successfully created
|
|
204
|
No Content - Successful request but no content to return
|
|
400
|
Bad Request - Invalid request data
|
|
401
|
Unauthorized - Authentication required
|
|
403
|
Forbidden - Authorization required
|
|
404
|
Not Found - Resource not found
|
|
500
|
Internal Server Error - Server error
|
|
ETag - provides a version number for the resource
|
|
Location - provides the URI for the newly created resource
|
|
Content-Type - specifies the format of the response body (e.g. application/json)
|
|
/resources
|
Retrieve all resources
|
|
/resources/{id}
|
Retrieve a single resource by ID
|
|
/resources?filter=value
|
Retrieve resources with a specific value
|
|
/resources
|
Create a new resource
|
|
/resources/{id}
|
Update an existing resource by ID
|
|
/resources/{id}
|
Delete an existing resource by ID
|
|
Use HTTP methods correctly
|
|
Use plural nouns for resource names
|
|
Use nouns for endpoint names
|
|
Use query parameters for filtering and sorting
|
|
Use error codes consistently
|
|
Use versioning to manage changes
|
|
Use pagination for large data sets
|
|
Provide API documentation and examples
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.