This document provides guidance on designing RESTful APIs. It recommends using nouns instead of verbs, keeping URLs simple with only two endpoints per resource, and following conventions from leading APIs. Complex variations and optional parameters should be "swept behind the '?'." The document emphasizes designing for application developers by making APIs intuitive, consistent and complete while also accommodating exceptional clients. It suggests adding an API virtualization layer to handle complexity.
1 of 106
Downloaded 4,620 times
More Related Content
RESTful API Design, Second Edition
1. RESTful API Design
Second Edition
Brian Mulloy
@landlessness
11.03.11 @ 11:03:11 PST
Apigee Dial-in or VoIP
@apigee See Details in Chat Window
32. 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/1234 show Bo delete Bo
create new
if not
dog in it
create Bo
Wikipedia
33. 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/1234 create show Bo delete Bo
new dog if not
in it create Bo
Wikipedia
34. 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/1234 error show Bo delete Bo
if not
error
Wikipedia
53. 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"}
54. 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”}
71. JSON is for JavaScript Objects
var myObject = JSON.parse(response);
These looks funny in JavaScript
timing = myObject.created_at;
timing = myObject.DateTime;
86. 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}
101. Application
API Virtualization Layer
API API API
102. Be RESTful
Only 2 URLs
No verbs
Use nouns as plurals
Concrete over abstract
For JSON follow JavaScript conventions
Sweep complexity behind the ‘?’
Borrow from leading APIs
Account for exceptional clients
Add virtualization layer