SlideShare a Scribd company logo
1 of 61
Download to read offline
Ben Ramsey • Zend/PHP Conference & Expo • 4 Nov 2010
Grokking REST
What is REST?
#webdevgangsign
Representational State Transfer
Client-server
Stateless
Cache
Uniform Interface
Layered System
Code-on-demand
RESTful Concepts
Resources & URLs
URLs do not matter
Using URLs as interfaces
creates tight coupling
between the client & server
http://api.example.org/user/getUser?u=ramsey
Using URL templates creates
tight coupling between the
client & server
http://api.example.org/user/{username}/photos
Your hypermedia format
should expose the URLs that
represent your resources
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"
xml:base="http://atom.example.org/">
<title>ramsey</title>
<author>
<name>ramsey</name>
</author>
<link rel="self" href="user/ramsey"/>
<link rel="edit" type="application/atom+xml;type=entry"
href="user/ramsey"/>
<link rel="related" href="user/ramsey/content"/>
<id>tag:example.org,2008:user/ramsey</id>
<updated>2009-09-21T13:45:00Z</updated>
<published>2008-05-23T16:23:34Z</published>
<content type="xhtml">
<div class="vcard" xmlns="http://www.w3.org/1999/xhtml">
<a class="fn">Ben Ramsey</a>
<span class="tel">123-456-7890</span>
</div>
</content>
</entry>
Hypermedia
application/json
{
"id": "756315701",
"name": "Ben Ramsey",
"first_name": "Ben",
"last_name": "Ramsey",
"link": "http://www.facebook.com/ramseyben",
"gender": "male",
"locale": "en_US"
}
Hypermedia?
No.
application/facebook+json;
type=user
application/xml
<?xml version="1.0" encoding="utf-8"?>
<user>
<id>756315701</id>
<name>Ben Ramsey</name>
<first_name>Ben</first_name>
<last_name>Ramsey</last_name>
<link>http://www.facebook.com/ramseyben</link>
<gender>male</gender>
<locale>en_US</locale>
</user>
Hypermedia?
No.
application/facebook+xml;
type=user
application/xhtml+xml
Hypermedia?
Yes!
application/atom+xml
Hypermedia?
Yes!
HATEOAS
Grokking REST • Ben Ramsey
‣How does a client know what to do with resources?
‣How do you go to the “next” operation?
‣What are the URLs for creating subordinate resources?
‣Where is the contract for the service?
41
Grokking REST • Ben Ramsey
Hypermedia as the Engine of Application
State (HATEOAS)
‣Use links to allow clients to discover locations and operations
‣Link relations are used to express the possible options
‣Clients do not need to know URLs, so they can change
‣The entire application workflow is abstracted, thus changeable
‣The hypermedia type itself can be versioned if necessary
‣No breaking of clients if the implementation is updated!
42
Why is REST so great?
REST scales
It’s extensible
It’s evolvable
Grokking REST • Ben Ramsey
Accept: application/vnd.myservice+xml;version=2
Use this style for versioning
47
Grokking REST • Ben Ramsey
http://api.example.org/v2/foo
Not this style
48
Grokking REST • Ben Ramsey
Accept:
application/vnd.mytype+xml;version=1;q=0.5,
application/vnd.myservice+xml;version=2
Clients can specify preferences
49
It’s seamless
Atom
Entry Document
application/atom+xml;type=entry
Feed/Collection Document
application/atom+xml
Category Document
application/atomcat+xml
Service Document
application/atomsvc+xml
GET	
  /	
  HTTP/1.1
Host:	
  atom.example.org
Accept:	
  application/atomsvc+xml,	
  application/atomcat+xml,	
  application/atom+xml
HTTP/1.x	
  200	
  OK
Date:	
  Mon,	
  21	
  Sep	
  2009	
  16:33:45	
  GMT
Content-­‐Type:	
  application/atomsvc+xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>
<service	
  xmlns="http://www.w3.org/2007/app"
	
  	
  	
  	
  	
  	
  	
  	
  	
  xmlns:atom="http://www.w3.org/2005/Atom"
	
  	
  	
  	
  	
  	
  	
  	
  	
  xml:base="http://atom.example.org/">
	
  <workspace>
	
  	
  <atom:title>Our	
  Content	
  Store</atom:title>
	
  	
  <collection	
  href="user">
	
  	
  	
  <atom:title>Users</atom:title>
	
  	
  	
  <accept>application/atom+xml;type=entry</accept>
	
  	
  	
  <categories	
  href="cat/user"/>
	
  	
  </collection>
	
  	
  <collection	
  href="content">
	
  	
  	
  <atom:title>Content</atom:title>
	
  	
  	
  <accept>application/atom+xml;type=entry</accept>
	
  	
  	
  <categories	
  href="cat/content"/>
	
  	
  </collection>
	
  </workspace>
