SlideShare a Scribd company logo
©2015 Apigee Corp. All Rights Reserved.
©2015 Apigee Corp. All Rights Reserved. 
Intro
• Why care about
this topic?
• Why care about
what we think?
©2015 Apigee Corp. All Rights Reserved. 
Topics
• What is a "REST API"
– Data-oriented versus Service-oriented APIs
– Hypermedia
– JSON representations
– Collections
• Versioning
©2015 Apigee Corp. All Rights Reserved. 
History
Service-oriented
 Data-oriented
RPC
CORBA
SOAP/WSDL
"REST API"
NLS
Xanadu
Databases
World-Wide Web
REST
??
Object-orientation
"REST API"
©2015 Apigee Corp. All Rights Reserved. 
Opposing Perspectives
Service-oriented



Data behind operations
Data-oriented



Operations behind data
©2015 Apigee Corp. All Rights Reserved. 
Opposing Perspectives
Service-oriented
	
  
	
  
	
  
	
  
getPerson(personId)	
  
updatePerson(personId,	
  data)	
  
deletePerson(personId)	
  
Data-oriented

	
  
	
  
	
  
http://primary-­‐key-­‐value	
  
http://example.org/person/12345	
  
©2015 Apigee Corp. All Rights Reserved. 
Why We Like Data-Oriented APIs
• The primary value is the data it exposes
• Data-Oriented is Simpler
– Learn the data vs learn the services + the data
– Don’t design an API at all, just use REST
©2015 Apigee Corp. All Rights Reserved. 
What Is Important?
Are you wasting
time repetitively
documenting the
standard HTTP
REST patterns?
©2015 Apigee Corp. All Rights Reserved. 
What would be better?
9
©2015 Apigee. All Rights Reserved. 
PetTracker
Dog
People
dogs n
people n
1
 1
owner 1
 dogs n
birthDate
 birthDate
hairColor
 furColor
name
 name
REST/HTTP
+
©2015 Apigee Corp. All Rights Reserved. 
Follow the REST/HTTP patterns exactly
• E.g.
– POST means Create. Response status code is 201. URL of
new resource is in the 'Location' header
– PUT means 'replace', not 'update'. PATCH means 'update'
– GET response includes ETag and Content-Location headers
– PUT and PATCH require an 'If-Match' header
– …
10
©2015 Apigee. All Rights Reserved.
©2015 Apigee Corp. All Rights Reserved. 
Gaps in HTTP/REST for programmatic use
•  How do you represent relationships
– Single-valued
•  What is a hyperlink?
– Multi-valued
•  What is a Collection/Cursor?
•  HTML provides some answers for the human-readable web
–  <a ref = "http://example.org/people/98765432">Joe Carraclough</a>
•  What is the equivalent for JSON?
11
©2015 Apigee. All Rights Reserved.
©2015 Apigee Corp. All Rights Reserved. 
Hypermedia — Just Do It
•  Most data is conceptually linked
–  So show the links in the data
•  Myths
–  Hypermedia APIs are controversial (practiced by extremists)
–  Hypermedia APIs are difficult
–  Hypermedia APIs are 100% self-describing
–  Hypermedia APIs are not compatible with languages like
Swagger (or other DLs)
©2015 Apigee Corp. All Rights Reserved. 
Service-Oriented Data-Oriented
http://example.org/people	
  
http://example.org/people/{personID}	
  
http://example.org/people/{personID}/dogs	
  
http://example.org/dogs	
  
http://example.org/dogs/{dogID}	
  
http://example.org/dogs/{dogID}/owner	
  
	
   	
   	
  plus	
  
{"id":	
  "12345678",	
  	
  
	
  "type":	
  "Dog"	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "98765432"}	
  
and	
  
{"id":"98765432",	
  	
  
	
  "type":	
  "Person"	
  
	
  "name":	
  "Joe	
  Carraclough",	
  	
  
	
  "hair_color":	
  "brown"}	
  
	
  
