Posts

Showing posts from April, 2014

REST API Best Practices 2: HTTP and CRUD

This post expands a bit further on the REST API Cheat Sheet regarding HTTP operations for Create / Read / Update / Delete functionality in REST APIs.

APIs for data access and management are typically concerned with four actions (the so-called CRUD operations):
Create - the ability to create a resourceRead - the ability to retrieve a resourceUpdate - the ability to modify a resourceDelete - the ability to remove a resource
CRUD operations don't have a perfect, 1-to-1 mapping to HTTP methods, which has led to different opinions and implementations, but the following list represents best practice as I see it in the industry today, and follows the HTTP specification:

CRUD Operation    HTTP MethodCreatePOSTReadGETUpdatePUT and/or PATCHDeleteDELETE
To reiterate, HTTP methods can be used to implement CRUD oprations as follows:
POST - create a resourceGET - retrieve a resourcePUT - update a resource (by replacing it with a new version)*PATCH - update part of a resource (if available and ap…