Understanding Of RestAPI

Twinkal Doshi
2 min readJun 26, 2023

--

API

API stands for Application Programming Interface. In the context of APIs, the word Application refers to any software with a distinct function. The interface can be thought of as a contract of service between two applications. This contract defines how the two communicate with each other using requests and responses.

For example, the weather bureau’s software system contains daily weather data. The weather app on your phone “talks” to this system via APIs and shows you daily weather updates on your phone.

RESTful API

RESTful API is an interface that two computer systems use to exchange information securely over the internet

HTTP, HTTPS Protocol

https://www.geeksforgeeks.org/difference-between-http-and-https/

Methods in RESTful API

Method 1: GET

The GET method is used to ‘retrieve’ a record or a collection of records from the server. The response is generally a JSON object with the data you requested.

Method 2: POST

You use the POST method whenever you need to create a new record in the database. This method takes an object as a payload and sends it to the server. The server code then handles the data, processes it if needed, and puts it in the database.

Method 3: PUT

You often need to update the existing data of the database, and the HTTP PUT method allows you to do just this. Like the POST method, it also takes an object and sends it to the server. The server processes the data and then updates the databases with the updated data.

Method 4: PATCH

The PATCH request method is used to modify only the necessary part of the data or response. The PATCH method doesn’t modify the entire response. It only modifies partial modifications to a resource.

Method 5: DELETE

As the name suggests, this method exists to delete data off the server. It is provided with a payload with information like the ID of the record the user wants to delete. Once the ID is found on the server, it is deleted from the database.

Status Codes

Most used codes — 200, 201, 401, 500, 204

Fetch

https://www.tothenew.com/blog/fetch-vs-axios-for-making-http-requests/#:~:text=Axios%20has%20built%2Din%20XSRF,timeout%20but%20fetch%20does%20not.

Axios

https://www.npmjs.com/package/axios

--

--

No responses yet