Free Ebook cover How to create APIs in NodeJS from basic to advanced

How to create APIs in NodeJS from basic to advanced

5

(1)

149 pages

What are REST API's

Capítulo 64

Estimated reading time: 3 minutes

Audio Icon

Listen in audio

0:00 / 0:00

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.

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

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.

REST APIs commonly use JSON as the data format for sending and receiving data, making it the typical choice due to its simplicity and ease of use.

Next chapter

Creating a basic REST API with NodeJS and ExpressJS

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.