</service>
GET	
  /user	
  HTTP/1.1
Host:	
  atom.example.org
Accept:	
  application/atom+xml
HTTP/1.x	
  200	
  OK
Date:	
  Mon,	
  21	
  Sep	
  2009	
  16:34:26	
  GMT
Content-­‐Type:	
  application/atom+xml
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>
<feed	
  xmlns="http://www.w3.org/2005/Atom"
	
  	
  	
  	
  	
  	
  xmlns:app="http://www.w3.org/2007/app"
	
  	
  	
  	
  	
  	
  xml:base="http://atom.example.org/">
	
  <title>Users</title>
	
  <updated>2009-­‐09-­‐21T05:21:19Z</updated>
	
  <id>tag:example.org,2009-­‐09:user</id>
	
  <app:collection	
  href="user">
	
  	
  <title>Users</title>
	
  	
  <app:accept>application/atom+xml;type=entry</app:accept>
	
  	
  <app:categories	
  href="cat/user"/>
	
  </app:collection>
	
  <link	
  rel="first"	
  href="user"/>
	
  <link	
  rel="last"	
  href="user?p=23"/>
	
  <link	
  rel="next"	
  href="user?p=2"/>
	
  <entry>
	
  	
  ...
	
  </entry>
</feed>
GET	
  /cat/user	
  HTTP/1.1
Host:	
  atom.example.org
Accept:	
  application/atomcat+xml
HTTP/1.x	
  200	
  OK
Date:	
  Mon,	
  22	
  Sep	
  2009	
  09:39:26	
  GMT
Content-­‐Type:	
  application/atomcat+xml
<?xml	
  version="1.0"?>
<app:categories	
  
	
  	
  xmlns:app="http://www.w3.org/2007/app"
	
  	
  xmlns:atom="http://www.w3.org/2005/Atom"
	
  	
  fixed="yes"	
  
	
  	
  scheme="http://atom.example.com/cat/user">
	
  <atom:category	
  term="manager"/>
	
  <atom:category	
  term="team"/>
	
  <atom:category	
  term="user"/>
</app:categories>
POST	
  /user	
  HTTP/1.1
Host:	
  atom.example.org
Content-­‐Type:	
  application/atom+xml;type=entry
<?xml	
  version="1.0"	
  encoding="utf-­‐8"?>
<entry	
  xmlns="http://www.w3.org/2005/Atom"
	
  	
  	
  	
  	
  	
  	
  xml:base="http://atom.example.org/">
	
  <title>ramsey</title>
	
  <author>
	
  	
  <name>ramsey</name>
	
  </author>
	
  <id>tag:example.org,2008:user/ramsey</id>
	
  <published>2008-­‐05-­‐23T16:23:34Z</published>
	
  <content	
  type="xhtml">
	
  	
  	
  <div	
  class="vcard"	
  xmlns="http://www.w3.org/1999/xhtml">
	
  	
  	
  	
  <a	
  class="fn">Ben	
  Ramsey</a>
	
  	
  	
  	
  <span	
  class="tel">123-­‐456-­‐7890</span>
	
  	
  	
  </div>
	
  </content>
</entry>
HTTP/1.x	
  201	
  Created
Date:	
  Mon,	
  22	
  Sep	
  2009	
  09:39:26	
  GMT
Location:	
  http://atom.example.org/user/ramsey
Content-­‐Type:	
  text/html
<html>
<body>
	
  	
  <p>Your	
  new	
  resource	
  was	
  created	
  
	
  	
  	
  	
  <a	
  href="http://atom.example.org/user/ramsey">here</a>.</p>