{"self":	
  "http://example.org/",	
  
	
  "type":	
  "PetTracker",	
  
	
  "dogs":	
  "http://example.org/dogs",	
  
	
  "people":	
  "http://example.org/people}	
  
	
  	
   	
  and	
  
{"self":	
  "http://example.org/dogs/12345678",	
  	
  
	
  "type":	
  "Dog",	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "http://example.org/people/98765432"}	
  
and	
  
{"self":	
  "http://example.org/people/98765432",	
  	
  
	
  "type":	
  "Person",	
  
	
  "name":	
  "Joe	
  Carraclough",	
  	
  
	
  "hair_color":	
  "brown",	
  
	
  "dogs":	
  "http://example.org/people/98765432/dogs"}	
  
	
  
©2015 Apigee Corp. All Rights Reserved. 
Cursor/Collection
{	
  
	
  "self":	
  "http://example.org/dogs",	
  
	
  "type":	
  "Collection",	
  
	
  "items":	
  [	
  
{"self":	
  "http://example.org/dogs/12345678",	
  	
  
	
  "type":	
  "Dog",	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "http://example.org/people/98765432"},	
  
{"self":	
  "http://example.org/dogs/12345679",	
  	
  
	
  "type":	
  "Dog",	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "http://example.org/people/98765432"}	
  
]	
  
}	
  
14
©2015 Apigee. All Rights Reserved.
©2015 Apigee Corp. All Rights Reserved. 
Cursor/Collection
{	
  
	
  "self":	
  "http://example.org/dogs?limit=10",	
  
	
  "type":	
  "Page",	
  
	
  "collection":	
  "http://example.org/dogs",	
  
	
  "next":	
  "http://example.org/ZG9ncz87bGFzdD0xMA==",	
  
	
  "previous":	
  "http://example.org/ZG9ncz87Zmlyc3Q9MTA=",	
  
	
  "items":	
  [	
  
{"self":	
  "http://example.org/dogs/12345678",	
  	
  
	
  "type":	
  "Dog",	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "http://example.org/people/98765432"},	
  
{"self":	
  "http://example.org/dogs/12345679",	
  	
  
	
  "type":	
  "Dog",	
  
	
  "name":	
  "Lassie",	
  	
  
	
  "fur_color":	
  "brown",	
  
	
  "owner":	
  "http://example.org/people/98765432"}	
  
]	
  
}	
  
15
©2015 Apigee. All Rights Reserved.
©2015 Apigee Corp. All Rights Reserved. 
A File in Google Drive
{	
  
"kind":	
  "drive#file",	
  
"id":	
  "1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0",	
  
"etag":	
  "9vYBbk7LzzrwpsohQSOkWalvY6Y/MTQ0Mjc1ODk5NzAwMQ",	
  
"selfLink":	
  "https://www.googleapis.com/drive/v2/files/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0",	
  
"alternateLink":	
  "https://docs.google.com/a/apigee.com/document/d/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0/edit?usp=drivesdk",	
  
"embedLink":	
  "https://docs.google.com/a/apigee.com/document/d/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0/preview",	
  
...	
  
"title":	
  "Web	
  API	
  Design	
  edition	
  2",	
  
"mimeType":	
  "application/vnd.google-­‐apps.document",	
  
...	
  
"createdDate":	
  "2015-­‐07-­‐10T15:26:34.567Z",	
  
"modifiedDate":	
  "2015-­‐09-­‐20T14:23:17.001Z",	
  
"modifiedByMeDate":	
  "2015-­‐09-­‐20T14:23:17.001Z",	
  
"lastViewedByMeDate":	
  "2015-­‐09-­‐30T23:16:08.011Z",	
  
"markedViewedByMeDate":	
  "1970-­‐01-­‐01T00:00:00.000Z",	
  
"version":	
  "41819",	
  
...	
  
	
  
©2015 Apigee Corp. All Rights Reserved. 
A Folder's Children in Google Drive
{	
  
"kind":	
  "drive#childList",	
  
"etag":	
  "9vYBbk7LzzrwpsohQSOkWalvY6Y/73yTWsreOINR667_OZQCurHB09o",	
  
"selfLink":	
  "https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children",	
  
"items":	
  [	
  
	
  {	
  
	
  	
  "kind":	
  "drive#childReference",	
  
	
  	
  "id":	
  "1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0",	
  
	
  	
  "selfLink":	
  "
https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children/1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0",	
  
	
  	
  "childLink":	
  "https://www.googleapis.com/drive/v2/files/1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0"	
  
	
  },	
  
	
  {	
  
	
  	
  "kind":	
  "drive#childReference",	
  
	
  	
  "id":	
  "1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8",	
  
	
  	
  "selfLink":	
  "
https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children/1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8",	
  
	
  	
  "childLink":	
  "https://www.googleapis.com/drive/v2/files/1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8"	
  
	
  }	
  
]	
  
}	
  
©2015 Apigee Corp. All Rights Reserved. 
Principles Illustrated
•  Use JSON
•  Keep your JSON simple and flat
•  Links can be simple properties
•  Collections are resources too
•  Provide a "self" property
•  Provide a "kind" property
©2015 Apigee Corp. All Rights Reserved. 
Perma-links Versus ‘Query URLs’
'Query URLs':
http://example.org/?type=Person&id=personID	
  
http://example.org/people/{personId}	
  
http://example.org/people/{personName}
vs Perma-links
http://example.org/cGVyc29uczt7cGVyc29uX2lkfS9kb2dz	
  	
  
©2015 Apigee Corp. All Rights Reserved. 
API Versioning
©2015 Apigee Corp. All Rights Reserved. 
The Most Complex Form of Versioning
•  Multiple versions of the same resource are available simultaneously
•  Client selects the version it needs
•  Cons:
–  It is expensive to implement
–  It doesn’t always work anyway
•  Pros:
–  Supports frequent versioning
•  Very few people actually do this
©2015 Apigee Corp. All Rights Reserved. 
Why Doesn’t It Always Work?
•  It doesn't work if you make substantial data-model changes
– You won’t be able to update through the old versions
•  It doesn't work for micro-services
– Consider:
•  /v1/orders/123456	
  
•  /v2/accounts/9876765	
  
– Now consider:
•  /v2/recent_changes	
  
– Should it include v1 format of orders, "
or v2 format of orders?
©2015 Apigee Corp. All Rights Reserved. 
Pragmatic Versioning
•  Only one version of each resource available at any one time
–  Make sure clients can tolerate minor changes
•  Version upgrade is infrequent
– Major breaking change
•  Less elegant version:
– https://api.acmecorp.com/orders/v1/123456	
  
– https://api.acmecorp.com/orders/v2/123456	
  
•  Elegant version – the ‘no-versioning’ strategy for versioning
– https://api.acmecorp.com/orders/123456	
  
– https://api2.acmecorp.com/orders/123456	
  
©2015 Apigee Corp. All Rights Reserved. 
Summary
•  Data-oriented APIs
•  Simple, flat JSON
•  Hypermedia
–  Hypermedia links can be simple JSON properties
•  Simple collections that are also resources
•  Simple, ‘no versioning’ versioning strategy
Thank you
Martin Nally
@mpnally
Marsh Gardiner
@earth2marsh

More Related Content

PDF
How to Grow and Measure Your API Program - I ♥ APIs 2015
PDF
Building Hypermedia APIs in JavaScript
PDF
Orchestrating microservices like a ninja
PPTX
How to define an api
PPTX
Building a Better BaaS
PDF
Building Mobile Apps with Apache UserGrid, the Open Source Baas
PDF
Going to Infinity and Beyond Documentation with OpenAPI
PDF
Java Master Class
How to Grow and Measure Your API Program - I ♥ APIs 2015
Building Hypermedia APIs in JavaScript
Orchestrating microservices like a ninja
How to define an api
Building a Better BaaS
Building Mobile Apps with Apache UserGrid, the Open Source Baas
Going to Infinity and Beyond Documentation with OpenAPI
Java Master Class

What's hot (20)

KEY
OpenACT - Meet1 - Intro to APIs
PDF
How mentoring can help you start contributing to open source
PPTX
Owning the Lifecycle of a Drupal Digital Project
PPT
Six Steps To Build A Successful API
PDF
Apache Usergrid for JavaScript Developers
PPTX
APIs and Linked Data: A match made in Heaven
PDF
Session at Oredev 2016.
PDF
How to Contribute to Apache Usergrid
PDF
Coding from Application Container Cloud to Oracle JET
PDF
geecon 2016: "What's Oracle Doing with JavaScript?!"
PDF
The 7 Deadly Sins of API Design
PDF
Wrapping and Securing REST APIs with GraphQL
PDF
Open Source Mobile Backend on Cassandra
PPTX
Design for scale
PPTX
Making Smart Homes Smarter With Javascript
PPTX
Apache Unomi presentation and update. By Serge Huber, CTO Jahia
PPT
Get Some REST: Building Great APIs for Great Apps | Allen Pike, Steamclock So...
PDF
Usergrid Overview
KEY
Apache Rave at The Apache Meetup in NL
PDF
Oracle User Group Holland
OpenACT - Meet1 - Intro to APIs
How mentoring can help you start contributing to open source
Owning the Lifecycle of a Drupal Digital Project
Six Steps To Build A Successful API
Apache Usergrid for JavaScript Developers
APIs and Linked Data: A match made in Heaven
Session at Oredev 2016.
How to Contribute to Apache Usergrid
Coding from Application Container Cloud to Oracle JET
geecon 2016: "What's Oracle Doing with JavaScript?!"
The 7 Deadly Sins of API Design
Wrapping and Securing REST APIs with GraphQL
Open Source Mobile Backend on Cassandra
Design for scale
Making Smart Homes Smarter With Javascript
Apache Unomi presentation and update. By Serge Huber, CTO Jahia
Get Some REST: Building Great APIs for Great Apps | Allen Pike, Steamclock So...
Usergrid Overview
Apache Rave at The Apache Meetup in NL
Oracle User Group Holland
Ad

Similar to Webcast: Pragmatic REST: The Next Generation (20)

PPTX
Pragmatic REST: recent trends in API design
PDF
Using an API
PDF
Learn REST in 18 Slides
PPT
RESTful SOA - 中科院暑期讲座
PPTX
Crafting Evolvable Api Responses
PPTX
A Deep Dive into RESTful API Design Part 2
PDF
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
PPTX
API Simplicity == Speed; Designing APIs That are Easy and Fun to Use
PPTX
Inside Wordnik's Architecture
PDF
Great APIs - Future of Your Progress App
PDF
REST Introduction (PHP London)
PPTX
How RESTful Is Your REST?
PPTX
API Documentation Workshop tcworld India 2015
PPTX
Scaling with swagger
PDF
Web API Design: Crafting Interfaces that Developers Love
PDF
Web API Design
PPTX
API Documentation presentation to East Bay STC Chapter
PPTX
API Documentation -- Presentation to East Bay STC Chapter
KEY
CouchDB : More Couch
PPTX
Rest schema design
Pragmatic REST: recent trends in API design
Using an API
Learn REST in 18 Slides
RESTful SOA - 中科院暑期讲座
Crafting Evolvable Api Responses
A Deep Dive into RESTful API Design Part 2
RESTFUL SERVICES MADE EASY: THE EVE REST API FRAMEWORK - Nicola Iarocci - Co...
API Simplicity == Speed; Designing APIs That are Easy and Fun to Use
Inside Wordnik's Architecture
Great APIs - Future of Your Progress App
REST Introduction (PHP London)
How RESTful Is Your REST?
API Documentation Workshop tcworld India 2015
Scaling with swagger
Web API Design: Crafting Interfaces that Developers Love
Web API Design
API Documentation presentation to East Bay STC Chapter
API Documentation -- Presentation to East Bay STC Chapter
CouchDB : More Couch
Rest schema design
Ad

More from Apigee | Google Cloud (20)

PDF
How Secure Are Your APIs?
PDF
Magazine Luiza at a glance (1)
PPTX
Monetization: Unlock More Value from Your APIs
PDF
Apigee Demo: API Platform Overview
PDF
Ticketmaster at a glance
PDF
AccuWeather: Recasting API Experiences in a Developer-First World
PDF
Which Application Modernization Pattern Is Right For You?
PPTX
Apigee Product Roadmap Part 2
PPTX
The Four Transformative Forces of the API Management Market
PDF
Walgreens at a glance
PDF
Apigee Edge: Intro to Microgateway
PDF
Managing the Complexity of Microservices Deployments
PDF
Pitney Bowes at a glance
PPTX
Microservices Done Right: Key Ingredients for Microservices Success
PDF
Adapt or Die: Opening Keynote with Chet Kapoor
PDF
Adapt or Die: Keynote with Greg Brail
PDF
Adapt or Die: Keynote with Anant Jhingran
PDF
London Adapt or Die: Opening Keynot
PDF
London Adapt or Die: Lunch keynote
PDF
London Adapt or Die: Closing Keynote — Adapt Now!
How Secure Are Your APIs?
Magazine Luiza at a glance (1)
Monetization: Unlock More Value from Your APIs
Apigee Demo: API Platform Overview
Ticketmaster at a glance
AccuWeather: Recasting API Experiences in a Developer-First World
Which Application Modernization Pattern Is Right For You?
Apigee Product Roadmap Part 2
The Four Transformative Forces of the API Management Market
Walgreens at a glance
Apigee Edge: Intro to Microgateway
Managing the Complexity of Microservices Deployments
Pitney Bowes at a glance
Microservices Done Right: Key Ingredients for Microservices Success
Adapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Anant Jhingran
London Adapt or Die: Opening Keynot
London Adapt or Die: Lunch keynote
London Adapt or Die: Closing Keynote — Adapt Now!

Recently uploaded (20)

PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Encapsulation theory and applications.pdf
PDF
Getting Started with Data Integration: FME Form 101
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Assigned Numbers - 2025 - Bluetooth® Document
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Encapsulation theory and applications.pdf
Getting Started with Data Integration: FME Form 101
20250228 LYD VKU AI Blended-Learning.pptx
Tartificialntelligence_presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Machine learning based COVID-19 study performance prediction
Group 1 Presentation -Planning and Decision Making .pptx
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Network Security Unit 5.pdf for BCA BBA.
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Per capita expenditure prediction using model stacking based on satellite ima...

Webcast: Pragmatic REST: The Next Generation

  • 1. ©2015 Apigee Corp. All Rights Reserved.
  • 2. ©2015 Apigee Corp. All Rights Reserved. Intro • Why care about this topic? • Why care about what we think?
  • 3. ©2015 Apigee Corp. All Rights Reserved. Topics • What is a "REST API" – Data-oriented versus Service-oriented APIs – Hypermedia – JSON representations – Collections • Versioning
  • 4. ©2015 Apigee Corp. All Rights Reserved. History Service-oriented Data-oriented RPC CORBA SOAP/WSDL "REST API" NLS Xanadu Databases World-Wide Web REST ?? Object-orientation "REST API"
  • 5. ©2015 Apigee Corp. All Rights Reserved. Opposing Perspectives Service-oriented Data behind operations Data-oriented Operations behind data
  • 6. ©2015 Apigee Corp. All Rights Reserved. Opposing Perspectives Service-oriented         getPerson(personId)   updatePerson(personId,  data)   deletePerson(personId)   Data-oriented       http://primary-­‐key-­‐value   http://example.org/person/12345  
  • 7. ©2015 Apigee Corp. All Rights Reserved. Why We Like Data-Oriented APIs • The primary value is the data it exposes • Data-Oriented is Simpler – Learn the data vs learn the services + the data – Don’t design an API at all, just use REST
  • 8. ©2015 Apigee Corp. All Rights Reserved. What Is Important? Are you wasting time repetitively documenting the standard HTTP REST patterns?
  • 9. ©2015 Apigee Corp. All Rights Reserved. What would be better? 9 ©2015 Apigee. All Rights Reserved. PetTracker Dog People dogs n people n 1 1 owner 1 dogs n birthDate birthDate hairColor furColor name name REST/HTTP +
  • 10. ©2015 Apigee Corp. All Rights Reserved. Follow the REST/HTTP patterns exactly • E.g. – POST means Create. Response status code is 201. URL of new resource is in the 'Location' header – PUT means 'replace', not 'update'. PATCH means 'update' – GET response includes ETag and Content-Location headers – PUT and PATCH require an 'If-Match' header – … 10 ©2015 Apigee. All Rights Reserved.
  • 11. ©2015 Apigee Corp. All Rights Reserved. Gaps in HTTP/REST for programmatic use •  How do you represent relationships – Single-valued •  What is a hyperlink? – Multi-valued •  What is a Collection/Cursor? •  HTML provides some answers for the human-readable web –  <a ref = "http://example.org/people/98765432">Joe Carraclough</a> •  What is the equivalent for JSON? 11 ©2015 Apigee. All Rights Reserved.
  • 12. ©2015 Apigee Corp. All Rights Reserved. Hypermedia — Just Do It •  Most data is conceptually linked –  So show the links in the data •  Myths –  Hypermedia APIs are controversial (practiced by extremists) –  Hypermedia APIs are difficult –  Hypermedia APIs are 100% self-describing –  Hypermedia APIs are not compatible with languages like Swagger (or other DLs)
  • 13. ©2015 Apigee Corp. All Rights Reserved. Service-Oriented Data-Oriented http://example.org/people   http://example.org/people/{personID}   http://example.org/people/{personID}/dogs   http://example.org/dogs   http://example.org/dogs/{dogID}   http://example.org/dogs/{dogID}/owner        plus   {"id":  "12345678",      "type":  "Dog"    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "98765432"}   and   {"id":"98765432",      "type":  "Person"    "name":  "Joe  Carraclough",      "hair_color":  "brown"}     {"self":  "http://example.org/",    "type":  "PetTracker",    "dogs":  "http://example.org/dogs",    "people":  "http://example.org/people}        and   {"self":  "http://example.org/dogs/12345678",      "type":  "Dog",    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "http://example.org/people/98765432"}   and   {"self":  "http://example.org/people/98765432",      "type":  "Person",    "name":  "Joe  Carraclough",      "hair_color":  "brown",    "dogs":  "http://example.org/people/98765432/dogs"}    
  • 14. ©2015 Apigee Corp. All Rights Reserved. Cursor/Collection {    "self":  "http://example.org/dogs",    "type":  "Collection",    "items":  [   {"self":  "http://example.org/dogs/12345678",      "type":  "Dog",    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "http://example.org/people/98765432"},   {"self":  "http://example.org/dogs/12345679",      "type":  "Dog",    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "http://example.org/people/98765432"}   ]   }   14 ©2015 Apigee. All Rights Reserved.
  • 15. ©2015 Apigee Corp. All Rights Reserved. Cursor/Collection {    "self":  "http://example.org/dogs?limit=10",    "type":  "Page",    "collection":  "http://example.org/dogs",    "next":  "http://example.org/ZG9ncz87bGFzdD0xMA==",    "previous":  "http://example.org/ZG9ncz87Zmlyc3Q9MTA=",    "items":  [   {"self":  "http://example.org/dogs/12345678",      "type":  "Dog",    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "http://example.org/people/98765432"},   {"self":  "http://example.org/dogs/12345679",      "type":  "Dog",    "name":  "Lassie",      "fur_color":  "brown",    "owner":  "http://example.org/people/98765432"}   ]   }   15 ©2015 Apigee. All Rights Reserved.
  • 16. ©2015 Apigee Corp. All Rights Reserved. A File in Google Drive {   "kind":  "drive#file",   "id":  "1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0",   "etag":  "9vYBbk7LzzrwpsohQSOkWalvY6Y/MTQ0Mjc1ODk5NzAwMQ",   "selfLink":  "https://www.googleapis.com/drive/v2/files/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0",   "alternateLink":  "https://docs.google.com/a/apigee.com/document/d/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0/edit?usp=drivesdk",   "embedLink":  "https://docs.google.com/a/apigee.com/document/d/1cjKSwWlryNfRs-­‐durx_8n0dGTUWE_klBrP8IuEYTUu0/preview",   ...   "title":  "Web  API  Design  edition  2",   "mimeType":  "application/vnd.google-­‐apps.document",   ...   "createdDate":  "2015-­‐07-­‐10T15:26:34.567Z",   "modifiedDate":  "2015-­‐09-­‐20T14:23:17.001Z",   "modifiedByMeDate":  "2015-­‐09-­‐20T14:23:17.001Z",   "lastViewedByMeDate":  "2015-­‐09-­‐30T23:16:08.011Z",   "markedViewedByMeDate":  "1970-­‐01-­‐01T00:00:00.000Z",   "version":  "41819",   ...    
  • 17. ©2015 Apigee Corp. All Rights Reserved. A Folder's Children in Google Drive {   "kind":  "drive#childList",   "etag":  "9vYBbk7LzzrwpsohQSOkWalvY6Y/73yTWsreOINR667_OZQCurHB09o",   "selfLink":  "https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children",   "items":  [    {      "kind":  "drive#childReference",      "id":  "1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0",      "selfLink":  " https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children/1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0",      "childLink":  "https://www.googleapis.com/drive/v2/files/1BuYLy9FkXpILYmwnRNetnUFCC9D-­‐U35PrJcO_9YsuW0"    },    {      "kind":  "drive#childReference",      "id":  "1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8",      "selfLink":  " https://www.googleapis.com/drive/v2/files/0B2Pq-­‐qMI4R2jYVdudkdNMld3Vm8/children/1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8",      "childLink":  "https://www.googleapis.com/drive/v2/files/1pfcXbfX9PaUk12Cywqav9H77-­‐DQEWhxjeKHgu1qpAi8"    }   ]   }  
  • 18. ©2015 Apigee Corp. All Rights Reserved. Principles Illustrated •  Use JSON •  Keep your JSON simple and flat •  Links can be simple properties •  Collections are resources too •  Provide a "self" property •  Provide a "kind" property
  • 19. ©2015 Apigee Corp. All Rights Reserved. Perma-links Versus ‘Query URLs’ 'Query URLs': http://example.org/?type=Person&id=personID   http://example.org/people/{personId}   http://example.org/people/{personName} vs Perma-links http://example.org/cGVyc29uczt7cGVyc29uX2lkfS9kb2dz    
  • 20. ©2015 Apigee Corp. All Rights Reserved. API Versioning
  • 21. ©2015 Apigee Corp. All Rights Reserved. The Most Complex Form of Versioning •  Multiple versions of the same resource are available simultaneously •  Client selects the version it needs •  Cons: –  It is expensive to implement –  It doesn’t always work anyway •  Pros: –  Supports frequent versioning •  Very few people actually do this
  • 22. ©2015 Apigee Corp. All Rights Reserved. Why Doesn’t It Always Work? •  It doesn't work if you make substantial data-model changes – You won’t be able to update through the old versions •  It doesn't work for micro-services – Consider: •  /v1/orders/123456   •  /v2/accounts/9876765   – Now consider: •  /v2/recent_changes   – Should it include v1 format of orders, " or v2 format of orders?
  • 23. ©2015 Apigee Corp. All Rights Reserved. Pragmatic Versioning •  Only one version of each resource available at any one time –  Make sure clients can tolerate minor changes •  Version upgrade is infrequent – Major breaking change •  Less elegant version: – https://api.acmecorp.com/orders/v1/123456   – https://api.acmecorp.com/orders/v2/123456   •  Elegant version – the ‘no-versioning’ strategy for versioning – https://api.acmecorp.com/orders/123456   – https://api2.acmecorp.com/orders/123456  
  • 24. ©2015 Apigee Corp. All Rights Reserved. Summary •  Data-oriented APIs •  Simple, flat JSON •  Hypermedia –  Hypermedia links can be simple JSON properties •  Simple collections that are also resources •  Simple, ‘no versioning’ versioning strategy
  • 25. Thank you Martin Nally @mpnally Marsh Gardiner @earth2marsh