Article image What are REST API's

9. What are REST API's

Page 64 | Listen in audio

REST APIs, or Representational State Transfer (REST), are an architectural style of software that define a set of constraints to be used to create web services. REST is a popular alternative to other API development methods such as SOAP due to its simplicity and the fact that it is built on top of existing web standards such as HTTP.

In simple terms, a REST API is a way for developers to interact with a given software or service. It provides an interface that can be used to request data from a server, send data to a server, or perform other operations on a server. These requests are made using standard HTTP methods such as GET, POST, PUT, and DELETE.

One of the main characteristics of REST APIs is their stateless nature. This means that each request made to a server is independent and has no knowledge of previous requests. This is important because it allows REST APIs to be highly scalable since the server doesn't need to maintain state information for each client. Instead, all of the information needed to process a request is sent with the request itself.

Another important feature of REST APIs is their adherence to the principle of interface uniformity. This means that all requests made to a REST API follow the same basic structure, regardless of the type of data being requested or the operation being performed. This makes REST APIs very easy to use and understand as developers don't have to learn a new interface for every different service they are working with.

REST APIs are also designed to be cacheable, which means that responses to certain requests can be stored and reused, reducing the amount of network traffic and improving performance. Additionally, REST APIs are typically designed to be layerless, meaning that a client can communicate directly with a server without the need to go through intermediaries.

In terms of data format, REST APIs typically use JSON (JavaScript Object Notation) as the default data format for sending and receiving data. JSON is a lightweight, easy-to-use data format that can be easily converted into JavaScript objects, making it a popular choice for REST APIs.

To illustrate how a REST API works, consider an example of a REST API that allows a client to request information about a book in a library. The client would make a GET request to the API URL, including the Book ID as part of the URL. The API would then return a JSON object containing all the information about the book, such as the title, author, and publication date.

If the client wanted to update a book's information, it would make a PUT request to the API URL, including the book ID and a JSON object containing the new book information. The API would then update the book information on the server and return a response confirming that the operation was successful.

In summary, REST APIs are a powerful and flexible way to create web services. They are easy to use, highly scalable, and built on top of existing web standards, making them a popular choice for many developers.

Now answer the exercise about the content:

_Which of the following statements is true about REST APIs?

You are right! Congratulations, now go to the next page

You missed! Try again.

Article image Creating a basic REST API with NodeJS and ExpressJS

Next page of the Free Ebook:

65Creating a basic REST API with NodeJS and ExpressJS

4 minutes

Earn your Certificate for this Course for Free! by downloading the Cursa app and reading the ebook there. Available on Google Play or App Store!

Get it on Google Play Get it on App Store

+ 6.5 million
students

Free and Valid
Certificate with QR Code

48 thousand free
exercises

4.8/5 rating in
app stores

Free courses in
video, audio and text