</body>
</html>
Bringing it all together…
Grokking REST • Ben Ramsey
Questions?
‣I blog at benramsey.com.
‣I tweet at @ramsey.
‣Please rate this presentation at joind.in/2284.
‣Find out more about REST by reading Architectural Styles and the
Design of Network-based Software Architectures and “How I Explained
REST to my Wife.”
‣My company is Moontoast. Check us out at moontoast.com. Follow us
on Twitter and like us on Facebook.
58
Grokking REST
Copyright © 2010 Ben Ramsey. Some rights reserved.
Presented on November 4, 2010 at Zend/PHP Conference
and Expo, Hyatt Regency Hotel, Santa Clara, CA.
This work is licensed under a Creative Commons Attribution-
Noncommercial-No Derivative Works 3.0 United States
License.
For uses not covered under this license, please contact the
author.
Grokking REST • Ben Ramsey
Photo Credits
‣ Restful Summer, by Clear Inner Vision
‣ Roatan Beach - Perfect Day, by Janusz
Leszczynski
‣ Tom Coates, by Patrick Lauke
‣ Web Developer Gang Sign, by Josh Lewis
‣ A Bar of Ivory Soap, by iirraa
‣ Albert Einstein, Public Domain, from
Wikimedia Commons
‣ Separated, by Hansol Lee
‣ Stateless by Koesmanto Bong
‣ Cache County, Utah by J. Stephen Conn
‣ used to interface, by Tom Hensel
‣ Sedimentary Layers by Mark Thurman
‣ jeremy’s tie by Gitchel
‣ Sand Banks Sunset, by Clear Inner Vision
‣ Where I Teach, by Todd Ehlers
‣ Frosted Glass door, Goderham Building, by
Rick Innis
‣ Drip Drops and the Spider Web, by Mike
Bitzenhofer
‣ #110 Hypertext Transfer Protocol, by maako
‣ Before we had CAD, we had Lead!, by
Wendell
60
Grokking REST • Ben Ramsey
Photo Credits
‣ Molecule display, by Christian Guthier
‣ Conclusion, by Mark Cummins
61

More Related Content

What's hot

JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!Evan Mullins
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so goodChris Love
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web ServicesGreg Hines
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Nicholas Zakas
 
Have You Seen Spring Lately?
Have You Seen Spring Lately?Have You Seen Spring Lately?
Have You Seen Spring Lately?Joshua Long
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 
HTML5 WebSocket for the Real-Time Web and the Internet of Things
HTML5 WebSocket for the Real-Time Weband the Internet of ThingsHTML5 WebSocket for the Real-Time Weband the Internet of Things
HTML5 WebSocket for the Real-Time Web and the Internet of ThingsPeter Moskovits
 
What's new in Spring 3?
What's new in Spring 3?What's new in Spring 3?
What's new in Spring 3?Craig Walls
 
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...Peter Moskovits
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web DesignChristopher Schmitt
 
Web Performance 101
Web Performance 101Web Performance 101
Web Performance 101Uri Lavi
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceAllFacebook.de
 
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...David Kaneda
 
Maine WordPress Meetup JSON REST API, 3/16/2016
Maine WordPress Meetup JSON REST API, 3/16/2016Maine WordPress Meetup JSON REST API, 3/16/2016
Maine WordPress Meetup JSON REST API, 3/16/2016Andre Gagnon
 
The internet for SEOs by Roxana Stingu
The internet for SEOs by Roxana StinguThe internet for SEOs by Roxana Stingu
The internet for SEOs by Roxana StinguRoxana Stingu
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsChris Love
 

What's hot (20)

Putting SOAP to REST
Putting SOAP to RESTPutting SOAP to REST
Putting SOAP to REST
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
WordCamp Birmingham 2016 - WP API, What is it good for? Absolutely Everything!
 
Service workers your applications never felt so good
Service workers   your applications never felt so goodService workers   your applications never felt so good
Service workers your applications never felt so good
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)Progressive Enhancement 2.0 (Conference Agnostic)
Progressive Enhancement 2.0 (Conference Agnostic)
 
Have You Seen Spring Lately?
Have You Seen Spring Lately?Have You Seen Spring Lately?
Have You Seen Spring Lately?
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
SPDY
SPDYSPDY
SPDY
 
HTML5 WebSocket for the Real-Time Web and the Internet of Things
HTML5 WebSocket for the Real-Time Weband the Internet of ThingsHTML5 WebSocket for the Real-Time Weband the Internet of Things
HTML5 WebSocket for the Real-Time Web and the Internet of Things
 
What's new in Spring 3?
What's new in Spring 3?What's new in Spring 3?
What's new in Spring 3?
 
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
 
