REST APIs
Definition
Representational State Transfer. An architectural style for designing networked applications. It relies on standard HTTP methods (GET, POST, PUT, DELETE) and treats data as 'Resources' identified by URLs.
Explain Like I'm New
A REST API is a digital menu for a restaurant. You cannot run into the kitchen and cook the food yourself. You must look at the menu (the API documentation), choose an item (a URL endpoint like `/users`), and tell the waiter exactly what you want using specific verbs (GET = read, POST = create, DELETE = remove). The kitchen (Node.js) then prepares the data and brings it out to you on a plate (JSON).
Real World Example
The Twitter API. You send a `GET` request to `api.twitter.com/tweets/123` to read a tweet. You send a `POST` request to `api.twitter.com/tweets` with a JSON body to create a new tweet.
Common Use Cases
- •Connecting mobile apps to a backend
- •Connecting React/Vue frontends to a database
Terminal Output
Interview Questions
basic
- What format is most commonly used to send and receive data in a REST API?
intermediate
- What is a 'Stateless' architecture in REST?