REST API’s #2

A REST API (also known as RESTful API) is an application programming interface (API or web API) that conforms to the constraints of REST architectural style and allows for interaction with RESTful web services. REST is an acronym for Representational State Transfer and an architectural style for distributed hypermedia systems. It was created by computer scientist Roy Fielding.

An API is a set of definitions and protocols for building and integrating application software. It’s sometimes referred to as a contract between an information provider and an information user—establishing the content required from the consumer (the call) and the content required by the producer (the response).

REST has a set of rules that developers follow when they create their API. One of these rules states that you should be able to get a piece of data (called a resource) when you link to a specific URL. Each URL is called a request while the data sent back to you is called a response.

In order for an API to be considered RESTful, it has to conform to these criteria:

  • A client-server architecture made up of clients, servers, and resources, with requests managed through HTTP.
  • Stateless client-server communication, meaning no client information is stored between get requests and each request is separate and unconnected.
  • Cacheable data that streamlines client-server interactions.
  • A uniform interface between components so that information is transferred in a standard form. This requires that:
    • resources requested are identifiable and separate from the representations sent to the client.
    • resources can be manipulated by the client via the representation they receive because the representation contains enough information to do so.
    • self-descriptive messages returned to the client have enough information to describe how the client should process it.
    • hypertext/hypermedia is available, meaning that after accessing a resource the client should be able to use hyperlinks to find all other currently available actions they can take.
  • A layered system that organizes each type of server (those responsible for security, load-balancing, etc.) involved the retrieval of requested information into hierarchies, invisible to the client.
  • Code-on-demand (optional): the ability to send executable code from the server to the client when requested, extending client functionality. 

In conclusion, here are 3 good reasons to use rest api’s:

  • Scalability. This protocol stands out due to its scalability. Thanks to the separation between client and server, a product may be scaled by a development team without much difficulty.
  • Flexibility and portability. With the indispensable requirement for data from one of the requests to be properly sent, it is possible to perform a migration from one server to another or carry out changes on the database at any time. Front and back can therefore be hosted on different servers, which is a significant management advantage.
  • Independence. With the separation between client and server, the protocol makes it easy for developments across a project to take place independently. In addition, the REST API adapts at all times to the working syntax and platform. This offers the opportunity to use multiple environments while developing.

resources:

https://www.smashingmagazine.com/2018/01/understanding-using-rest-api/

https://restfulapi.net/

Leave a comment

Design a site like this with WordPress.com
Get started