[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
 
Web Performance 101
Web Performance 101Web Performance 101
Web Performance 101
 
WebApp #3 : API
WebApp #3 : APIWebApp #3 : API
WebApp #3 : API
 
WebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer ConferenceWebApp / SPA @ AllFacebook Developer Conference
WebApp / SPA @ AllFacebook Developer Conference
 
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
How to Develop a Rich, Native-quality User Experience for Mobile Using Web St...
 
Maine WordPress Meetup JSON REST API, 3/16/2016
Maine WordPress Meetup JSON REST API, 3/16/2016Maine WordPress Meetup JSON REST API, 3/16/2016
Maine WordPress Meetup JSON REST API, 3/16/2016
 
The internet for SEOs by Roxana Stingu
The internet for SEOs by Roxana StinguThe internet for SEOs by Roxana Stingu
The internet for SEOs by Roxana Stingu
 
Disrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applicationsDisrupting the application eco system with progressive web applications
Disrupting the application eco system with progressive web applications
 

Viewers also liked (18)

KMS Vision Convergence Workshop Proceeding
KMS Vision Convergence Workshop ProceedingKMS Vision Convergence Workshop Proceeding
KMS Vision Convergence Workshop Proceeding
 
Embraer 20-F Portugues 2012
Embraer 20-F Portugues 2012Embraer 20-F Portugues 2012
Embraer 20-F Portugues 2012
 
Cohabitat Gathering 2011
Cohabitat Gathering 2011Cohabitat Gathering 2011
Cohabitat Gathering 2011
 
The Social Media E..E..Edge
The Social Media E..E..EdgeThe Social Media E..E..Edge
The Social Media E..E..Edge
 
Qt for developers alebo súčasnosť a budúcnosť vývoja aplikácií pre telefóny N...
Qt for developers alebo súčasnosť a budúcnosť vývoja aplikácií pre telefóny N...Qt for developers alebo súčasnosť a budúcnosť vývoja aplikácií pre telefóny N...
Qt for developers alebo súčasnosť a budúcnosť vývoja aplikácií pre telefóny N...
 
Nutter
NutterNutter
Nutter
 
Se Rg@Vf^ F Fo
Se  Rg@Vf^ F FoSe  Rg@Vf^ F Fo
Se Rg@Vf^ F Fo
 
Song Book
Song BookSong Book
Song Book
 
JavaMagazine - Java SE 8 - 2014-03-04
JavaMagazine - Java SE 8 - 2014-03-04JavaMagazine - Java SE 8 - 2014-03-04
JavaMagazine - Java SE 8 - 2014-03-04
 
AIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge ShareAIX Advanced Administration Knowledge Share
AIX Advanced Administration Knowledge Share
 
Open Access in Latin America
Open Access in Latin AmericaOpen Access in Latin America
Open Access in Latin America
 
Icici bank
Icici bankIcici bank
Icici bank
 
4000 auto approve wordpress blogs backlink list (pr8-pr1)
4000 auto approve wordpress blogs backlink list (pr8-pr1)4000 auto approve wordpress blogs backlink list (pr8-pr1)
4000 auto approve wordpress blogs backlink list (pr8-pr1)
 
Citibank
CitibankCitibank
Citibank
 
puzzle
puzzlepuzzle
puzzle
 
A Comparison of Cloud based ERP Systems
A Comparison of Cloud based ERP SystemsA Comparison of Cloud based ERP Systems
A Comparison of Cloud based ERP Systems
 
Comments (1)
Comments (1)Comments (1)
Comments (1)
 
Nigerian scam
Nigerian scamNigerian scam
Nigerian scam
 

Similar to Grokking REST (ZendCon 2010)

The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTBruno Kessler Foundation
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesPaul Fremantle
 
Introduction to AtomPub Web Services
Introduction to AtomPub Web ServicesIntroduction to AtomPub Web Services
Introduction to AtomPub Web ServicesBen Ramsey
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-servicesrporwal
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web ServicesAngelin R
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011Alessandro Nadalin
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)Paul James
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsBastian Hofmann
 
The Evolving Security Environment For Web Services
The Evolving Security Environment For Web ServicesThe Evolving Security Environment For Web Services
The Evolving Security Environment For Web ServicesQanita Ahmad
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!Ben Ramsey
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APISHAKIL AKHTAR
 

