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

JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...
JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...
JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...HostedbyConfluent
 
Solr Exchange: Introduction to SolrCloud
Solr Exchange: Introduction to SolrCloudSolr Exchange: Introduction to SolrCloud
Solr Exchange: Introduction to SolrCloudthelabdude
 
patroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymentpatroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymenthyeongchae lee
 
The 10 Mistakes I've made...so you don't have to
The 10 Mistakes I've made...so you don't have toThe 10 Mistakes I've made...so you don't have to
The 10 Mistakes I've made...so you don't have toTara Hunt
 
Restful api design
Restful api designRestful api design
Restful api designMizan Riqzia
 
RESTful API 설계
RESTful API 설계RESTful API 설계
RESTful API 설계Jinho Yoo
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code firstConfiz
 
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander ZaitsevClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander ZaitsevAltinity Ltd
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질Young-Ho Cho
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsSolution4Future
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo
 
Real time replication using Kafka Connect
Real time replication using Kafka ConnectReal time replication using Kafka Connect
Real time replication using Kafka Connectconfluent
 

What's hot (20)

NestJS
NestJSNestJS
NestJS
 
JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...
JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...
JDBC Source Connector: What could go wrong? with Francesco Tisiot | Kafka Sum...
 
Solr Exchange: Introduction to SolrCloud
Solr Exchange: Introduction to SolrCloudSolr Exchange: Introduction to SolrCloud
Solr Exchange: Introduction to SolrCloud
 
patroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deploymentpatroni-based citrus high availability environment deployment
patroni-based citrus high availability environment deployment
 
Spring Security 5
Spring Security 5Spring Security 5
Spring Security 5
 
The 10 Mistakes I've made...so you don't have to
The 10 Mistakes I've made...so you don't have toThe 10 Mistakes I've made...so you don't have to
The 10 Mistakes I've made...so you don't have to
 
Restful api design
Restful api designRestful api design
Restful api design
 
RESTful API 설계
RESTful API 설계RESTful API 설계
RESTful API 설계
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
Sql Antipatterns Strike Back
Sql Antipatterns Strike BackSql Antipatterns Strike Back
Sql Antipatterns Strike Back
 
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander ZaitsevClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
ClickHouse in Real Life. Case Studies and Best Practices, by Alexander Zaitsev
 
도메인 주도 설계의 본질
도메인 주도 설계의 본질도메인 주도 설계의 본질
도메인 주도 설계의 본질
 
Python RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutionsPython RESTful webservices with Python: Flask and Django solutions
Python RESTful webservices with Python: Flask and Django solutions
 
Single page application
Single page applicationSingle page application
Single page application
 
CI/CD with Github Actions
CI/CD with Github ActionsCI/CD with Github Actions
CI/CD with Github Actions
 
Odoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new apiOdoo - From v7 to v8: the new api
Odoo - From v7 to v8: the new api
 
Expressjs
ExpressjsExpressjs
Expressjs
 
Models for hierarchical data
Models for hierarchical dataModels for hierarchical data
Models for hierarchical data
 
Real time replication using Kafka Connect
Real time replication using Kafka ConnectReal time replication using Kafka Connect
Real time replication using Kafka Connect
 

More from Brian Mulloy

DetNodeCopterKickoff
DetNodeCopterKickoffDetNodeCopterKickoff
DetNodeCopterKickoffBrian 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
 
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 4Brian Mulloy
 
Two Ton API Client
Two Ton API ClientTwo Ton API Client
Two Ton API ClientBrian 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 MulloyBrian 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

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Teach a Dog REST APIs

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