SlideShare une entreprise Scribd logo
1  sur  51
A Conversation About REST
          Jeremy Brown
        notmessenger.com
What is an API?
What is an API?
From Wikipedia:

An application programming interface (API)
is a particular set of rules and specifications
that a software program can follow to access
and make use of the services and resources
provided by another software program that
implements the API.
What is an API?
Wikipedia continues:

It serves as an interface between different
software programs and facilitates their
interaction, similar to the way the user
interface facilitates interaction between
humans and computers.
What is an API?
Our understanding:

Set of rules and specifications to facilitate
the interaction between different software
programs.
Examples
mkdir

format
Types of APIs
XML-RPC (1998)

SOAP (1998, 2003)

JSON-RPC (2005)

REST (2000)
XML-RPC
xmlrpc.com

It’s remote procedure calling using HTTP as
the transport and XML as the encoding.
XML-RPC is designed to be as simple as
possible, while allowing complex data
structures to be transmitted, processed and
returned.
XML-RPC
xmlrpc.com also says:
We wanted a clean, extensible format that’s very
simple. It should be possible for an HTML coder to
be able to look at a file containing an XML-RPC
call, understand what it’s doing, and be able to
modify it and have it work on the first or second
try... We also wanted it to be an easy protocol
that could quickly be adapted to run in other
environments or on other operating systems.
XML-RPC
Sample Request:
<?xml version="1.0"?>
<methodCall>
  <methodName>getStateName</methodName>
  <params>
    <param>
        <value><int>40</int></value>
    </param>
  </params>
</methodCall>
XML-RPC
Sample Request:
<?xml version="1.0"?>
<methodCall>
  <methodName>getStateName</methodName>
  <params>
    <param>
        <value><int>40</int></value>
    </param>
  </params>
</methodCall>



Sample Response:
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
        <value><string>South Dakota</string></value>
    </param>
  </params>
</methodResponse>
SOAP
SOAP spec:
SOAP is a lightweight protocol for exchange of
information in a decentralized, distributed
environment. It is an XML based protocol that
consists of three parts: an envelope that defines a
framework for describing what is in a message and
how to process it, a set of encoding rules for
expressing instances of application-defined datatypes,
and a convention for representing remote procedure
calls and responses.
SOAP
Sample Request:
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 299

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
  <soap:Header>
  </soap:Header>
  <soap:Body>
    <m:GetStockPrice xmlns:m="http://www.example.org/stock">
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body>
</soap:Envelope>
JSON-RPC
Wikipedia says:

JSON-RPC is a remote procedure call
protocol encoded in JSON. It is a very simple
protocol (and very similar to XML-RPC),
defining only a handful of data types and
commands.
JSON-RPC
Sample Request:
{
"version": "1.1",
"method": "confirmFruitPurchase",
"id": "194521489",
"params": [
    [ "apple", "orange", "pear" ],
    1.123
]
}




{
"version": "1.1",
"result": "done",
"error": null,
"id": "194521489"
}
JSON-RPC
Sample Request:
{
"version": "1.1",
"method": "confirmFruitPurchase",
"id": "194521489",
"params": [
    [ "apple", "orange", "pear" ],
    1.123
]
}



Sample Response:
{
"version": "1.1",
"result": "done",
"error": null,
"id": "194521489"
}
Types of APIs
Types of APIs
XML-RPC

SOAP

JSON-RPC
Types of APIs
XML-RPC

SOAP          Service Oriented
JSON-RPC
Types of APIs
XML-RPC

SOAP          Service Oriented
JSON-RPC

REST          Resource Oriented
Types of APIs
   XML-RPC

   SOAP               Service Oriented
   JSON-RPC

   REST                Resource Oriented

Service Oriented architectures are designed
to call methods. REST transports resources.
REST
Representational State Transfer
Guiding Principles
Identification of resources

Manipulation of resources through these
representations

Self-descriptive messages

