Menu

REST API
πŸ“°

REST API

DEV Community: backendΒ·LokeshΒ·15 days ago
#vnFKMwPf
#devtobackend#devto#dev#products#example
Reading 0:00
15s threshold

What Is an API?

API stands for Application Programming Interface .

In simple terms, an API allows different applications to communicate with each other.

For example, a frontend application can send a request to a server and receive data in return.

What Is a REST API?

REST stands for Representational State Transfer .

A REST API is a common way for applications to communicate over the internet using HTTP.

For example, an e-commerce application may use an API to:

Get all products.

Get a single product.

Add a new product.

Update a product.

Delete a product.

HTTP Methods

REST APIs commonly use different HTTP methods to perform different operations.

1. GET

GET is used to retrieve data .

Example:

GET /products

Enter fullscreen mode

Exit fullscreen mode

This can be used to get a list of products.

fetch ( " https://dummyjson.com/products " ) . then (( response ) => response . json ()) . then (( data ) => { console . log ( data ); });

Enter fullscreen mode

Exit fullscreen mode

2.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.