62
White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies Bryan Hirsch, Tech Lead, New Media Technologies Thursday, May 2, 13

White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

  • Upload
    others

  • View
    9

  • Download
    0

Embed Size (px)

Citation preview

Page 1: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

White House Web API StandardsOpen Source, Open Data

Executive Office of the President

Leigh Heyman, Director of New Media Technologies

Bryan Hirsch, Tech Lead, New Media Technologies

Thursday, May 2, 13

Page 2: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

“Among our commitments, we’re launching a new online tool – called ‘We the People’ -- to allow Americans to directly petition

the White House, and we’ll share that technology so any government in the world can enable its citizens to do the same.”

-- President Barack Obama, September 20, 2011

Thursday, May 2, 13

Page 3: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Open Source at the White House

September 2011

Thursday, May 2, 13

Page 4: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Thursday, May 2, 13

Page 5: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

APIs at the White House??

Thursday, May 2, 13

Page 6: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

APIs at the White House??

Thursday, May 2, 13

Page 7: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

https://github.com/whitehouse/api-standards

Thursday, May 2, 13

Page 8: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 9: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 10: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

Thursday, May 2, 13

Page 11: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

nodes

entities

taxonomy terms

sites/default/files

Thursday, May 2, 13

Page 12: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

nodes

entities

taxonomy terms

sites/default/files

Thursday, May 2, 13

Page 13: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

Thursday, May 2, 13

Page 14: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

Thursday, May 2, 13

Page 15: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

petitions/civil-rights/2011petitions/economy/2013petitions/environment/2012

Thursday, May 2, 13

Page 16: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

petitions/civil-rights/2011petitions/economy/2013petitions/environment/2012

Thursday, May 2, 13

Page 17: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

petitions/civil-rights/2011petitions/economy/2013petitions/environment/2012

Thursday, May 2, 13

Page 18: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Maintainability

Thursday, May 2, 13

Page 19: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

REST

Thursday, May 2, 13

Page 20: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

REST

Great. Now what do we do?

Thursday, May 2, 13

Page 21: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Pragmatic REST• Approach• API Standards• How to use it • How to contribute

Web API Design, by Brian Mulloy

Thursday, May 2, 13

Page 22: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Facade Pattern

API Facade Pattern, by Brian Mulloy

Thursday, May 2, 13

Page 23: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 24: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Pragmatic REST

http://api.example.gov/v1/magazines.json

http://example.gov/api/v1/magazines.xml

Thursday, May 2, 13

Page 25: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Versions

Thursday, May 2, 13

Page 26: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Versions

v1, v2, v3 Good

v-1.1, v1.2, 1.3 Bad

Thursday, May 2, 13

Page 27: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

RESTful URLs

Thursday, May 2, 13

Page 28: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

nouns goodverbs bad

Web API Design, by Brian Mulloy

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 29: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Web API Design, by Brian Mulloy

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 30: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Web API Design, by Brian Mulloy

• Approach• API Standards• How to use it • How to contribute

/getAllLeashedDogs

/verifyVetrinarianLocation

/feedNeededFood

/createRecurringMedication

/doDirectOwnerDicipline

/doExpressCheckupWithVetrinarian

/getRecurringFeedingSchedule

/getHungerLevel

/getSquirrelsChasingPuppies

/newDogForOwner

/getNewDogsAtKennelSince

/getRedDogsWithoutSiblings

/getSittingDogsAtPark

/getLeashedDogsStateTo

/replaceParkSittingDogsWithRunningDogs

Thursday, May 2, 13

Page 31: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Resource

POST GET PUT DELETE

create read update delete

/dogs

/dogs/1234

Create new dogs List dogs Bulk update

Delete all dogs

Error Show BoIf exists, update Bo; if not, error

Delete Bo

HTTP verbs

Web API Design, by Brian Mulloy

Thursday, May 2, 13

Page 32: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

Thursday, May 2, 13

Page 33: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

Thursday, May 2, 13

Page 34: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

