SlideShare une entreprise Scribd logo
1  sur  41
Télécharger pour lire hors ligne
REST and REST-fulness
David Waite
Ping Labs

!1

Copyright ©2012 Ping Identity Corporation. All rights reserved.
REST VS SOAP

!2

Copyright ©2012 Ping Identity Corporation. All rights reserved.
REST vs SOAP?

• REST is a network data architecture for
hypermedia systems
• SOAP is a XML-based message format
• SOA is a software design and deployment
pattern
!

• Often people say REST to imply a RESTinfluenced API design (RESTful API)
!3

Copyright ©2012 Ping Identity Corporation. All rights reserved.
OK then, REST vs SOA

• REST and SOA are not mutually
exclusive
– REST abstracts network elements within a
distributed hypermedia system
– SOA is the idea of having a decentralized
system by having components which supply
services to other services

!4

Copyright ©2012 Ping Identity Corporation. All rights reserved.
The Mistakes of SOAP

• SOAP (Simple Object Access Protocol)
was defined as a protocol abstraction on
top of other protocol
– HTTP, SMTP, JMS

• Ignores many lower-level protocol features
• Reimplements them on top of its own
protocol
• Uses XML for Object representation
!5

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML VS JSON

!6

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• XML was designed as a reusable
simplification of SGML in 1999
– Standard Generalized Markup Language
– XML could be said to be a language divided
between two camps, people defining:
– markup languages for documents
• HTML, SVG, MathML

– interoperable data serialization

!7

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• The initial influencers were almost purely
document-oriented
– tools would not manipulate XML as data but
be written to manipulate particular documents

• XML has problems when representing
generic data
• XML APIs are notoriously tedious for
extracting data

!8

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• Short for JavaScript Object Notation
• JSON was first used as a data format in
2001 by Douglas Crockford
• First popular use was by Yahoo! in 2005,
Google in 2006
• Informational RFC describing the format
in 2006

!9

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• JSON is based on a subset of the Javascript
format used to define literal data structures
– Floating point numerics
– Booleans
– Strings
– Null
– Arrays
– Objects (Dictionaries/Maps)

!10

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• Original popularity was because of AJAX
Web sites like Gmail
• JSON format can be “eval”ed in JS
– probably should regex to make sure there
isn’t any code
– current browsers have a faster native JSON
parser built-in

!11

Copyright ©2012 Ping Identity Corporation. All rights reserved.
XML vs JSON

• Unlike XML, a native data format is defined
• containing most of the primitives you need
• But no native representation of:
– date/time
– integers (vs double-precision floats)
– binary streams
– namespaced data

• No (finished) schema language

!12

Copyright ©2012 Ping Identity Corporation. All rights reserved.
WHAT IS REST?

!13

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Roy Fielding

• A principal author of
the HTTP specification
• Contributor to Apache
HTTP Server
• Retconned “REST” as
the motivation for the
design of HTTP in his
doctorate dissertation

!14

Copyright ©2012 Ping Identity Corporation. All rights reserved.
What is REST

A set of six architectural constraints
1.
2.
3.
4.
5.
6.

!15

Client/Server
Stateless
Cacheable
Layered System
Uniform Interface
Code on Demand (optional)

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Client/Server

Separation of user interface and
data storage concerns
•
•
•
•

!16

Portability of user interface
Scalability of server components
Independent deployment
Independent evolution

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Stateless

Each request contains all needed
information to understand the
request
•
•
•
•

!17

session state is kept on the client
better recovery from failures
reduced server resource usage
scalability due to not needing manage state
between requests
Copyright ©2012 Ping Identity Corporation. All rights reserved.
Stateless Tradeoffs

• More traffic between client and server
• May need to integrity or confidentialityprotect data needed for future requests
• Greater negative impact to bad client
implementation

!18

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Cacheable

• Responses are required to be interpreted
as cacheable or non-cacheable
• Improves network efficiency
• Improve server efficiency by avoiding
response generation
• Improves client performance
• But, stale data may decrease reliability

