What is REST API?

What is REST API?

A REST API is the most conventional type of application programming interface on the World Wide Web.

What does REST stand for?

RE stands for REpresentational, the S for State and the T for Transfer. This adds up to Representational State Transfer. REST is a type of software architecture used to describe any interface between different systems that use HTTP for their communication. The REST paradigm states that when data is transferred between two clients, no information is retained by the data transfer service itself. An example: You log in to PayPal with your login details and are authenticated by the service. At your next session you have to log in again because no authentication was stored in the previous login process.

Who is the client of a REST API?

Clients can be native apps (Android, iOS), an internet browser (Google Chrome, Safari, Microsoft Edge, etc.) or Virtual Assistant AIs like Alexa or Google Home. Of course, any smart home device (wifi controlled radiators) that is connected via an API is defined as a client.

What does RESTful mean?

An API is RESTful if it adheres to the norms of the API REST standards.

What makes a REST API?

The main characteristic is the loose client-server coupling: client and server do not need any exchange beyond that of the data. In concrete terms, this means that the server is not "interested" in what the client does with the data. The client, in turn, is not "interested" in what the server implementation looks like either. 

Secondly, a REST API is stateless, so to speak, because each API call (or API call) that arrives at the server is independent. For accessing, creating, updating and deleting resources, the following HTTP verbs are used while maintaining the order: GET, POST, PUT, DELETE. If you request information on a web page, this is a GET. A POST happens, for example, when you leave your contact details on the World Wide Web.

Thirdly, API calls can be cached so that the same resource does not experience multiple requests.

Fourthly, it is important to mention that a REST API is uniform: each resource must have a unique Uniform Resource Identifier.

A REST API can use the same methods to query a third-party server that are used to display pages or forms on the same website. For this reason, the third-party server can be queried using a URL provided by the API editor.

An API is not one-way

Where there is a request in the form of an API call, there is also a response. The response is in one of two specific return formats: JSON or XML. In some circumstances, the API development may have been done in such a way that the user can choose the return format of the REST API.

A well-constructed (RESTful) interface is usually easy to read and the corresponding API documentation is clearly formulated, as is the case with the Youtube Data API, for example.

Example of how to use the GET function in a REST API

Imagine that a third person maintains an address book with all your contacts for you. You can 1. extract information from this address book via API calls (i.e. GET requests) and 2. add information to it via API calls (POST). Now you want to know who the number that just called your mobile phone belongs to (e.g. 09732 30 24 984, the number of appleute).

So you perform a GET query to the address of your address book stored in the API documentation, e.g. api.myaddressbook.com/contacts/phone/097323024984.

Here, you are searching for the address entry based on the phone number. The restful API will be able to answer you in the appropriate return format:

  • Phone number: 097323024984
  • First name: Marc
  • Last name: Mueller
  • Company: appleute

The result is unique because of the uniqueness of the phone number. If, on the other hand, you were to search for "Mueller", you would possibly have several entries, because "Mueller" - being a very common surname in Germany - may occur more frequently in your address book.

So much for GET requests to extract or request information via the so-called REST API.

Example of how to use the POST function in a REST API

The mechanism for the POST action is similar to that of the GET request. Imagine you want to pass on information, i.e. "post" something. In a figurative sense, posting is done via a kind of contact form or template, with the individual components of the shared information communicated to the interface via the contact form parameters. In this way, information can be passed on to a third-party provider and its receipt or status can even be confirmed upon receipt.

REST-API Development: Consult experts

For questions about or applications (API to PayPal, YouTube, ERP, etc.) of REST API, API development agencies like appleute are at your side.