/v1/magazines.json?topic=economy

Thursday, May 2, 13

Page 35: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

/v1/magazines.json?topic=economy

/v1/magazines/1234.json

Thursday, May 2, 13

Page 36: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

/v1/magazines.json?topic=economy

/v1/magazines/1234.json

/v1/magazines/1234/articles.json

Thursday, May 2, 13

Page 37: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

/v1/magazines.json?topic=economy

/v1/magazines/1234.json

/v1/magazines/1234/articles.json

/v1/magazines/1234.json?

fields=title,subtitle,date

Thursday, May 2, 13

Page 38: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

http://api.example.gov/...

Good

GET

/v1/magazines.json

/v1/magazines.json?topic=economy

/v1/magazines/1234.json

/v1/magazines/1234/articles.json

/v1/magazines/1234.json?

fields=title,subtitle,date

POST

/v1/magazines/1234/articles

Thursday, May 2, 13

Page 39: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Badhttp://api.example.gov/...

Thursday, May 2, 13

Page 40: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Bad

GET

/magazine

/magazine/1234

/publisher/magazine/1234

http://api.example.gov/...

Thursday, May 2, 13

Page 41: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Bad

GET

/magazine

/magazine/1234

/publisher/magazine/1234

POST

/magazine/1234/create

http://api.example.gov/...

Thursday, May 2, 13

Page 42: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Bad

GET

/magazine

/magazine/1234

/publisher/magazine/1234

POST

/magazine/1234/create

/magazine/2011/desc

http://api.example.gov/...

Thursday, May 2, 13

Page 43: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Responses

Thursday, May 2, 13

Page 44: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Responses

"tags": [

{"id": "125", "name": "Environment"},

{"id": "834", "name": "Water Quality"}

],

Thursday, May 2, 13

Page 45: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Responses

"tags": [

{"id": "125", "name": "Environment"},

{"id": "834", "name": "Water Quality"}

],

Good

Thursday, May 2, 13

Page 46: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Responses

"tags": [

{"id": "125", "name": "Environment"},

{"id": "834", "name": "Water Quality"}

],

"tags": [

{"125": "Environment"},

{"834": "Water Quality"}

],

Good

Thursday, May 2, 13

Page 47: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Responses

"tags": [

{"id": "125", "name": "Environment"},

{"id": "834", "name": "Water Quality"}

],

"tags": [

{"125": "Environment"},

{"834": "Water Quality"}

],

Bad

Good

Thursday, May 2, 13

Page 48: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Error handling

Thursday, May 2, 13

Page 49: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Error handling• 200 - OK• 400 - Bad Request• 500 - Internal Server Error

Thursday, May 2, 13

Page 50: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

Error handling

{

"status" : "400",

"developerMessage" : "Verbose, plain language description of the problem. Provide

developers suggestions about how to solve their problems here",

"userMessage" : "This is a message that can be passed along to end-users,

if needed.",

"errorCode" : "444444",

"moreInfo" : "http://www.example.gov/developer/path/to/help/for/444444,

http://drupal.org/node/444444",

}

Thursday, May 2, 13

Page 51: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Record limits

Thursday, May 2, 13

Page 52: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Record limits{

"metadata": {

"resultset": {

"count": 50,

"offset": 25,

"limit": 25

}

},

"results": [ {...} ],

}

Thursday, May 2, 13

Page 53: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Request & response examples

Thursday, May 2, 13

Page 54: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Mock responses

API Facade Pattern, by Brian Mulloy

Thursday, May 2, 13

Page 55: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

JSONP

Thursday, May 2, 13

Page 57: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 58: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 59: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Requirements

Code review

QA

Thursday, May 2, 13

Page 60: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Thursday, May 2, 13

Page 61: White House Web API Standards - Amazon S3 · White House Web API Standards Open Source, Open Data Executive Office of the President Leigh Heyman, Director of New Media Technologies

• Approach• API Standards• How to use it • How to contribute

Issues&

Pull requests

Thursday, May 2, 13