!19

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Layered System

• System can be composed of hierarchical
layers
• Components can act as clients on one side
and servers on the other
• Clients and Servers both do not need to know
or do anything to support these components
• Reduces complexity of overall system
• Intermediaries can affect performance

!20

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Code on Demand

• Client side can be extended by downloading
code
– javascript, applets, flash

• Reduces features which need to be preimplemented
• But, affects visibility into what is happening
• Security ramifications
• Optional, may not be supported by some clients

!21

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Uniform Interface

• Generality to the client/server interface
(HTTP, HTML)
• Reusability
• Independent evolution
• But, degrades efficiency

!22

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Interface Constraints

• Four additional interface constraints:
!

1. Identification of Resources through URIs
2. Manipulation of Resources through
Representations
3. Self-Descriptive Messages
4. Hypermedia as the engine of application
state (HATEAOS)

!23

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Identification of Resources through URIs

• A request is meant to be targeted at a
particular resource
– via a Uniform Resource Identifier

• Independent from Representations of
the resource returned or accepted
– e.g., resource backed by database row
results in stylized HTML content

• Provides generality and late binding
!24

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Self-Descriptive Messages

• A request or response can contain data
and metadata
• Metadata is sufficient for processing data
– Content-Type
• text/html
• application/xml
• application/personrecord+json

• Also, caching is part of a response

!25

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Manipulation of Resources through Representations

• A representation of the resource
provides enough information to
manipulate resource
– Blog with comment form
– List of records with delete buttons
!

• URL of resource to client API?

!26

Copyright ©2012 Ping Identity Corporation. All rights reserved.
HATEAOS

Hypermedia as the engine of application state
!

• Web is a non-linear medium formed by
multimedia connected by hyperlinks
• Parties should not be assumed to
understand structure of resources in
order to be able to retrieve and
manipulate them
!27

Copyright ©2012 Ping Identity Corporation. All rights reserved.
RESTFUL API DESIGN

!28

Copyright ©2012 Ping Identity Corporation. All rights reserved.
RESTful API Design fundamentals

• Understand HTTP as an underlying
system
– HTTP Methods
– Content type selection
– Cacheability
– Safety and Idempotency of certain methods

!29

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Example: Rails RESTful Routes
resources	
  :photos
creates seven different routes in your application, all mapping to
the Photos controller:
resources	
  :photos

Verb
GET

Path
/photos

Action Used for
index display a list of all photos

GET

/photos/new

new

POST
GET

/photos
/photos/:id

create create a new photo
show display a specific photo

GET

/photos/:id/edit edit

PATCH/
/photos/:id
PUT
DELETE /photos/:id
!30

return HTML form to create a new photo

return an HTML form for editing a photo

update update a specific photo
destroy delete a specific photo
Copyright ©2012 Ping Identity Corporation. All rights reserved.
Example: Rails content type selection

class	
  UsersController	
  <	
  ApplicationController::Base	
  

!

	
  	
  respond_to	
  :html,	
  :xml,	
  :json	
  
!

	
  	
  def	
  index	
  
	
  	
  	
  	
  respond_with(@users	
  =	
  User.all)	
  
	
  	
  end	
  
end

!31

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Example: Rails Content Type Selection

GET	
  /users	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  HTML

GET	
  /users

Accepts:	
  application/json	
  #	
  JSON	
  


GET	
  /users.xml	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #	
  XML

!32

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Bad Examples

GET	
  /user/changeGender?gender=f

GET	
  /article/1/delete	
  
!

POST	
  /soap

SOAPAction:	
  urn:foo:SubmitTaxRecords

!33

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Cacheability

• As much of your API as possible should
be designed with the idea of cacheability
– Can I guarantee this data will be valid for a
certain period of time?
– Is there a significant impact if the data goes
invalid before the time I specified?
– How can I more easily check if data has
changed than generate a new response?
• HEAD vs GET

