Slide 1

Slide 1 text

PROJECT DATE CLIENT 2012-07-26 ROBERT ALLEN / @ZIRCOTE RESTFUL WEB SERVICES VIA RFC-2616 PHP CHICAGO MEET-UP Ifbyphone_Guest IFBYPHONE 1 Thursday, July 26, 12

Slide 2

Slide 2 text

NETFLIX CONSUMER API REQUESTS NETFLIX API GROWTH JANUARY 2010...APRIL 2011 2 Thursday, July 26, 12

Slide 3

Slide 3 text

YOUTUBE ORGANIC GROWTH 3 Thursday, July 26, 12

Slide 4

Slide 4 text

FACEBOOK APPLICATION INTEGRATION 4 Thursday, July 26, 12

Slide 5

Slide 5 text

IFBYPHONE TECHNOLOGY EVOLUTION 5 Thursday, July 26, 12

Slide 6

Slide 6 text

Web Services 6 Thursday, July 26, 12

Slide 7

Slide 7 text

XML-RPC Invented 1998 Process Patented in 2006 Four times the bytes as xml Effectively ReST in practice 7 Thursday, July 26, 12

Slide 8

Slide 8 text

SOAP Control freaks dream. Transport agnostic WSDL, UDDI, WS-*, MTOM, 1.1, 1.2 8 Thursday, July 26, 12

Slide 9

Slide 9 text

Representation State Transfer 9 Thursday, July 26, 12

Slide 10

Slide 10 text

So, what is ReST? 10 Thursday, July 26, 12

Slide 11

Slide 11 text

It’s not... standard requirement always pretty always sane Agreed upon by more than 2 people in a room of 20. 11 Thursday, July 26, 12

Slide 12

Slide 12 text

It is... an architectural guideline very flexible or rigid As simple or complex as you make it. a living technology the culmination of previous works into a single suggested tool chest. 12 Thursday, July 26, 12

Slide 13

Slide 13 text

Roy Thomas Fielding. Dissertation: “Architectural Styles and the Design of Network- based Software Architectures” Principal Author of RFC-2608, RFC-2616, RFC-2396, RFC-1808, RFC-2145 and RFC-1945 “Life is a distributed object system. However, communication among humans is a distributed hypermedia system, where the minds intellect, the voice +gestures, eyes+ears, and imagination are all components. -- Roy T. Fielding 1998 13 Thursday, July 26, 12

Slide 14

Slide 14 text

RFC-1808 (June 1995) Relative URL RFC-1945 (May 1996) HTTP 1.0 RFC-2068 (January 1997) HTTP 1.1 RFC-2145 (May 1997) HTTP Version Numbers RFC-2396 (August 1998) Uniform Resource Identifiers RFC-2616 (June 1999) HTTP 1.1 Architectural Styles and the Design of Network-based Software Architectures. (2000) 14 Thursday, July 26, 12

Slide 15

Slide 15 text

THE FIELDING LEGACY 15 Thursday, July 26, 12

Slide 16

Slide 16 text

So what is RFC-2616? 16 Thursday, July 26, 12

Slide 17

Slide 17 text

Methods Headers Status Codes Content Negotiation Security Considerations Connection Handling and Parameters Caching 17 Thursday, July 26, 12

Slide 18

Slide 18 text

GET 18 Thursday, July 26, 12

Slide 19

Slide 19 text

resource?query_string 19 Thursday, July 26, 12

Slide 20

Slide 20 text

Lucene/Solr 20 Thursday, July 26, 12

Slide 21

Slide 21 text

Google Query Language 21 Thursday, July 26, 12

Slide 22

Slide 22 text

Riak 22 Thursday, July 26, 12

Slide 23

Slide 23 text

POST/PUT 23 Thursday, July 26, 12

Slide 24

Slide 24 text

Create and Modify raw body (xml, text, json...) multipart/form-data x-www-form- urlencoded 24 Thursday, July 26, 12

Slide 25

Slide 25 text

