introduction to rest - api

13

Upload: chetan-gadodia

Post on 17-Jul-2015

280 views

Category:

Technology


5 download

TRANSCRIPT

Background

HTTP Overview

REST - API Overview

Design Constraints

Benefits

Examples

Developed by W3C - World Wide Web Consortium

Technical Architecture Group (TAG) in parallel with HTTP 1.1

Software architecture

Components

Connectors

Data

Architectural properties

Allows for sending documents back & forth on the web.

URL’s Identifies a “Resource”.

/Team - identify all Team

/Team/QA/ABC - identify the Member of a team.

HTTP Verbs

GET / PUT / DELETE / POST

Representations

Response Codes

200 OK

201 Created

500 Internal Server Error

400 Bad Request

404 Not Found

REST – API Stands for?

Request Static Transfer

Remote State Transfer

Remote Stored Transfer

Remote Static Transfer

Correct Answer is…

REpresentational State Transfer

Relies on a

Stateless

Client - Server

Cacheable communications protocol

HTTP protocol is used.

Architecture Style for designing networked applications

The Design Constraints for REST – API style.

Uniform Interface

Simplifies and Decouples the architecture.

Enables each part to evolve independently.

Four guiding principles

Resource-Based

Manipulation of Resources Through Representations

Self-descriptive Messages

Hypermedia as the Engine of Application State (HATEOAS)

Stateless

State to handle the request is contained within the request itself.

The URI uniquely identifies the resource and the body contains the state

(or state change) of that resource.

After Server Process - communicated back to the client via headers,

status and response body.

Enables greater scalability - server does not have to maintain, update or

communicate that session state.

Load balancers don't have to worry about session affinity for stateless

systems

Cacheable

Well-managed caching partially or completely eliminates some client–

server interactions, further improving scalability and performance.

Client-Server

Uniform interface separates clients from servers.

Clients are not concerned with data storage - portability of client code is

improved.

Servers are not concerned with the user interface or user state - servers

can be simpler and more scalable

Layered System

A client cannot connected directly to the end server.

A client may connected with Server via Intermediary servers.

Intermediary servers may improve system scalability by enabling load-

balancing.

Helps to enforce security policies.

Network Performance

Efficiency - Caching data

Scalability - Gateway, Proxy and layered

User Perceived Performance - Caching

pre-fetched information

- Eg: Form Validation