Vocabulary

  • HTTP request
  • HTTP methods
  • operations
  • verbs

 

  • Status code: 200 is success
  • Status code: 400 is client error

 

  • Headers: Content-Type    application/json
'Content-type': 'application/json; charset=UTF-8'

 

Introduction to REST

 

  Example  
GET /post  
GET /posts/1  
GET /posts/1/comments  
GET /comments?postId=1  
POST /posts  
PUT /posts/1  
PATCH /posts/1  
DELETE /posts/1  

 

Create => POST.
Read => GET.
Update => PATCH/PUT.
Delete => DELETE.

 

 

  • GET: The get method is used to Read data on the server.
  • POST: The post method is used to Create data.
  • PATCH/PUT: The patch method is used to Update data.
  • DELETE: The delete method is used to Delete data.

 

 

 

What is REST?

REST stands for Representational State Transfer.

 

We are able to communicate with servers using the HTTP protocol. With these protocols, we can Create, Read, Update and Delete data – otherwise known as CRUD operations.

We can do this by sending HTTP requests. REST simplifies the communication process by providing various HTTP methods/operations/verbs which we can use to send requests to the server.

 

 

 

Six guiding constraints of REST

The constraints of the REST architectural style affect the following architectural properties:[1][5]

  • performance in component interactions, which can be the dominant factor in user-perceived performance and network efficiency;[6]
  • scalability allowing the support of large numbers of components and interactions among components;
  • simplicity of a uniform interface;
  • modifiability of components to meet changing needs (even while the application is running);
  • visibility of communication between components by service agents;
  • portability of components by moving program code with the data;
  • reliability in the resistance to failure at the system level in the presence of failures within components, connectors, or data.

 

Useful resources

JSON placeholder - fake endpoint