DELETE/HEAD/TRACE 25 Thursday, July 26, 12

Slide 26

Slide 26 text

Headers 26 Thursday, July 26, 12

Slide 27

Slide 27 text

Request & Response 27 Thursday, July 26, 12

Slide 28

Slide 28 text

Standard & User Defined 28 Thursday, July 26, 12

Slide 29

Slide 29 text

User Defined Headers User defined headers must begin with ‘X-’ X-FORWARDED-FOR 29 Thursday, July 26, 12

Slide 30

Slide 30 text

Content-Type resource.json resource.xml resource.csv resource.pdf 30 Thursday, July 26, 12

Slide 31

Slide 31 text

resource.json resource.xml resource.csv resource.pdf 30 Thursday, July 26, 12

Slide 32

Slide 32 text

resource.json resource.xml resource.csv resource.pdf 31 Thursday, July 26, 12

Slide 33

Slide 33 text

Accept resource.json resource.xml resource.csv resource.pdf 31 Thursday, July 26, 12

Slide 34

Slide 34 text

resource.en-us resource.en-uk resource.es-mx resources.fr-ca 32 Thursday, July 26, 12

Slide 35

Slide 35 text

resource.en-us resource.en-uk resource.es-mx resources.fr-ca 33 Thursday, July 26, 12

Slide 36

Slide 36 text

Accept-Language resource.en-us resource.en-uk resource.es-mx resources.fr-ca 33 Thursday, July 26, 12

Slide 37

Slide 37 text

Accept: application/json 34 Thursday, July 26, 12

Slide 38

Slide 38 text

Accept-Language: en-us 35 Thursday, July 26, 12

Slide 39

Slide 39 text

Accept-Charset: iso-8859-5 36 Thursday, July 26, 12

Slide 40

Slide 40 text

Functional Uses of Headers 37 Thursday, July 26, 12

Slide 41

Slide 41 text

Pagination: Range: items 1-20 Content-Range: items 1-20/200 206 Partial Content 38 Thursday, July 26, 12

Slide 42

Slide 42 text

E-Tag If-None-Match If-Match Idempotency & Caching 39 Thursday, July 26, 12

Slide 43

Slide 43 text

Content Negotiation Accept: application/json, application/xml, application/ json+hal;q=0.9,*/*;q=0.8 40 Thursday, July 26, 12

Slide 44

Slide 44 text

Rate Limiting X-RateLimit-Limit X-RateLimit-Remaining X-RateLimit-Reset 420 Enhance Your Calm (courtesy of Twitter) 41 Thursday, July 26, 12

Slide 45

Slide 45 text

Dysfunctional Uses of Headers 42 Thursday, July 26, 12

Slide 46

Slide 46 text

always sending a 200 regardless of state sending E-Tags but not using them assignment of errors to incorrect status advertising Content-Negotiation but failing to honor it. 43 Thursday, July 26, 12

Slide 47

Slide 47 text

Status Codes & Error Handling 44 Thursday, July 26, 12

Slide 48

Slide 48 text

Classification Groups 100 Informational 200 Successful 300 Redirection 400 Client Error 500 Server Error 45 Thursday, July 26, 12

Slide 49

Slide 49 text

418 I’m a teapot RFC-2324 HTCPCP 1.0 coffee-scheme://host/ pot_designator? additions 46 Thursday, July 26, 12

Slide 50

Slide 50 text

Other Status Code Considerations Not all user agents are friendly. Don’t be an unfriendly agent. not all 200s are created equal. 47 Thursday, July 26, 12

Slide 51

Slide 51 text

COMMITMENT 48 Thursday, July 26, 12

Slide 52

Slide 52 text

REST IS A LIVING INTERPRETATION EVOLVING DAILY 49 Thursday, July 26, 12

Slide 53

Slide 53 text

Want to Know More? www.ietf.org www.ics.uci.edu/~fielding www.zircote.com scholar.google.com => Roy Fielding groups.google.com => Api-Craft 50 Thursday, July 26, 12