!34

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Relations
/articles	
  
Article

!

/articles/xyz	
  
Comment

User

!

/articles/xyz/comments	
  
Author

!

/users/dwaite

!35

Copyright ©2012 Ping Identity Corporation. All rights reserved.
HATEAOS

• Don’t couple site design and resource
locations to API design
• Lots of “Best Practice” and “Personal
Preference” choices

!36

Copyright ©2012 Ping Identity Corporation. All rights reserved.
HATEAOS example

#	
  Non-­‐HATEAOS	
  
GET	
  /users/dwaite	
  #	
  -­‐>	
  
{	
  

	
  	
  “fn”:	
  “Waite”,	
  

	
  	
  “gn”:	
  “David”,

	
  	
  groups:	
  

	
  	
  	
  	
  [“admin”,	
  “labs”,	
  “denver”]	
  

}

!37

Copyright ©2012 Ping Identity Corporation. All rights reserved.
HATEAOS example

#	
  HATEAOS	
  
GET	
  /users/dwaite	
  #	
  -­‐>	
  
{	
  

	
  	
  “fn”:	
  “Waite”,	
  

	
  	
  “gn”:	
  “David”,

	
  	
  groups:	
  

	
  	
  {

	
  	
  	
  “Administrator”:	
  “/groups/admin”,	
  

	
  	
  	
  “Ping	
  Labs”:	
  	
  	
  	
  	
  “/groups/pinglabs”,

	
  	
  	
  “Denver”:	
  	
  	
  	
  	
  	
  	
  	
  “/locations/Denver”

	
  	
  }

}

!38

Copyright ©2012 Ping Identity Corporation. All rights reserved.
Versioning

• Big design contention
– Minor version updates through data - add to
response, do not change or remove
– Major version update, indicate via
• new URL
• new media type / mime type
– application/user+json;version=1

• some header

– Require version to be specified?

!39

Copyright ©2012 Ping Identity Corporation. All rights reserved.
More Information

• http://en.wikipedia.org/wiki/
Representational_state_transfer
• http://www.stormpath.com/blog/
designing-rest-json-apis
• http://www.ics.uci.edu/~fielding/pubs/
dissertation/rest_arch_style.htm
• http://groups.google.com/group/api-craft

!40

Copyright ©2012 Ping Identity Corporation. All rights reserved.
One More Thing: Cookies

• Cookies are generally non-RESTful
– Against client/server and stateless
• client state on server
• server state on client

– Against caching
• Response containing cookies
• Response generated from request cookies

• Try to use HTTP-level auth (like OAuth2)

!41

Copyright ©2012 Ping Identity Corporation. All rights reserved.

Contenu connexe

Tendances

Making the Conceptual Layer Real via HTTP based Linked Data
Making the Conceptual Layer Real via HTTP based Linked DataMaking the Conceptual Layer Real via HTTP based Linked Data
Making the Conceptual Layer Real via HTTP based Linked DataKingsley Uyi Idehen
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - IntroductionJoel Briza
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service designRamin Orujov
 
OpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewOpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewKingsley Uyi Idehen
 
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNsExploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNsKingsley Uyi Idehen
 
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-endUsing Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-endKingsley Uyi Idehen
 
Virtuoso Universal Server Overview
Virtuoso Universal Server OverviewVirtuoso Universal Server Overview
Virtuoso Universal Server Overviewrumito
 
Virtuoso ODBC Driver Configuration & Usage (Windows)
Virtuoso ODBC Driver Configuration & Usage (Windows)Virtuoso ODBC Driver Configuration & Usage (Windows)
Virtuoso ODBC Driver Configuration & Usage (Windows)Kingsley Uyi Idehen
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to strutsAnup72
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service DesignLorna Mitchell
 
Amish Umesh - Future Of Web App Testing - ClubHack2007
Amish Umesh - Future Of Web App Testing  - ClubHack2007Amish Umesh - Future Of Web App Testing  - ClubHack2007
Amish Umesh - Future Of Web App Testing - ClubHack2007ClubHack
 
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7CA API Management
 
Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote
 Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote
Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference KeynoteKingsley Uyi Idehen
 
