SlideShare a Scribd company logo
1 of 73
Download to read offline
Teach a Dog to REST


Brian Mulloy
@landlessness

Apigee
@apigee
20%
Application developers are kingmakers.
Make your API easy to learn.
Good APIs are a design problem.
Idempotent methods
I won’t say things like that.
Let’s look at puppies.
hackett   hackett




hackett   hackett
...
/getAllDogs
/locationVerify
/foodNeeded
/createRecurringDogWalk
/giveDirectOrder
/healthCheck
/getRecurringDogWalkSchedule
/getLocation
/getDog
/massDogParty
/getNewDogsSince
/getRedDogs
/getSittingDogs
/dogStateChangesSearch
/replaceSittingDogsWithRunningDogs
/saveDog
...
A puppy’s world is big.
JnL               law_keven




Smithsonian's National Zoo    hackett
...                                  ...

/getAllDogs                          /getAllLeashedDogs

/verifyLocation                      /verifyVeterinarianLocation

/feedNeeded                          /feedNeededFood

/createRecurringWakeUp               /createRecurringMedication

/giveDirectOrder                     /doDirectOwnerDiscipline

/checkHealth                         /doExpressCheckupWithVeterinarian

/getRecurringWakeUpSchedule          /getRecurringFeedingSchedule

/getLocation                         /getHungerLevel

/getDog                              /getSquirrelChasingPuppies

/newDog                              /newDogForOwner

/getNewDogsSince                     /getNewDogsAtKennelSince

/getRedDogs                          /getRedDogsWithoutSiblings

/getSittingDogs                      /getSittingDogsAtPark

/setDogStateTo                       /setLeashedDogStateTo

/replaceSittingDogsWithRunningDogs   /replaceParkSittingDogsWithRunningDogs

/saveDog                             /saveMommaDogsPuppies

...                                  ...
We are on a slippery slope.
Keep the simple things simple.
Hopkinsii
We only need two URLs.
The first is for a collection.
/dogs
The second is for an element.
/dogs/bo
POST
GET
PUT
DELETE
CREATE
READ
UPDATE
DELETE
Resource     POST            GET        PUT        DELETE
             create          read      update      delete




                                     replace
           create a                              delete all
 /dogs                   list dogs   dogs with
           new dog                               dogs
                                     new dogs


                                     if exists
           treat as a
                                     update Bo
           collection
/dogs/bo              show Bo                    delete Bo
           create new
                                     if not
           dog in it
                                     create Bo



                 Wikipedia
Resource     POST            GET        PUT       DELETE
             create          read      update      delete




                                     replace
           create a                            delete all
 /dogs                   list dogs   dogs with
           new dog                             dogs
                                     new dogs


           treat as a                if exists
           collection                update Bo
/dogs/bo   create     show Bo                    delete Bo
           new dog                   if not
           in it                     create Bo



                 Wikipedia
Resource     POST              GET        PUT        DELETE
             create            read      update      delete




                                       bulk
           create a                                delete all
 /dogs                     list dogs   update
           new dog                                 dogs
                                       dogs


                                       if exists
                                       update Bo
/dogs/bo   error           show Bo                 delete Bo
                                       if not
                                       error



                   Wikipedia
Verbs are bad.
Nouns are good.
Plurals are better.
What about associations?
GET /owners/bob/dogs

POST /owners/bob/dogs
What about complex variations?
Cody Simms
Sweep variations under the ‘?’
/dogs?color=red&state=running&location=park
What about pagination?
Facebook
offset
limit


Twitter
page
rpp


LinkedIn
start
count
/dogs?limit=25&offset=50
What about searching?
Global
/search?q=fluffy+dog




Scoped
/owners/bob/dogs/search?q=fluffy
What about versioning?
Twilio
/2010-04-01/Accounts/



salesforce.com
/services/data/v20.0/sobjects/Account



Facebook
?v=1.0
/v1/dogs
Please give me exactly what I need.
LinkedIn
/people:(id,first-name,last-name,industry)




Facebook
/joe.smith/friends?fields=id,name,picture




Google (partial response)
?fields=title,media:group(media:thumbnail)
/dogs?fields=name,color,location
What about formats?
Google Data
?alt=json



Foursquare
/venue.json



Digg*
Accept: application/json
?type=json
* The type argument, if present, overrides the Accept header.
/dogs.json


/dogs/bo.json
What about partial updates?
What about errors?
meredithfarmer
Facebook            HTTP Status Code: 200

