REST APIs 101 : A brief introduction



REST APIs stand for Representational State transfer.
It is a simple, standardized, scalable and stateless (data about the communication is not saved ) way to communicate between Restful web services (Web services that use REST API) and the clients.



Example ( REST API Endpoint ) : 

"https://address.com/users" (Endpoint for the resource "users")
"https://address.com/companies" (Endpoint for the resource "companies")

REST API operations:

REST APIs operations are based on the C.R.U.D model (Create, Read, Update, Delete) which translates to (Post, Get, Put, Delete) in HTML parlance.
  • Post: for creating resources.
  • Get: for reading resources.
  • Put: updates resources.
  • Delete: deletes resources
REST API Endpoint:

The REST API endpoint is the URL (Uniform Resource Locator) of the resource (image, video, database) we want to request.
Parameters: represent the parameters of the queried resource, they come after the REST API endpoint.
Header: is the metadata describing the format of the request.

Communication between different applications:

REST API allows communication between applications that use completely different technologies and languages (JAVA, Node.js,...) through a standardized communication methods using REST API.

Most RESTful API use HTTP as the transport protocol to send the request to the server. The response from the RESTful web services (web services using REST APIs) could be in JSON, HTML, XML, ...

We send a REST formatted request and we get REST formatted response (according to the REST API style).
The format is a standard one that the client sending the REST API requests and the RESTful web 
services understand.

Example of HTTP requests:

When we use HTTP in our browser to view the contents of a site, we send a GET request, when we fill out a form and hit "submit" we are sending a POST request (diagram below).


The curl tool:

The curl (Client url) is a client program that is used to send and receive data to and from servers.
We can use it to send REST API requests over HTTP.
Using curl to send REST API requests, we can add resources, delete them, update them,...


You will get all the HTML code for the home page.
Curl does a GET request to the web server and receive the response as HTML for example.

Comments

Leave as a comment:

Archive