1 of 16

REST, Request, Response

Web Technology

Subin Sahayam, Rourab Paul, Assistant Professor,

Department of Computer Science and Engineering

Shiv Nadar University

2 of 16

REST Web Service

REST is an architectural style for designing web services, where resources are identified by URLs and accessed using standard HTTP methods.

K1

3 of 16

REST Web Service

REST is an architectural style for designing web services, where resources are identified by URLs and accessed using standard HTTP methods.

K1

4 of 16

REST Web Service

  • REST Web Service?
    • Provide Information over Web - Interoperability
    • REpresentational State Transfer (REST)
    • Architectural Style
      • Client – Server Separation
      • Stateless
      • Simplicity
      • Scalability
      • Cacheable
      • Layered System
      • Uniform Interface

​

K1

5 of 16

REST Web Service

  • Client – Server Separation
  • Stateless - Each request is self-contained
  • Cacheable - Clients can cache and reuse data
  • Layered System - Intermediaries like proxies or load balancers
  • Uniform Interface - Standard Methods
  • Code on demand – Server Send Executable Code

K1

6 of 16

REST Architecture

K2

7 of 16

REST Request

K2

8 of 16

HTTP Verbs

K2

9 of 16

HTTP Verbs

K2

Method

Purpose

Example

GET

Read data

Get student 101

POST

Create data

Add a new student

PUT

Replace/update data

Update student 101

PATCH

Partially update

Change only student's name

DELETE

Delete data

Delete student 101

10 of 16

HTTP Verbs

  • Methods: GET, POST, PUT, PATCH, DELETE, HEAD, CONNECT, OPTIONS, TRACE
  • Safe: Methods that do not change server state
  • Idempotency: Repeating a method has same effect
  • Status Code: 200, 404, 501
  • Headers: Meta Data

K1

11 of 16

HTTP Verbs

K2

12 of 16

REST Response

K2

13 of 16

​

​

​

​

14 of 16

​

​

​

​

Website / Service

Example REST API use

GitHub

Repositories, users, issues, commits

Google Maps Platform

Places, routes, geocoding

Spotify

Music, albums, artists, playlists

Slack

Messages, channels, users

Google Drive

Files and folders

Google Sheets

Read/write spreadsheet data

Gmail

Messages, labels, threads

Popular real-world services

15 of 16

​

​

​

​

Git Hub Example

Purpose

HTTP Method

REST API URL

Get a user

GET

https://api.github.com/users/octocat

Get user repositories

GET

https://api.github.com/users/octocat/repos

Get repository information

GET

https://api.github.com/repos/octocat/Hello-World

Get repository issues

GET

https://api.github.com/repos/octocat/Hello-World/issues

Get repository contents

GET

https://api.github.com/repos/octocat/Hello-World/contents/README

Get pull requests

GET

https://api.github.com/repos/octocat/Hello-World/pulls

16 of 16

THANK YOU