Tableau Desktop as a Linked (Open) Data Front-End via ODBC
Tableau Desktop as a Linked (Open) Data Front-End via ODBCTableau Desktop as a Linked (Open) Data Front-End via ODBC
Tableau Desktop as a Linked (Open) Data Front-End via ODBCKingsley Uyi Idehen
 
Understanding Linked Data via EAV Model based Structured Descriptions
Understanding Linked Data via EAV Model based Structured DescriptionsUnderstanding Linked Data via EAV Model based Structured Descriptions
Understanding Linked Data via EAV Model based Structured DescriptionsKingsley Uyi Idehen
 
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Brian Huff
 
Solving Real Problems Using Linked Data
Solving Real Problems Using Linked DataSolving Real Problems Using Linked Data
Solving Real Problems Using Linked Datarumito
 

Tendances (20)

Virtuoso Platform Overview
Virtuoso Platform OverviewVirtuoso Platform Overview
Virtuoso Platform Overview
 
REST in Practice
REST in PracticeREST in Practice
REST in Practice
 
Making the Conceptual Layer Real via HTTP based Linked Data
Making the Conceptual Layer Real via HTTP based Linked DataMaking the Conceptual Layer Real via HTTP based Linked Data
Making the Conceptual Layer Real via HTTP based Linked Data
 
Web programming and development - Introduction
Web programming and development - IntroductionWeb programming and development - Introduction
Web programming and development - Introduction
 
Best practices for RESTful web service design
Best practices for RESTful web service designBest practices for RESTful web service design
Best practices for RESTful web service design
 
OpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers OverviewOpenLink Virtuoso - Management & Decision Makers Overview
OpenLink Virtuoso - Management & Decision Makers Overview
 
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNsExploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
 
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-endUsing Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
 
Virtuoso Universal Server Overview
Virtuoso Universal Server OverviewVirtuoso Universal Server Overview
Virtuoso Universal Server Overview
 
Virtuoso ODBC Driver Configuration & Usage (Windows)
Virtuoso ODBC Driver Configuration & Usage (Windows)Virtuoso ODBC Driver Configuration & Usage (Windows)
Virtuoso ODBC Driver Configuration & Usage (Windows)
 
ISWC 2012 - Linked Data Meetup
ISWC 2012 - Linked Data MeetupISWC 2012 - Linked Data Meetup
ISWC 2012 - Linked Data Meetup
 
Intorduction to struts
Intorduction to strutsIntorduction to struts
Intorduction to struts
 
Best Practices in Web Service Design
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
 
Amish Umesh - Future Of Web App Testing - ClubHack2007
Amish Umesh - Future Of Web App Testing  - ClubHack2007Amish Umesh - Future Of Web App Testing  - ClubHack2007
Amish Umesh - Future Of Web App Testing - ClubHack2007
 
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
 
Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote
 Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote
Virtuoso, The Prometheus of RDF -- Sematics 2014 Conference Keynote
 
Tableau Desktop as a Linked (Open) Data Front-End via ODBC
Tableau Desktop as a Linked (Open) Data Front-End via ODBCTableau Desktop as a Linked (Open) Data Front-End via ODBC
Tableau Desktop as a Linked (Open) Data Front-End via ODBC
 
Understanding Linked Data via EAV Model based Structured Descriptions
Understanding Linked Data via EAV Model based Structured DescriptionsUnderstanding Linked Data via EAV Model based Structured Descriptions
Understanding Linked Data via EAV Model based Structured Descriptions
 
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
Seamless Integrations between WebCenter Content, Site Studio, and WebCenter S...
 
Solving Real Problems Using Linked Data
Solving Real Problems Using Linked DataSolving Real Problems Using Linked Data
Solving Real Problems Using Linked Data
 

En vedette

