What is REST API?
- REST stands for Representational State Transfer
- Uses HTTP and HTTP Standard request types to perform operations on resource exposed by server
- GET
- PUT
- POST
- DELETE

What is a Resource?
Resource is a Domain Object around which API are exposed.
Resource Examples Consider you are creating School Management Application, here resources will be:
- Student
- Teacher
- ReportCard
- School
- Subject
Which HTTP request type is used for what kind of operation on resource in REST API?
- GET
- Query specific resource
- Query collection of resources
- PUT
- Updating a resource
- POST
- Creating a resource
- DELETE
- Deleting a resource
REST stands for: Representational State Transfer, what do you mean by Representational State Transfer?
As per REST standards, Client and Server exchange Representation of Resource
- When creating a new resource, client sends representation of new resource and server saves it.
- When client wants its existing resource, it asks server for it and server sends representation of existing state of resource.
- When client wants to update state of resource on server side, it sends updated representation of resource.

Representation types
- XML
- JSON
- ProtoBuf
Representation being transferred contains:
- Data
- Metadata
- hypermedia links to transition to more information
Example
Create: Client sends data to Server
{
name: Rakesh Kalra,
age: 14
course: science,
}
Get
{
id: 1211
name: Rakesh Kalra,
age: 14
course: science,
createTime: 12-05-2020
}
Get All
[
{
id: 1211
name: Rakesh Kalra,
age: 14
course: science,
createTime: 12-05-2020
},
{
id: 1222
name: Harish Singh,
age: 17
course: commerce,
createTime: 19-05-2020
}
....
]
How updation of information works?
- Client ask server for current state of resource
- Client sends server updated state of resource

Can you give example of REST API with say example of Student URLs?
Operation | Request Type | URI | Request Body |
---|---|---|---|
Get all Students | GET | /api/students | |
Get specific Student | GET | /api/students/123 | |
Create new Student | POST | /api/students | Request body will contain representation of new student |
Update specific Student | PUT | /api/students/123 | Request body will contain updated representation of specific student |
Delete a Student | DELETE | /api/students/123 |