Sunday, August 12, 2018

RESTful Web Service API

REST (Representational state transfer) is an architectural style that was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation. Roy Fielding is one of the principal authors of the HTTP specification. RESTful APIs are defined with these aspects:
  • standard HTTP methods (e.g., GET, PUT, POST, or DELETE) 
  • hypertext links to reference state  
  • hypertext links to reference related resources
  • data -- often JSON or XML but can be any other valid Internet media type
The following table shows how the HTTP methods are typically used to implement a RESTful API.
 
RESTful API HTTP methods
Resource
GET
PUT
POST
DELETE
Collection URI, such as http://example.com/resources
List the URIs and perhaps other details of the collection's members.
Replace the entire collection with another collection.
Create a new entry in the collection. The new entry's URI is assigned automatically and is usually returned by the operation.
Delete the entire collection.
Retrieve a representation of the addressed member of the collection, expressed in an appropriate Internet media type.
Replace the addressed member of the collection, or if it doesn't exist, create it.
Not generally used. Treat the addressed member as a collection in its own right and create a new entry in it.
Delete the addressed member of the collection.
 
The PUT and DELETE methods are idempotent methods. The GET method is a safe method (or nullipotent), meaning that calling it produces no side-effects.
 
The Atom Publishing Protocol for publishing to blogs is considered a canonical RESTful protocol.
 

No comments:

Post a Comment