Application Programming Interface RESTful APIs
Mobile applications can retrieve data from the user’s device application, an online source, or the database.
Let’s start with API, which stands for application programming interface: It is a set of rules and protocols that allows different software applications to communicate with each other.
The number of APIs globally is growing rapidly, with Postman reporting typical growth of 39 percent in the last year.
More simply, In a restaurant, when you’re ready to order, you have a menu to make your food selection. You choose your desired dish. After finalizing your order, the waiter takes note of it and then takes it to the chef. The latter then prepares your meal accordingly, and the waiter serves it to your table. This process is straightforward for you as a diner since you don’t need to concern yourself with the steps of how the food is cooked. In this scenario, the waiter functions as an intermediary, similar to an API, serving as the vital link that establishes seamless communication between you and the kitchen.

Today, we have categories of API protocols, one of them is REST API is a method of communication between applications and web services.
Let’s dive a little deeper and understand more…
REST is Representational State Transfer. It’s an architecture style and set of constraints used for designing network applications and you can only say that an API is RESTful if specific constraints are met.
However, the following five constraints must be present for any application to be considered RESTful:
- Client-server: the client sends requests to the server, and the server responds with data.
- Stateless: each request from the client to the server must contain all the information needed to understand and process the request.
- Cacheable: responses can be saved by a web browser, a server, or any system.
- Layered: the system can be split into layers (a client can not necessarily tell if it is directly communicating with the server or an intermediate).
- Have a uniform interface: the system should offer a uniform communication system to access the resources.
- Code on demand (optional).
You already know that HTTP methods and status codes play an essential role in REST APIs.
Here is a list of the most used HTTP methods and which action you should initiate for those calls.
- GET: Returns the requested resource. If not found, return a 404 Not Found status code.
- POST: Creates a record. The POST request always comes with an HTTP request body containing JSON or Form URL encoded data, which is also called a payload.
- PUT: Update a specified resource: A PUT request deals with a single resource.
- PATCH: Tells the API to update a part of the resource. Note the difference between a PUT and a PATCH call. A PUT call replaces the complete resource, while the PATCH call only updates some parts. A PATCH request also deals with a single record.
- DELETE: Delete a resource.
See you in the next part 2 of my Blog article about REST API …, Take care!!
Comments
Post a Comment