the best web apis are web sites
DESCRIPTION
see: http://blog.whatfettle.com/2007/01/11/good-web-apis-are-just-web-sites/TRANSCRIPT
![Page 1: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/1.jpg)
A Web Friendly
API?
![Page 2: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/2.jpg)
Javascript AJAX
Python Ruby PHP Perl
Curl
![Page 3: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/3.jpg)
![Page 4: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/4.jpg)
One Thing in common ...
![Page 5: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/5.jpg)
They
HATE SOAP!
![Page 6: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/6.jpg)
But
!OVE The Web
![Page 7: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/7.jpg)
URIs identifythings
![Page 8: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/8.jpg)
and they can beanywhere ..
![Page 9: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/9.jpg)
![Page 10: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/10.jpg)
use cool URIs
![Page 11: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/11.jpg)
readRFC 2616
![Page 12: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/12.jpg)
Constrain Verbs
• GET / HEAD
• POST
• PUT
• DELETE
• OPTIONS
YAGNI?
![Page 13: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/13.jpg)
askIS IT SAFE?
![Page 14: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/14.jpg)
method safe idempotent semantics resource cacheable
-----------------------------------------------------------
GET | X X X X X |
HEAD | X X X X X |
PUT | X X X |
POST | * |
DELETE | X X X |
OPTIONS | X X X |
-----------------------------------------------------------
PROPFIND | X X X X * |
PROPPATCH | X X X |
MKCOL | * X X |
COPY | X X X |
MOVE | ? X X |
LOCK | X X |
UNLOCK | X X X |
PATCH | * X X |
-----------------------------------------------------------
understand HTTP methods
![Page 15: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/15.jpg)
think aboutrepresentations
• HTML
• RSS/Atom
• XML
• JSON
• whatever
![Page 16: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/16.jpg)
Warning!You are about to see
NakedProtocol Headers
![Page 17: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/17.jpg)
Content-NegotiationHTTP GET:
Accept: application/weatherml+xml; q=1.0,
application/xml; q=0.8,
text/html; q=0.5
Apache Server .htaccess:
AddType application/weatherml+xml wea
Options +MultiViews
./index.wea
./index.xml
./index.html
![Page 18: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/18.jpg)
enjoy the freecaching
HTTP GET http://flickr.com/photos/psd/2450160
If-Modified-Since: Fri, 31 Dec 1999 23:59:59 GMT
If-None-Match: 'guid-21343244324'
!
HTTP/1.1 412 Precondition Failed
![Page 19: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/19.jpg)
HTTP POST http://example.com/calls
Content-Type: application/x-www-form-urlencoded
Accept: text/xml; charset=utf-8
callingParty=tel:+447918808
calledParty=sip:Merlin
!
HTTP 1.1 201 Created
Location: http://example.com/calls/123213
Content-Type: text/xml; charset=utf-8
<callInfo>
<callId>http://example.com/calls/123213</callId>
<callStatus>Initial</callStatus>
</callInfo>
make Phone Call
![Page 20: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/20.jpg)
HTTP GET http://example.com/calls/123213
Accept: text/xml
!
200 OK
Content-Type: text/xml; charset=utf-8
<callInfo>
<callId> http://example.com/user/fred/calls/123213
<callStatus> CallInitial </callStatus>
<callingParty> tel:+447918880...
<calledParty> tel:+447918880...
<timeStarted> 2007-01-09 11:45:20
<duration> 502
<terminationStatus> CallNotTerminated
</callInfo>
get Call Info
![Page 21: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/21.jpg)
HTTP POST http://example.com/calls/123213Content-Type: application/x-www-form-urlencoded
callStatus=Terminated
!
202 Accepted Location: http://example.com/calls/123213
end Call
![Page 22: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/22.jpg)
list Recent CallsHTTP GET http://example.com/calls/feed
! 200 OK
Content-Type: application/atom+xml
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Phonebox Calls</title>
<link rel="self" href="http://example.com/calls/"
rel="alternate" type="text/html"/>
<updated>2007-01-0911:45:02Z</updated>
<author><name>Phonebox</name></author>
<id>tag:example.com,2007-01-09:/calls</id>
<entry>
<link href="http://example.com/user/psd/calls/1234567/"/>
<title>Call 1234567</title>
<id>tag:example.com/calls/1234567-200701091223313</id>
<summary>CallInformation</summary>
<updated>2005-10-13T18:30:02Z</updated>
</entry>
<entry>
<link href="http://example.com/user/fred/calls/17231667/"/>
...
![Page 23: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/23.jpg)
Overallhttp://example.com/callshttp://example.com/calls/feedhttp://example.com/user/paul/calls/feedhttp://example.com/user/paul/calls/7d6374da5http://example.com/user/paul/calls/search?callingParty=tel:%3A44791888http://example.com/smshttp://example.com/sms/feedhttp://example.com/user/fred/sms/7d6374da5http://example.com/user/fred/sms/inbox/feedhttp://example.com/user/fred/sms/inbox/7d6374da5http://example.com/user/fred/sms/inbox?search?from=tel:%3A44791888....
![Page 24: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/24.jpg)
Yes, Dear Reader,there's no API as such
it's just yet another Web site ..
![Page 25: The Best Web APIs are Web Sites](https://reader035.vdocument.in/reader035/viewer/2022081403/554f84e2b4c905435d8b4b4c/html5/thumbnails/25.jpg)
Surf long and prosper ..