Taming coupling and cohesive beasts
Taming coupling and cohesive beastsTaming coupling and cohesive beasts
Taming coupling and cohesive beastsParam Rengaiah
 
Responsive Web Design for Enterprise Apps
Responsive Web Design for Enterprise AppsResponsive Web Design for Enterprise Apps
Responsive Web Design for Enterprise AppsParam Rengaiah
 
Taming coupling and cohesive beasts
Taming coupling and cohesive beastsTaming coupling and cohesive beasts
Taming coupling and cohesive beastsParam Rengaiah
 
From Rails-way to modular architecture
From Rails-way to modular architectureFrom Rails-way to modular architecture
From Rails-way to modular architectureIvan Nemytchenko
 
Separating REST Facts from Fallacies
Separating REST Facts from FallaciesSeparating REST Facts from Fallacies
Separating REST Facts from FallaciesAlan Dean
 
Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.Param Rengaiah
 
ITB2015 - ColdBox 4 MVC Modular Architecture
ITB2015 - ColdBox 4 MVC Modular ArchitectureITB2015 - ColdBox 4 MVC Modular Architecture
ITB2015 - ColdBox 4 MVC Modular ArchitectureOrtus Solutions, Corp
 
24 Books You've Never Heard Of - But Will Change Your Life
24 Books You've Never Heard Of - But Will Change Your Life24 Books You've Never Heard Of - But Will Change Your Life
24 Books You've Never Heard Of - But Will Change Your LifeRyan Holiday
 
20 Quotes To Turn Your Obstacles Into Opportunities
20 Quotes To Turn Your Obstacles Into Opportunities20 Quotes To Turn Your Obstacles Into Opportunities
20 Quotes To Turn Your Obstacles Into OpportunitiesRyan Holiday
 

En vedette (10)

Taming coupling and cohesive beasts
Taming coupling and cohesive beastsTaming coupling and cohesive beasts
Taming coupling and cohesive beasts
 
Responsive Web Design for Enterprise Apps
Responsive Web Design for Enterprise AppsResponsive Web Design for Enterprise Apps
Responsive Web Design for Enterprise Apps
 
Taming coupling and cohesive beasts
Taming coupling and cohesive beastsTaming coupling and cohesive beasts
Taming coupling and cohesive beasts
 
#NoEstimates
#NoEstimates#NoEstimates
#NoEstimates
 
From Rails-way to modular architecture
From Rails-way to modular architectureFrom Rails-way to modular architecture
From Rails-way to modular architecture
 
Separating REST Facts from Fallacies
Separating REST Facts from FallaciesSeparating REST Facts from Fallacies
Separating REST Facts from Fallacies
 
Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.Modular Architectures: What they are why do they matter now.
Modular Architectures: What they are why do they matter now.
 
ITB2015 - ColdBox 4 MVC Modular Architecture
ITB2015 - ColdBox 4 MVC Modular ArchitectureITB2015 - ColdBox 4 MVC Modular Architecture
ITB2015 - ColdBox 4 MVC Modular Architecture
 
24 Books You've Never Heard Of - But Will Change Your Life
24 Books You've Never Heard Of - But Will Change Your Life24 Books You've Never Heard Of - But Will Change Your Life
24 Books You've Never Heard Of - But Will Change Your Life
 
20 Quotes To Turn Your Obstacles Into Opportunities
20 Quotes To Turn Your Obstacles Into Opportunities20 Quotes To Turn Your Obstacles Into Opportunities
20 Quotes To Turn Your Obstacles Into Opportunities
 

Similaire à REST and REST-fulness

Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIRasan Samarasinghe
 
Webinar: Applying REST to Network Management – An Implementor’s View
Webinar: Applying REST to Network Management – An Implementor’s View Webinar: Applying REST to Network Management – An Implementor’s View
Webinar: Applying REST to Network Management – An Implementor’s View Tail-f Systems
 
RESTful web
RESTful webRESTful web
RESTful webAlvin Qi
 
