api

rest

rest-api

REST API

A weblog about REST API that exposes GET, POST, DELETE, and PUT endpoints that will subsequently allow you to perform the full range of CRUD operations.

Anushka Singh (anushka)

Inspiration does exist, but it must find you working.

What is REST API?

Restful API
RESTFUL API is an interface that allows applications to communicate with each other. It provides a communication interface for different components of your system, allowing data exchange in an efficient and secure manner. It defines the way that different parts of the application interact with each other and how they are organized. RESTFUL API also provides a way to extend the application by adding new APIs or endpoints without having to modify existing code. With this technology, you can easily create a simple API or integrate another one with your existing structure. Additionally, it utilizes a port number to make sure that messages sent via the API are received correctly by the right component. By using RESTFUL API, you can be sure that your application is up-to-date and running smoothly at all.

REST stands for Representational State Transfer. It is an architectural style for designing networked applications (i.e apps that use some form of a network to communicate). It is the most popular style for building web APIs. REST determines specifications of the API through a set of rules that are followed when a REST API is created.

REST treats any data (e.g. image, video, text, etc) as a resource that the client can fetch/edit/delete. REST mandates that a client should be able to perform the appropriate operation by accessing a specific URL and sending a request. The server then sends an appropriate response.
Think of it as a contract between the programs: the requester (aka the client) and the responder (aka the server). If the requester sends X to the responder, the responder will give Y to the requester. X and Y are specified in contract between the two parties and explained in the documentation for the API.

Anatomy of URL
vouzamo-wordpress-com-anatomy-of-a-url

RESTFUL API makes use of HTTP methods such as GET, POST, PUT and DELETE when interacting with application resources via a port number, which makes it easy for developers to develop system-to-system communication in real-time.

image

Data (such as images, videos, and text) embody resources in REST. A client visits a specific URL and sends a server request to receive a response.
A request (the URL you access) contains four components, which are:

  • the endpoint, which is the URL with the structure root-endpoint/?
  • the method with one of the five possible types (GET, POST, PUT, PATCH, DELETE)
  • the headers, serving various functions, including authentication and providing information about the content of the body (you can use the -H or --header option to send HTTP headers)
  • data (or body), that’s what you send to the server through the -d or --data option with POST, PUT, PATCH, or DELETE requests.
    The HTTP requests allow you to operate with the database, such as:
  • POST request to create records
  • GET request to read or get a resource (a document or image, a collection of other resources) from the server
  • PUT and PATCH requests to update records
  • DELETE request to delete a resource from a server
    These operations stand for four possible actions, known as CRUD: Create, Read, Update and Delete.

Making an HTTP request in JavaScript
api3

The server sends the data to the client in one of the following formats:

  • HTML
  • JSON
  • XLT
  • PHP
  • Python
  • Plain text

ekawmj3rafdtn06hzj79