Hypermedia as the Engine of Application
State (HATEOAS)
Identification of resources
  Individual resources are identified in
  requests, for example using URIs in web-
  based REST systems
Identification of resources
  Individual resources are identified in
  requests, for example using URIs in web-
  based REST systems

  http://api.myapi.com/articles
Identification of resources
  Individual resources are identified in
  requests, for example using URIs in web-
  based REST systems

  http://api.myapi.com/articles
  http://api.myapi.com/article/12
Identification of resources
  Individual resources are identified in
  requests, for example using URIs in web-
  based REST systems

  http://api.myapi.com/articles
  http://api.myapi.com/article/12
  http://api.myapi.com/customer/4/order/18
Manipulation of resources
Manipulation of resources
  GET

  Return representation of the resource
  requested
Manipulation of resources
  GET

  Return representation of the resource
  requested

  PUT

  Replace representation with new
  representation, or create if does not exist
Manipulation of resources
Manipulation of resources
  POST

  Create a new resource
Manipulation of resources
  POST

  Create a new resource

  DELETE

  Delete the resource
Self-descriptive messages
 Each message includes enough information to
 describe how to process the message

 For example, the specification of media type
 through the use of the Content-Type header
Self-descriptive messages
   Each message includes enough information to
   describe how to process the message

   For example, the specification of media type
   through the use of the Content-Type header

Content-Type: image/jpeg
Self-descriptive messages
    Each message includes enough information to
    describe how to process the message

    For example, the specification of media type
    through the use of the Content-Type header

Content-Type: image/jpeg

                                  <radius>2</radius>
Content-Type: application/xml     <unit>inches</unit>
Self-descriptive messages
Another example are the Response Codes:
   200 Okay               413 Request Entity Too Large

   201 Created            415 Unsupported Media Type

   303 See Other          416 Requested Range Not Satisfiable

   401 Unauthorized       501 Not Implemented

   404 Not Found          many others
HATEOAS
HATEOAS
Just like with HTTP, there is no maintenance
of application state.
HATEOAS
Just like with HTTP, there is no maintenance
of application state.

Cookies are bad! Very, very bad!!
HATEOAS
Just like with HTTP, there is no maintenance
of application state.

Cookies are bad! Very, very bad!!

Related URIs should be included in
representations of resources.
Live Examples!
Other ways to interact
 with a REST service
Other ways to interact
 with a REST service
OPTIONS

Discover which methods of manipulation are
available for specified resource
Other ways to interact
 with a REST service
OPTIONS

Discover which methods of manipulation are
available for specified resource

HEAD

Get sample of Response header without data
payload
Conversation Starters
REST is a set of principles
 and not a specification
Allow for differing Accept
 and Content-Type values
 Content-Type: application/xml

 Accept: text/javascript
http://www.aisee.com/graph_of_the_month/http.png
Thank You
  Jeremy Brown
notmessenger.com

Contenu connexe

Tendances

REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transfer
Tricode (part of Dept)
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
David Krmpotic
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from REST
elliando dias
 

Tendances (20)

REST - Representational state transfer
REST - Representational state transferREST - Representational state transfer
REST - Representational state transfer
 
6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework6 Months Industrial Training in Spring Framework
6 Months Industrial Training in Spring Framework
 
ReST (Representational State Transfer) Explained
ReST (Representational State Transfer) ExplainedReST (Representational State Transfer) Explained
ReST (Representational State Transfer) Explained
 
RESTful Architecture
RESTful ArchitectureRESTful Architecture
RESTful Architecture
 
Rest and the hypermedia constraint
Rest and the hypermedia constraintRest and the hypermedia constraint
Rest and the hypermedia constraint
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
 
ReSTful API Final
ReSTful API FinalReSTful API Final
ReSTful API Final
 
Rest & RESTful WebServices
Rest & RESTful WebServicesRest & RESTful WebServices
Rest & RESTful WebServices
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Representational State Transfer (REST)
Representational State Transfer (REST)Representational State Transfer (REST)
Representational State Transfer (REST)
 
