2. Over View:
1. What is An API
2. API Example
3. What is REST
4. Rest Example
5. How REST WORKS
3. What Is An API?
An API is a kind of mediator between client and server which
takes the request and delivers the response
A set of functions and procedures that allow the creation of
applications which access the features or data of an operating
system, application, or other service.
7. Why is it so called?
The Client references a Web resource using a URL. A representation of the resource is
returned (in this case as an HTML document).
The representation (e.g., Boeing747.html) places the client application in a state. The result of
the client traversing a hyperlink in Boeing747.html is another resource accessed. The new
representation places the client application into yet another state. Thus, the client application
changes (transfers) state with each resource representation --> Representation State
Transfer!
9. REpresentational State Transfer
REST
Nouns (Resources)
unconstrained
i.e., http://example.com/employees/12345
Verbs
constrained
i.e., GET
Representation
s
constrained
i.e., XML
10. Verbs:
•Represent the actions to be performed on resources
•HTTP GET (Create)
•HTTP POST(Read)
•HTTP PUT(Update)
•HTTP DELETE(delete)
12. REST and the WEB
•The Web is an example of a REST system!
•All of those Web services that you have been using all these many years -
book ordering services, search services, online dictionary services, etc - are
REST-based Web services.
•Alas, you have been using REST, building REST services and you didn't even
know it.
13. Resource based
• Things vs Actions
• Nouns vs Verbs
• Identified by URIs
• Separate Representation
14. Six Constraints:
1. Uniform Interface
2. Stateless
3. Client Server
4. Cachable
5. Layered System
6. Code On Demand
15. Uniform Interface:
• Defines the interface between Client and Server
• Simplifies and Decopules the Representation
• For Us this means:
• HTTP Request
• URI
• HTTP response
16. Stateless:
• Server Contains No Client State
• Each request has enough context to process message
-Self Descriptive messages
• Session states are held at client side
17. Client - Server
• Disconnected System
• Separate Concerns
• Uniform Interface between client and server
19. Layered System
• Client Cant assume direct connection to server
• Software or hardware intermediares between them
20. Code on Demand
• Server Can temporarily extend client
• Transfer logic to client
• Client executes the logic
• For Example,
1. Java Applets
2. Java Script
21. SOAP vs REST
• Soap Overhead
• web Standards
• XML
• No Overhead
• No Web Standards
• XML,JSON
23. Lets Take an example,
Observe the Urls of the below images
24. Now In this below picture you are observing data which is from the server in
KEY VALUE pairs format
We Uses those Keys to represent the Values dynamically.
26. Summary:
• Violating any Constraint other than code on demand, means it is
not strictly RESTful web Service
• Compliance with REST Constraint
1. Scalability
2. Modifiability
3. Portability
4. Visibility
5. Simplicity