what is a restful api

11 months ago 16
Nature

A RESTful API is an application programming interface that conforms to the constraints of REST architectural style. REST stands for Representational State Transfer and was created by computer scientist Roy Fielding. RESTful APIs allow for interaction with RESTful web services and are used to exchange information securely over the internet between two computer systems. RESTful APIs are based on representational state transfer (REST), which is an architectural style and approach to communications often used in web services development.

RESTful APIs are defined with the following aspects:

  • The resource identifier (URI) of one or several resources used as starting points, sometimes called endpoints or entry points.
  • The encoding of all possible resource representations (which will include representation of the data and of the hypermedia links for state transitions).
  • The possible state transitions and where they can occur.

When a client request is made via a RESTful API, it transfers a representation of the state of the resource to the requester or endpoint. This information, or representation, is delivered in one of several formats via HTTP, such as JSON, HTML, XML, Python, PHP, or plain text. JSON is the most popular file format to use because it’s language-agnostic, as well as readable by both humans and machines.

RESTful APIs communicate via HTTP requests to perform standard database functions like creating, reading, updating, and deleting records (also known as CRUD) within a resource. For example, a REST API would use a GET request to retrieve a record, a POST request to create one, a PUT request to update a record, and a DELETE request to delete one. All HTTP methods can be used in API calls.