{"type":"OAuthException","message":"(#803) Some
of the aliases you requested do not exist:
foo.bar"}




Twilio              HTTP Status Code: 401

{"status":401,"message":"Authenticate","code":
20003,"more_info":"http://www.twilio.com/docs/
errors/20003"}




SimpleGeo           HTTP Status Code: 401

{"code":401,"message":"Authentication
Required"}
Code for code
200 - OK

401 - Unauthorized
http://en.wikipedia.org/wiki/List_of_HTTP_status_codes




Message for people
{“message” : “Verbose, plain language
description of the problem with hints about
how to fix it.”
“more_info” : “http://dev.teachdogrest.com/
errors/12345”}
What about the rest of the URL?
Facebook    graph.facebook.com

             api.facebook.com

             developers.facebook.com



Foursquare   api.foursquare.com
             developers.foursquare.com



   Twitter   api.twitter.com

             search.twitter.com

             stream.twitter.com

             dev.twitter.com
API gateway
api.teachdogrest.com



Developer connection
dev.teachdogrest.com



Do web redirects
api ! dev

developers ! dev
developer ! dev
What about defaults?
Format
json



Pagination (depends on data size)
limit=10&offset=0
What about exceptional stuff?
Client intercepts HTTP error codes
Twitter

/public_timelines.json?
suppress_response_codes=true


HTTP Status Code: 200


{"error" : "Could not authenticate
you." }
Always returns OK
/dogs?suppress_response_codes=true


Code for code ignoring
200 - OK


Message for people code
{“response_code” : “401”, “message” :
“Verbose, plain language description of the
problem with hints about how to fix it.”
“more_info” : “http://dev.teachdogrest.com/
errors/12345”, “code” : 12345}
Client supports limited HTTP methods
Method Parameter
create

/dogs?method=post
read

/dogs
update

/dogs/bo?method=put&location=park
delete

/dogs/bo?method=delete
Really? All of this? And iterate it?
Application




      API Virtualization Layer




API             API              API
Be RESTful
Only 2 URLs
No verbs
Use nouns as plurals
Sweep complexity behind the ‘?’
Borrow from leading APIs
Account for exceptional clients
Add virtualization layer
THANK YOU
Questions and ideas to:

Brian Mulloy
@landlessness
brian@apigee.com

More Related Content

What's hot

What's hot (20)

Migrating from Self-Managed Kubernetes on EC2 to a GitOps Enabled EKS
Migrating from Self-Managed Kubernetes on EC2 to a GitOps Enabled EKSMigrating from Self-Managed Kubernetes on EC2 to a GitOps Enabled EKS
Migrating from Self-Managed Kubernetes on EC2 to a GitOps Enabled EKS
 
CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton CI-CD Jenkins, GitHub Actions, Tekton
CI-CD Jenkins, GitHub Actions, Tekton
 
DevOps with GitHub Actions
DevOps with GitHub ActionsDevOps with GitHub Actions
DevOps with GitHub Actions
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführung
 
Introduction to Github Actions
Introduction to Github ActionsIntroduction to Github Actions
Introduction to Github Actions
 
Gitlab flow solo
Gitlab flow soloGitlab flow solo
Gitlab flow solo
 
DEVOPS 에 대한 전반적인 소개 및 자동화툴 소개
DEVOPS 에 대한 전반적인 소개 및 자동화툴 소개DEVOPS 에 대한 전반적인 소개 및 자동화툴 소개
DEVOPS 에 대한 전반적인 소개 및 자동화툴 소개
 
Domain Driven Design
Domain Driven DesignDomain Driven Design
Domain Driven Design
 
Git - Level 2
Git - Level 2Git - Level 2
Git - Level 2
 
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
Introduction to DevOps Tools | DevOps Training | DevOps Tutorial for Beginner...
 
Writing the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golangWriting the Container Network Interface(CNI) plugin in golang
Writing the Container Network Interface(CNI) plugin in golang
 
Docker containers : introduction
Docker containers : introductionDocker containers : introduction
Docker containers : introduction
 
GitHub Actions in action
GitHub Actions in actionGitHub Actions in action
GitHub Actions in action
 
DevOps vs Agile | DevOps Tutorial For Beginners | DevOps Training | Edureka
DevOps vs Agile | DevOps Tutorial For Beginners | DevOps Training | EdurekaDevOps vs Agile | DevOps Tutorial For Beginners | DevOps Training | Edureka
DevOps vs Agile | DevOps Tutorial For Beginners | DevOps Training | Edureka
 
GitHub Actions (Nakov at RuseConf, Sept 2022)
GitHub Actions (Nakov at RuseConf, Sept 2022)GitHub Actions (Nakov at RuseConf, Sept 2022)
GitHub Actions (Nakov at RuseConf, Sept 2022)
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Argocd up and running
Argocd up and runningArgocd up and running
Argocd up and running
 
大型製造業實踐DevOps 團隊之路
大型製造業實踐DevOps 團隊之路大型製造業實踐DevOps 團隊之路
大型製造業實踐DevOps 團隊之路
 
KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...
KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...
KPIs for APIs (and how API Calls are the new Web Hits, and you may be measuri...
 
Devops online training ppt
Devops online training pptDevops online training ppt
Devops online training ppt
 

More from Brian Mulloy

Applying Design Priciples to APIs - 2 of 4
Applying Design Priciples to APIs - 2 of 4 Applying Design Priciples to APIs - 2 of 4
Applying Design Priciples to APIs - 2 of 4
Brian Mulloy
 
KPIs for APIs - defrag 2010 - Brian Mulloy
KPIs for APIs - defrag 2010 - Brian MulloyKPIs for APIs - defrag 2010 - Brian Mulloy
KPIs for APIs - defrag 2010 - Brian Mulloy
Brian Mulloy
 

More from Brian Mulloy (6)

Swarms
SwarmsSwarms
Swarms
 
DetNodeCopterKickoff
DetNodeCopterKickoffDetNodeCopterKickoff
DetNodeCopterKickoff
 
Applying Design Priciples to APIs - 2 of 4
Applying Design Priciples to APIs - 2 of 4 Applying Design Priciples to APIs - 2 of 4
Applying Design Priciples to APIs - 2 of 4
 
Applying Design Priciples to APIs - 1 of 4
Applying Design Priciples to APIs - 1 of 4Applying Design Priciples to APIs - 1 of 4
Applying Design Priciples to APIs - 1 of 4
 
Two Ton API Client
Two Ton API ClientTwo Ton API Client
Two Ton API Client
 
KPIs for APIs - defrag 2010 - Brian Mulloy
KPIs for APIs - defrag 2010 - Brian MulloyKPIs for APIs - defrag 2010 - Brian Mulloy
KPIs for APIs - defrag 2010 - Brian Mulloy
 

Recently uploaded

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
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...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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?
 
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...
 
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 New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 

Teach a Dog to REST

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n