RESTful APIs

REST (REST API Architectural Constraints)

REST stands for REpresentational State Transfer and API stands for Application Program Interface. REST is a software architectural style that defines the set of rules to be used for creating web services. Web services which follow the REST architectural style are known as RESTful web services. It allows requesting systems to access and manipulate web resources by using a uniform and predefined set of rules. Interaction in REST based systems happen through Internet’s Hypertext Transfer Protocol (HTTP).

A Restful system consists of a:

Which HTTP method should we use?

When constructing a REST API each HTTP method corresponds to an action against a resource served by the API.

HTTP status codes

There are a multitude of HTTP status codes, here is just a few of the pertinent ones (which we will be using):

REST API Movies Example

Let us now create this API in Express. We will be using JSON as our transport data format as it is easy to work with in JavaScript and has other benefits. We will be using POSTMAN for API Testing so Download and Install POSTMAN in your system.

POSTMAN (*Mandatory to learn)

Postman is one of the most popular software testing tools which is used for API testing. With the help of this tool, developers can easily create, test, share, and document APIs.

Introduction to Postman

Tutorials and Crash Course

Code Example (Movies Example)

📁 You can see code in Code Folder. Here’s the link

Run it by doing

npm install

npm server.js

Then Test it using POSTMAN.

*After completing the Topic 7 read the Important Reads Listed in the Expressjs Page: Repo and Web.