Search This Blog

Wednesday 11 November 2020

REST API

 

API is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the API on the server and allows the client to talk to it.


REST determines how the API looks like. It stands for “Representational State Transfer”. It is a set of rules that developers follow when they create their API. 



JSON (JavaScript Object Notation) a common format for sending and requesting data through a REST API. The response that Github sends back to you is also formatted as JSON.



The method is the type of request you send to the server. You can choose from these five types below:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

They are used to perform four possible actions: CreateReadUpdate and Delete (CRUD).



Method NameRequest Meaning
`GET`This request is used to get a resource from a server. If you perform a `GET` request, the server looks for the data you requested and sends it back to you. In other words, a `GET` request performs a `READ` operation. This is the default request method.
`POST`This request is used to create a new resource on a server. If you perform a `POST` request, the server creates a new entry in the database and tells you whether the creation is successful. In other words, a `POST` request performs an `CREATE` operation.
`PUT` and `PATCH`These two requests are used to update a resource on a server. If you perform a `PUT` or `PATCH` request, the server updates an entry in the database and tells you whether the update is successful. In other words, a `PUT` or `PATCH` request performs an `UPDATE` operation.
`DELETE`This request is used to delete a resource from a server. If you perform a `DELETE` request, the server deletes an entry in the database and tells you whether the deletion is successful. In other words, a `DELETE` request performs a `DELETE` operation.
Headers are used to provide information to both the client and server. It can be used for many purposes, such as authentication and providing information about the body content. 

The data (sometimes called “body” or “message”) contains information you want to be sent to the server. This option is only used with POSTPUTPATCH or DELETE requests.


Response Codes:

2XX  - Success
3XX - Request redirected
4XX - Client Error
5XX - Server Error







































            

REST API

  API  is an application programming interface. It is a set of rules that allow programs to talk to each other. The developer creates the AP...