Workshop 04 android-development
Workshop 04 android-developmentWorkshop 04 android-development
Workshop 04 android-developmentAravindharamanan S
 
Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?Akana
 
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 2015Jackson F. de A. Mafra
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
JavaOne2013 Leveraging Linked Data and OSLC
JavaOne2013 Leveraging Linked Data and OSLCJavaOne2013 Leveraging Linked Data and OSLC
JavaOne2013 Leveraging Linked Data and OSLCSteve Speicher
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
Creating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepCreating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepMike Anderson
 
Rest api design by george reese
Rest api design by george reeseRest api design by george reese
Rest api design by george reesebuildacloud
 
W3C Linked Data Platform Overview
W3C Linked Data Platform OverviewW3C Linked Data Platform Overview
W3C Linked Data Platform OverviewSteve Speicher
 
Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API" Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API" Fwdays
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Woodruff Solutions LLC
 
What is the difference between an api and web services
What is the difference between an api and web servicesWhat is the difference between an api and web services
What is the difference between an api and web servicesAparna Sharma
 

Similaire à REST and REST-fulness (20)

Advanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST APIAdvanced Web Development in PHP - Understanding REST API
Advanced Web Development in PHP - Understanding REST API
 
Webinar: Applying REST to Network Management – An Implementor’s View
Webinar: Applying REST to Network Management – An Implementor’s View Webinar: Applying REST to Network Management – An Implementor’s View
Webinar: Applying REST to Network Management – An Implementor’s View
 
APITalkMeetupSharable
APITalkMeetupSharableAPITalkMeetupSharable
APITalkMeetupSharable
 
REST != WebAPI
REST != WebAPIREST != WebAPI
REST != WebAPI
 
RESTful web
RESTful webRESTful web
RESTful web
 
Workshop 04 android-development
Workshop 04 android-developmentWorkshop 04 android-development
Workshop 04 android-development
 
Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?Making Sense of Hypermedia APIs – Hype or Reality?
Making Sense of Hypermedia APIs – Hype or Reality?
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
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
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
JavaOne2013 Leveraging Linked Data and OSLC
JavaOne2013 Leveraging Linked Data and OSLCJavaOne2013 Leveraging Linked Data and OSLC
JavaOne2013 Leveraging Linked Data and OSLC
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
Creating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleepCreating a RESTful api without losing too much sleep
Creating a RESTful api without losing too much sleep
 
Rest api design by george reese
Rest api design by george reeseRest api design by george reese
Rest api design by george reese
 
W3C Linked Data Platform Overview
W3C Linked Data Platform OverviewW3C Linked Data Platform Overview
W3C Linked Data Platform Overview
 
Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API" Алексей Веркеенко "Symfony2 & REST API"
Алексей Веркеенко "Symfony2 & REST API"
 
RESTful APIs
RESTful APIsRESTful APIs
RESTful APIs
 
Mobile APIs in Practice
Mobile APIs in PracticeMobile APIs in Practice
Mobile APIs in Practice
 
Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8Connecting to Data from Windows Phone 8
Connecting to Data from Windows Phone 8
 
What is the difference between an api and web services
What is the difference between an api and web servicesWhat is the difference between an api and web services
What is the difference between an api and web services
 