Implementation advantages of rest
Implementation advantages of restImplementation advantages of rest
Implementation advantages of rest
 
Rest api-interview
Rest api-interviewRest api-interview
Rest api-interview
 
REST and RESTful Web Services
REST and RESTful Web ServicesREST and RESTful Web Services
REST and RESTful Web Services
 
HATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from RESTHATEOAS: The Confusing Bit from REST
HATEOAS: The Confusing Bit from REST
 
JAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with JavaJAX-RS. Developing RESTful APIs with Java
JAX-RS. Developing RESTful APIs with Java
 
REST API Design
REST API DesignREST API Design
REST API Design
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Rest and Rails
Rest and RailsRest and Rails
Rest and Rails
 
Rest in Rails
Rest in RailsRest in Rails
Rest in Rails
 

Similaire à A Conversation About REST

RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
Li Yi
 
RESTful services
RESTful servicesRESTful services
RESTful services
gouthamrv
 

Similaire à A Conversation About REST (20)

Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015Phalcon 2 High Performance APIs - DevWeekPOA 2015
Phalcon 2 High Performance APIs - DevWeekPOA 2015
 
Salesforce Integration
Salesforce IntegrationSalesforce Integration
Salesforce Integration
 
Apitesting.pptx
Apitesting.pptxApitesting.pptx
Apitesting.pptx
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 
Rest web service
Rest web serviceRest web service
Rest web service
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Restful Fundamentals
Restful FundamentalsRestful Fundamentals
Restful Fundamentals
 
Web Service
Web ServiceWeb Service
Web Service
 
Network Device Database Management with REST using Jersey
Network Device Database Management with REST using JerseyNetwork Device Database Management with REST using Jersey
Network Device Database Management with REST using Jersey
 
Api design and development
Api design and developmentApi design and development
Api design and development
 
SFDC REST API
SFDC REST APISFDC REST API
SFDC REST API
 
RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座RESTful SOA - 中科院暑期讲座
RESTful SOA - 中科院暑期讲座
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
Best practices and advantages of REST APIs
Best practices and advantages of REST APIsBest practices and advantages of REST APIs
Best practices and advantages of REST APIs
 
Building Restful Applications Using Php
Building Restful Applications Using PhpBuilding Restful Applications Using Php
Building Restful Applications Using Php
 
RESTful services
RESTful servicesRESTful services
RESTful services
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
 
Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5Xamarin Workshop Noob to Master – Week 5
Xamarin Workshop Noob to Master – Week 5
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 

Plus de Mike Wilcox

Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
Mike Wilcox
 

Plus de Mike Wilcox (20)

Accessibility for Fun and Profit
Accessibility for Fun and ProfitAccessibility for Fun and Profit
Accessibility for Fun and Profit
 
WTF R PWAs?
WTF R PWAs?WTF R PWAs?
WTF R PWAs?
 
Advanced React
Advanced ReactAdvanced React
Advanced React
 
Webpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need itWebpack: What it is, What it does, Whether you need it
Webpack: What it is, What it does, Whether you need it
 
Dangerous CSS
Dangerous CSSDangerous CSS
Dangerous CSS
 
Web Components v1
Web Components v1Web Components v1
Web Components v1
 
Great Responsive-ability Web Design
Great Responsive-ability Web DesignGreat Responsive-ability Web Design
Great Responsive-ability Web Design
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
Model View Madness
Model View MadnessModel View Madness
Model View Madness
 
Hardcore JavaScript – Write it Right
Hardcore JavaScript – Write it RightHardcore JavaScript – Write it Right
Hardcore JavaScript – Write it Right
 
The Great Semicolon Debate
The Great Semicolon DebateThe Great Semicolon Debate
The Great Semicolon Debate
 
AMD - Why, What and How
AMD - Why, What and HowAMD - Why, What and How
AMD - Why, What and How
 
Dojo & HTML5
Dojo & HTML5Dojo & HTML5
Dojo & HTML5
 