Similar to Grokking REST (ZendCon 2010) (20)

REST Presentation
REST PresentationREST Presentation
REST Presentation
 
The Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReSTThe Internet as Web Services: introduction to ReST
The Internet as Web Services: introduction to ReST
 
REST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and LiesREST vs WS-*: Myths Facts and Lies
REST vs WS-*: Myths Facts and Lies
 
Introduction to AtomPub Web Services
Introduction to AtomPub Web ServicesIntroduction to AtomPub Web Services
Introduction to AtomPub Web Services
 
Modified REST Presentation
Modified REST PresentationModified REST Presentation
Modified REST Presentation
 
Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
Web Services
Web ServicesWeb Services
Web Services
 
Restful Web Services
Restful Web ServicesRestful Web Services
Restful Web Services
 
Restful webservices
Restful webservicesRestful webservices
Restful webservices
 
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011REST in ( a mobile ) peace @ WHYMCA 05-21-2011
REST in ( a mobile ) peace @ WHYMCA 05-21-2011
 
REST Introduction (PHP London)
REST Introduction (PHP London)REST Introduction (PHP London)
REST Introduction (PHP London)
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
Opening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the IslandsOpening up the Social Web - Standards that are bridging the Islands
Opening up the Social Web - Standards that are bridging the Islands
 
Introduction To REST
Introduction To RESTIntroduction To REST
Introduction To REST
 
The Evolving Security Environment For Web Services
The Evolving Security Environment For Web ServicesThe Evolving Security Environment For Web Services
The Evolving Security Environment For Web Services
 
Web services - REST and SOAP
Web services - REST and SOAPWeb services - REST and SOAP
Web services - REST and SOAP
 
You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!You Look Like You Could Use Some REST!
You Look Like You Could Use Some REST!
 
Jax Ajax Architecture
Jax Ajax  ArchitectureJax Ajax  Architecture
Jax Ajax Architecture
 
Architecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web APIArchitecting &Building Scalable Secure Web API
Architecting &Building Scalable Secure Web API
 
Sinatra
SinatraSinatra
Sinatra
 

More from Ben Ramsey

Api Versioning
Api VersioningApi Versioning
Api VersioningBen Ramsey
 
Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Ben Ramsey
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APCBen Ramsey
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumBen Ramsey
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheBen Ramsey
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTPBen Ramsey
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural StyleBen Ramsey
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsBen Ramsey
 
Around the PHP Community
Around the PHP CommunityAround the PHP Community
Around the PHP CommunityBen Ramsey
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesBen Ramsey
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesBen Ramsey
 

More from Ben Ramsey (11)

Api Versioning
Api VersioningApi Versioning
Api Versioning
 
Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)Desktop Apps with PHP and Titanium (ZendCon 2010)
Desktop Apps with PHP and Titanium (ZendCon 2010)
 
Caching with Memcached and APC
Caching with Memcached and APCCaching with Memcached and APC
Caching with Memcached and APC
 
Desktop Apps with PHP and Titanium
Desktop Apps with PHP and TitaniumDesktop Apps with PHP and Titanium
Desktop Apps with PHP and Titanium
 
Give Your Site a Boost with Memcache
Give Your Site a Boost with MemcacheGive Your Site a Boost with Memcache
Give Your Site a Boost with Memcache
 
Hidden Gems in HTTP
Hidden Gems in HTTPHidden Gems in HTTP
Hidden Gems in HTTP
 
Grokking the REST Architectural Style
Grokking the REST Architectural StyleGrokking the REST Architectural Style
Grokking the REST Architectural Style
 
Making the Most of HTTP In Your Apps
Making the Most of HTTP In Your AppsMaking the Most of HTTP In Your Apps
Making the Most of HTTP In Your Apps
 
Around the PHP Community
Around the PHP CommunityAround the PHP Community
Around the PHP Community
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web Services
 
Distribution and Publication With Atom Web Services
Distribution and Publication With Atom Web ServicesDistribution and Publication With Atom Web Services
Distribution and Publication With Atom Web Services
 

Recently uploaded

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 productivityPrincipled Technologies
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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 textsMaria Levchenko
 
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 AutomationSafe Software
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
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...apidays
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
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...Miguel Araújo
 
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 Takeoffsammart93
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 

Recently uploaded (20)

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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
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...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
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...
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 