Dernier

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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
[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.pdfhans926745
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
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
 
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 Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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.pdfsudhanshuwaghmare1
 
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.pptxEarley Information Science
 
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 MenDelhi Call girls
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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 2024Rafal Los
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 

Dernier (20)

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...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
[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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
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...
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
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
 
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
 
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
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

REST and REST-fulness

  • 1. REST and REST-fulness David Waite Ping Labs !1 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 2. REST VS SOAP !2 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 3. REST vs SOAP? • REST is a network data architecture for hypermedia systems • SOAP is a XML-based message format • SOA is a software design and deployment pattern ! • Often people say REST to imply a RESTinfluenced API design (RESTful API) !3 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 4. OK then, REST vs SOA • REST and SOA are not mutually exclusive – REST abstracts network elements within a distributed hypermedia system – SOA is the idea of having a decentralized system by having components which supply services to other services !4 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 5. The Mistakes of SOAP • SOAP (Simple Object Access Protocol) was defined as a protocol abstraction on top of other protocol – HTTP, SMTP, JMS • Ignores many lower-level protocol features • Reimplements them on top of its own protocol • Uses XML for Object representation !5 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 6. XML VS JSON !6 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 7. XML vs JSON • XML was designed as a reusable simplification of SGML in 1999 – Standard Generalized Markup Language – XML could be said to be a language divided between two camps, people defining: – markup languages for documents • HTML, SVG, MathML – interoperable data serialization !7 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 8. XML vs JSON • The initial influencers were almost purely document-oriented – tools would not manipulate XML as data but be written to manipulate particular documents • XML has problems when representing generic data • XML APIs are notoriously tedious for extracting data !8 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 9. XML vs JSON • Short for JavaScript Object Notation • JSON was first used as a data format in 2001 by Douglas Crockford • First popular use was by Yahoo! in 2005, Google in 2006 • Informational RFC describing the format in 2006 !9 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 10. XML vs JSON • JSON is based on a subset of the Javascript format used to define literal data structures – Floating point numerics – Booleans – Strings – Null – Arrays – Objects (Dictionaries/Maps) !10 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 11. XML vs JSON • Original popularity was because of AJAX Web sites like Gmail • JSON format can be “eval”ed in JS – probably should regex to make sure there isn’t any code – current browsers have a faster native JSON parser built-in !11 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 12. XML vs JSON • Unlike XML, a native data format is defined • containing most of the primitives you need • But no native representation of: – date/time – integers (vs double-precision floats) – binary streams – namespaced data • No (finished) schema language !12 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 13. WHAT IS REST? !13 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 14. Roy Fielding • A principal author of the HTTP specification • Contributor to Apache HTTP Server • Retconned “REST” as the motivation for the design of HTTP in his doctorate dissertation !14 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 15. What is REST A set of six architectural constraints 1. 2. 3. 4. 5. 6. !15 Client/Server Stateless Cacheable Layered System Uniform Interface Code on Demand (optional) Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 16. Client/Server Separation of user interface and data storage concerns • • • • !16 Portability of user interface Scalability of server components Independent deployment Independent evolution Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 17. Stateless Each request contains all needed information to understand the request • • • • !17 session state is kept on the client better recovery from failures reduced server resource usage scalability due to not needing manage state between requests Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 18. Stateless Tradeoffs • More traffic between client and server • May need to integrity or confidentialityprotect data needed for future requests • Greater negative impact to bad client implementation !18 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 19. Cacheable • Responses are required to be interpreted as cacheable or non-cacheable • Improves network efficiency • Improve server efficiency by avoiding response generation • Improves client performance • But, stale data may decrease reliability !19 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 20. Layered System • System can be composed of hierarchical layers • Components can act as clients on one side and servers on the other • Clients and Servers both do not need to know or do anything to support these components • Reduces complexity of overall system • Intermediaries can affect performance !20 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 21. Code on Demand • Client side can be extended by downloading code – javascript, applets, flash • Reduces features which need to be preimplemented • But, affects visibility into what is happening • Security ramifications • Optional, may not be supported by some clients !21 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 22. Uniform Interface • Generality to the client/server interface (HTTP, HTML) • Reusability • Independent evolution • But, degrades efficiency !22 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 23. Interface Constraints • Four additional interface constraints: ! 1. Identification of Resources through URIs 2. Manipulation of Resources through Representations 3. Self-Descriptive Messages 4. Hypermedia as the engine of application state (HATEAOS) !23 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 24. Identification of Resources through URIs • A request is meant to be targeted at a particular resource – via a Uniform Resource Identifier • Independent from Representations of the resource returned or accepted – e.g., resource backed by database row results in stylized HTML content • Provides generality and late binding !24 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 25. Self-Descriptive Messages • A request or response can contain data and metadata • Metadata is sufficient for processing data – Content-Type • text/html • application/xml • application/personrecord+json • Also, caching is part of a response !25 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 26. Manipulation of Resources through Representations • A representation of the resource provides enough information to manipulate resource – Blog with comment form – List of records with delete buttons ! • URL of resource to client API? !26 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 27. HATEAOS Hypermedia as the engine of application state ! • Web is a non-linear medium formed by multimedia connected by hyperlinks • Parties should not be assumed to understand structure of resources in order to be able to retrieve and manipulate them !27 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 28. RESTFUL API DESIGN !28 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 29. RESTful API Design fundamentals • Understand HTTP as an underlying system – HTTP Methods – Content type selection – Cacheability – Safety and Idempotency of certain methods !29 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 30. Example: Rails RESTful Routes resources  :photos creates seven different routes in your application, all mapping to the Photos controller: resources  :photos Verb GET Path /photos Action Used for index display a list of all photos GET /photos/new new POST GET /photos /photos/:id create create a new photo show display a specific photo GET /photos/:id/edit edit PATCH/ /photos/:id PUT DELETE /photos/:id !30 return HTML form to create a new photo return an HTML form for editing a photo update update a specific photo destroy delete a specific photo Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 31. Example: Rails content type selection class  UsersController  <  ApplicationController::Base   !    respond_to  :html,  :xml,  :json   !    def  index          respond_with(@users  =  User.all)      end   end !31 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 32. Example: Rails Content Type Selection GET  /users                                #  HTML
 GET  /users
 Accepts:  application/json  #  JSON   
 GET  /users.xml                        #  XML !32 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 33. Bad Examples GET  /user/changeGender?gender=f
 GET  /article/1/delete   ! POST  /soap
 SOAPAction:  urn:foo:SubmitTaxRecords !33 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 34. Cacheability • As much of your API as possible should be designed with the idea of cacheability – Can I guarantee this data will be valid for a certain period of time? – Is there a significant impact if the data goes invalid before the time I specified? – How can I more easily check if data has changed than generate a new response? • HEAD vs GET !34 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 35. Relations /articles   Article ! /articles/xyz   Comment User ! /articles/xyz/comments   Author ! /users/dwaite !35 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 36. HATEAOS • Don’t couple site design and resource locations to API design • Lots of “Best Practice” and “Personal Preference” choices !36 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 37. HATEAOS example #  Non-­‐HATEAOS   GET  /users/dwaite  #  -­‐>   {  
    “fn”:  “Waite”,  
    “gn”:  “David”,
    groups:  
        [“admin”,  “labs”,  “denver”]  
 } !37 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 38. HATEAOS example #  HATEAOS   GET  /users/dwaite  #  -­‐>   {  
    “fn”:  “Waite”,  
    “gn”:  “David”,
    groups:  
    {
      “Administrator”:  “/groups/admin”,  
      “Ping  Labs”:          “/groups/pinglabs”,
      “Denver”:                “/locations/Denver”
    }
 } !38 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 39. Versioning • Big design contention – Minor version updates through data - add to response, do not change or remove – Major version update, indicate via • new URL • new media type / mime type – application/user+json;version=1 • some header – Require version to be specified? !39 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 40. More Information • http://en.wikipedia.org/wiki/ Representational_state_transfer • http://www.stormpath.com/blog/ designing-rest-json-apis • http://www.ics.uci.edu/~fielding/pubs/ dissertation/rest_arch_style.htm • http://groups.google.com/group/api-craft !40 Copyright ©2012 Ping Identity Corporation. All rights reserved.
  • 41. One More Thing: Cookies • Cookies are generally non-RESTful – Against client/server and stateless • client state on server • server state on client – Against caching • Response containing cookies • Response generated from request cookies • Try to use HTTP-level auth (like OAuth2) !41 Copyright ©2012 Ping Identity Corporation. All rights reserved.