Webpage Design Basics for Non-Designers
Webpage Design Basics for Non-DesignersWebpage Design Basics for Non-Designers
Webpage Design Basics for Non-Designers
 
Why You Need a Front End Developer
Why You Need a Front End DeveloperWhy You Need a Front End Developer
Why You Need a Front End Developer
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
The Fight Over HTML5
The Fight Over HTML5The Fight Over HTML5
The Fight Over HTML5
 
How to get a Job as a Front End Developer
How to get a Job as a Front End DeveloperHow to get a Job as a Front End Developer
How to get a Job as a Front End Developer
 
The History of HTML5
The History of HTML5The History of HTML5
The History of HTML5
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 

A Conversation About REST

  • 1. A Conversation About REST Jeremy Brown notmessenger.com
  • 2. What is an API?
  • 3. What is an API? From Wikipedia: An application programming interface (API) is a particular set of rules and specifications that a software program can follow to access and make use of the services and resources provided by another software program that implements the API.
  • 4. What is an API? Wikipedia continues: It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans and computers.
  • 5. What is an API? Our understanding: Set of rules and specifications to facilitate the interaction between different software programs.
  • 7. Types of APIs XML-RPC (1998) SOAP (1998, 2003) JSON-RPC (2005) REST (2000)
  • 8. XML-RPC xmlrpc.com It’s remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned.
  • 9. XML-RPC xmlrpc.com also says: We wanted a clean, extensible format that’s very simple. It should be possible for an HTML coder to be able to look at a file containing an XML-RPC call, understand what it’s doing, and be able to modify it and have it work on the first or second try... We also wanted it to be an easy protocol that could quickly be adapted to run in other environments or on other operating systems.
  • 10. XML-RPC Sample Request: <?xml version="1.0"?> <methodCall> <methodName>getStateName</methodName> <params> <param> <value><int>40</int></value> </param> </params> </methodCall>
  • 11. XML-RPC Sample Request: <?xml version="1.0"?> <methodCall> <methodName>getStateName</methodName> <params> <param> <value><int>40</int></value> </param> </params> </methodCall> Sample Response: <?xml version="1.0"?> <methodResponse> <params> <param> <value><string>South Dakota</string></value> </param> </params> </methodResponse>
  • 12. SOAP SOAP spec: SOAP is a lightweight protocol for exchange of information in a decentralized, distributed environment. It is an XML based protocol that consists of three parts: an envelope that defines a framework for describing what is in a message and how to process it, a set of encoding rules for expressing instances of application-defined datatypes, and a convention for representing remote procedure calls and responses.
  • 13. SOAP Sample Request: POST /InStock HTTP/1.1 Host: www.example.org Content-Type: application/soap+xml; charset=utf-8 Content-Length: 299 <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> <soap:Header> </soap:Header> <soap:Body> <m:GetStockPrice xmlns:m="http://www.example.org/stock"> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
  • 14. JSON-RPC Wikipedia says: JSON-RPC is a remote procedure call protocol encoded in JSON. It is a very simple protocol (and very similar to XML-RPC), defining only a handful of data types and commands.
  • 15. JSON-RPC Sample Request: { "version": "1.1", "method": "confirmFruitPurchase", "id": "194521489", "params": [ [ "apple", "orange", "pear" ], 1.123 ] } { "version": "1.1", "result": "done", "error": null, "id": "194521489" }
  • 16. JSON-RPC Sample Request: { "version": "1.1", "method": "confirmFruitPurchase", "id": "194521489", "params": [ [ "apple", "orange", "pear" ], 1.123 ] } Sample Response: { "version": "1.1", "result": "done", "error": null, "id": "194521489" }
  • 19. Types of APIs XML-RPC SOAP Service Oriented JSON-RPC
  • 20. Types of APIs XML-RPC SOAP Service Oriented JSON-RPC REST Resource Oriented
  • 21. Types of APIs XML-RPC SOAP Service Oriented JSON-RPC REST Resource Oriented Service Oriented architectures are designed to call methods. REST transports resources.
  • 23. Guiding Principles Identification of resources Manipulation of resources through these representations Self-descriptive messages Hypermedia as the Engine of Application State (HATEOAS)
  • 24. Identification of resources Individual resources are identified in requests, for example using URIs in web- based REST systems
  • 25. Identification of resources Individual resources are identified in requests, for example using URIs in web- based REST systems http://api.myapi.com/articles
  • 26. Identification of resources Individual resources are identified in requests, for example using URIs in web- based REST systems http://api.myapi.com/articles http://api.myapi.com/article/12
  • 27. Identification of resources Individual resources are identified in requests, for example using URIs in web- based REST systems http://api.myapi.com/articles http://api.myapi.com/article/12 http://api.myapi.com/customer/4/order/18
  • 29. Manipulation of resources GET Return representation of the resource requested
  • 30. Manipulation of resources GET Return representation of the resource requested PUT Replace representation with new representation, or create if does not exist
  • 32. Manipulation of resources POST Create a new resource
  • 33. Manipulation of resources POST Create a new resource DELETE Delete the resource
  • 34. Self-descriptive messages Each message includes enough information to describe how to process the message For example, the specification of media type through the use of the Content-Type header
  • 35. Self-descriptive messages Each message includes enough information to describe how to process the message For example, the specification of media type through the use of the Content-Type header Content-Type: image/jpeg
  • 36. Self-descriptive messages Each message includes enough information to describe how to process the message For example, the specification of media type through the use of the Content-Type header Content-Type: image/jpeg <radius>2</radius> Content-Type: application/xml <unit>inches</unit>
  • 37. Self-descriptive messages Another example are the Response Codes: 200 Okay 413 Request Entity Too Large 201 Created 415 Unsupported Media Type 303 See Other 416 Requested Range Not Satisfiable 401 Unauthorized 501 Not Implemented 404 Not Found many others
  • 39. HATEOAS Just like with HTTP, there is no maintenance of application state.
  • 40. HATEOAS Just like with HTTP, there is no maintenance of application state. Cookies are bad! Very, very bad!!
  • 41. HATEOAS Just like with HTTP, there is no maintenance of application state. Cookies are bad! Very, very bad!! Related URIs should be included in representations of resources.
  • 42.
  • 44. Other ways to interact with a REST service
  • 45. Other ways to interact with a REST service OPTIONS Discover which methods of manipulation are available for specified resource
  • 46. Other ways to interact with a REST service OPTIONS Discover which methods of manipulation are available for specified resource HEAD Get sample of Response header without data payload
  • 48. REST is a set of principles and not a specification
  • 49. Allow for differing Accept and Content-Type values Content-Type: application/xml Accept: text/javascript
  • 51. Thank You Jeremy Brown notmessenger.com

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. SOAP - 2003: W3C recommendation submitted. Is NOT a spec.\n
  7. \n
  8. \n
  9. \n
  10. \n
  11. Can be used over SMTP and other protocols because of its design.\n\nIs NOT lightweight.\n\nNothing works out of the box - ever.\n
  12. \n
  13. \n
  14. Required Methods\n\nREQUEST:\n method\n id\n params\n\nRESPONSE:\n result\n error\n id\n
  15. \n
  16. \n
  17. \n
  18. \n
  19. Roy Fielding\n\nCo-authored HTTP 1.0 and 1.1 spec\n\nREST was designed along side HTTP 1.1\n
  20. \n
  21. 1st one: talk about collections\n\n3rd one: talk about customer/order vs order/customer\n
  22. 1st one: talk about collections\n\n3rd one: talk about customer/order vs order/customer\n
  23. 1st one: talk about collections\n\n3rd one: talk about customer/order vs order/customer\n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. Statler and Waldorf\n
  36. Statler and Waldorf\n
  37. \n
  38. \n
  39. \n
  40. Remember PUT? Not all APIs create a new resource.\n
  41. \n
  42. \n
  43. \n