What is API REST?

Breno Ridolfi
3 min readJun 17, 2021
Create by Breno Ridolfi

If you arrived at this post it’s because you’re looking for a simplified explanation to understand what REST API is, Right?

API(Application Programming Interface) would be an input/output port of information from a given company where other applications could consume such information. In the more technical part API(web) usually uses HTTP request and response service, returning information in XML or JSON format.

REST

REST is a set of architectural principles, where we can have the separation of responsibility from the client/server where they must be prepared to communicate with using HTTP REQUESTS.

REST requests must be Stateless, therefore, they must not save information from old requests and must be individual/independent, for example, they must not store authentication on the back-end (server), authentication must always be sent with the request to the back-end , for example sending using “Headers”.

On the front-end(client) it recommends storing information in cache to avoid requests on the server, usually used in GET requests.

It is recommended to use a uniform interface between components to standardize, in this case I recommend that the back-end application uses Swagger, so it is possible to access the root URL and view all available Apis with more details. But Rest guides to use Hypermedia as the engine of application state (HATEOAS), because it brings some advantages to your api. However, the concept of HATEOAS is not always used.

REQUESTS REST AND VERBS HTTP

In the REST concept HTTP verbs are very important so let’s understand them!

GET: Used to query information on the server.
Exemple: URL “/students” return a list of students.

POST: Used to inform the back-end (server) that it must record in its database the information received in the request, using POST it is possible to use the HTTP body.
Exemple: URL “/students”, create a new Student 2.

Body
{
"name": "Student 2"
"age": 15
}

PUT: Used to inform the back-end (server) that it must record in its database the information received in the request, using PUT it is also possible to use the HTTP body.
Exemple: URL “/students/2”, change the age of Student 2.

Body
{
"name": "Student 2"
"age": 17
}

DELETE: Used to inform the back-end (server) that it must delete information in its database.
Exemple: URL “/students/2”, delete Student 2.

Tips

  • In the back-end application create a standardized communication nomenclature, for example:
    For input information use “NameModelRequest”, and for response information use “NameModelResponse”.
  • In the front-end I also recommend using a Request and Response template, this helps keep the code organized.
  • Learn and use Postman, it is an excellent tool to test API and to organize a library with several API.

Conclusion

Api rest is the best invention today basically everything we use for internet interaction is REST.
With this brief explanation I hope I have made you understand how Api Rest works and that you can build your Apis understanding how the Rest concept works.
Thank you for reading!! I am open to suggestions for improvements to the article!

--

--