Grokking REST (ZendCon 2010)

  • 1. Ben Ramsey • Zend/PHP Conference & Expo • 4 Nov 2010 Grokking REST
  • 3.
  • 5.
  • 15. URLs do not matter
  • 16.
  • 17. Using URLs as interfaces creates tight coupling between the client & server
  • 19. Using URL templates creates tight coupling between the client & server
  • 21. Your hypermedia format should expose the URLs that represent your resources
  • 22. <?xml version="1.0" encoding="utf-8"?> <entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://atom.example.org/"> <title>ramsey</title> <author> <name>ramsey</name> </author> <link rel="self" href="user/ramsey"/> <link rel="edit" type="application/atom+xml;type=entry" href="user/ramsey"/> <link rel="related" href="user/ramsey/content"/> <id>tag:example.org,2008:user/ramsey</id> <updated>2009-09-21T13:45:00Z</updated> <published>2008-05-23T16:23:34Z</published> <content type="xhtml"> <div class="vcard" xmlns="http://www.w3.org/1999/xhtml"> <a class="fn">Ben Ramsey</a> <span class="tel">123-456-7890</span> </div> </content> </entry>
  • 25. { "id": "756315701", "name": "Ben Ramsey", "first_name": "Ben", "last_name": "Ramsey", "link": "http://www.facebook.com/ramseyben", "gender": "male", "locale": "en_US" }
  • 27. No.
  • 30. <?xml version="1.0" encoding="utf-8"?> <user> <id>756315701</id> <name>Ben Ramsey</name> <first_name>Ben</first_name> <last_name>Ramsey</last_name> <link>http://www.facebook.com/ramseyben</link> <gender>male</gender> <locale>en_US</locale> </user>
  • 32. No.
  • 36. Yes!
  • 39. Yes!
  • 41. Grokking REST • Ben Ramsey ‣How does a client know what to do with resources? ‣How do you go to the “next” operation? ‣What are the URLs for creating subordinate resources? ‣Where is the contract for the service? 41
  • 42. Grokking REST • Ben Ramsey Hypermedia as the Engine of Application State (HATEOAS) ‣Use links to allow clients to discover locations and operations ‣Link relations are used to express the possible options ‣Clients do not need to know URLs, so they can change ‣The entire application workflow is abstracted, thus changeable ‣The hypermedia type itself can be versioned if necessary ‣No breaking of clients if the implementation is updated! 42
  • 43. Why is REST so great?
  • 47. Grokking REST • Ben Ramsey Accept: application/vnd.myservice+xml;version=2 Use this style for versioning 47
  • 48. Grokking REST • Ben Ramsey http://api.example.org/v2/foo Not this style 48
  • 49. Grokking REST • Ben Ramsey Accept: application/vnd.mytype+xml;version=1;q=0.5, application/vnd.myservice+xml;version=2 Clients can specify preferences 49
  • 51. Atom
  • 52. Entry Document application/atom+xml;type=entry Feed/Collection Document application/atom+xml Category Document application/atomcat+xml Service Document application/atomsvc+xml
  • 53. GET  /  HTTP/1.1 Host:  atom.example.org Accept:  application/atomsvc+xml,  application/atomcat+xml,  application/atom+xml HTTP/1.x  200  OK Date:  Mon,  21  Sep  2009  16:33:45  GMT Content-­‐Type:  application/atomsvc+xml <?xml  version="1.0"  encoding="utf-­‐8"?> <service  xmlns="http://www.w3.org/2007/app"                  xmlns:atom="http://www.w3.org/2005/Atom"                  xml:base="http://atom.example.org/">  <workspace>    <atom:title>Our  Content  Store</atom:title>    <collection  href="user">      <atom:title>Users</atom:title>      <accept>application/atom+xml;type=entry</accept>      <categories  href="cat/user"/>    </collection>    <collection  href="content">      <atom:title>Content</atom:title>      <accept>application/atom+xml;type=entry</accept>      <categories  href="cat/content"/>    </collection>  </workspace> </service>
  • 54. GET  /user  HTTP/1.1 Host:  atom.example.org Accept:  application/atom+xml HTTP/1.x  200  OK Date:  Mon,  21  Sep  2009  16:34:26  GMT Content-­‐Type:  application/atom+xml <?xml  version="1.0"  encoding="utf-­‐8"?> <feed  xmlns="http://www.w3.org/2005/Atom"            xmlns:app="http://www.w3.org/2007/app"            xml:base="http://atom.example.org/">  <title>Users</title>  <updated>2009-­‐09-­‐21T05:21:19Z</updated>  <id>tag:example.org,2009-­‐09:user</id>  <app:collection  href="user">    <title>Users</title>    <app:accept>application/atom+xml;type=entry</app:accept>    <app:categories  href="cat/user"/>  </app:collection>  <link  rel="first"  href="user"/>  <link  rel="last"  href="user?p=23"/>  <link  rel="next"  href="user?p=2"/>  <entry>    ...  </entry> </feed>
  • 55. GET  /cat/user  HTTP/1.1 Host:  atom.example.org Accept:  application/atomcat+xml HTTP/1.x  200  OK Date:  Mon,  22  Sep  2009  09:39:26  GMT Content-­‐Type:  application/atomcat+xml <?xml  version="1.0"?> <app:categories      xmlns:app="http://www.w3.org/2007/app"    xmlns:atom="http://www.w3.org/2005/Atom"    fixed="yes"      scheme="http://atom.example.com/cat/user">  <atom:category  term="manager"/>  <atom:category  term="team"/>  <atom:category  term="user"/> </app:categories>
  • 56. POST  /user  HTTP/1.1 Host:  atom.example.org Content-­‐Type:  application/atom+xml;type=entry <?xml  version="1.0"  encoding="utf-­‐8"?> <entry  xmlns="http://www.w3.org/2005/Atom"              xml:base="http://atom.example.org/">  <title>ramsey</title>  <author>    <name>ramsey</name>  </author>  <id>tag:example.org,2008:user/ramsey</id>  <published>2008-­‐05-­‐23T16:23:34Z</published>  <content  type="xhtml">      <div  class="vcard"  xmlns="http://www.w3.org/1999/xhtml">        <a  class="fn">Ben  Ramsey</a>        <span  class="tel">123-­‐456-­‐7890</span>      </div>  </content> </entry> HTTP/1.x  201  Created Date:  Mon,  22  Sep  2009  09:39:26  GMT Location:  http://atom.example.org/user/ramsey Content-­‐Type:  text/html <html> <body>    <p>Your  new  resource  was  created          <a  href="http://atom.example.org/user/ramsey">here</a>.</p> </body> </html>
  • 57. Bringing it all together…
  • 58. Grokking REST • Ben Ramsey Questions? ‣I blog at benramsey.com. ‣I tweet at @ramsey. ‣Please rate this presentation at joind.in/2284. ‣Find out more about REST by reading Architectural Styles and the Design of Network-based Software Architectures and “How I Explained REST to my Wife.” ‣My company is Moontoast. Check us out at moontoast.com. Follow us on Twitter and like us on Facebook. 58
  • 59. Grokking REST Copyright © 2010 Ben Ramsey. Some rights reserved. Presented on November 4, 2010 at Zend/PHP Conference and Expo, Hyatt Regency Hotel, Santa Clara, CA. This work is licensed under a Creative Commons Attribution- Noncommercial-No Derivative Works 3.0 United States License. For uses not covered under this license, please contact the author.
  • 60. Grokking REST • Ben Ramsey Photo Credits ‣ Restful Summer, by Clear Inner Vision ‣ Roatan Beach - Perfect Day, by Janusz Leszczynski ‣ Tom Coates, by Patrick Lauke ‣ Web Developer Gang Sign, by Josh Lewis ‣ A Bar of Ivory Soap, by iirraa ‣ Albert Einstein, Public Domain, from Wikimedia Commons ‣ Separated, by Hansol Lee ‣ Stateless by Koesmanto Bong ‣ Cache County, Utah by J. Stephen Conn ‣ used to interface, by Tom Hensel ‣ Sedimentary Layers by Mark Thurman ‣ jeremy’s tie by Gitchel ‣ Sand Banks Sunset, by Clear Inner Vision ‣ Where I Teach, by Todd Ehlers ‣ Frosted Glass door, Goderham Building, by Rick Innis ‣ Drip Drops and the Spider Web, by Mike Bitzenhofer ‣ #110 Hypertext Transfer Protocol, by maako ‣ Before we had CAD, we had Lead!, by Wendell 60
  • 61. Grokking REST • Ben Ramsey Photo Credits ‣ Molecule display, by Christian Guthier ‣ Conclusion, by Mark Cummins 61