A First Class Web Citizen

Preview:

DESCRIPTION

Presentation from The Highland Fling conference on things to understand when designing APIs along with a few design guidelines.

Citation preview

A First Class Web Citizen

Gareth Rushgrove | morethanseven.net

Some People Use Browsers

Gareth Rushgrove | morethanseven.net

Some People Don’t Use Browsers

Gareth Rushgrove | morethanseven.net

urllib.urlopen('http://twitter.com/statuses/update.xml').read

Some People Aren't People, They're Robots

Gareth Rushgrove | morethanseven.net

And Not Everything Is a Website

Gareth Rushgrove | morethanseven.net

The Web Is On Your Desktop Too

Gareth Rushgrove | morethanseven.net

And Sometimes It’s a Rabbit...

Gareth Rushgrove | morethanseven.net

...Sort Of

Gareth Rushgrove | morethanseven.net

What Is A Designer To Do?

Gareth Rushgrove | morethanseven.net

Understand The Web As A Platform

Gareth Rushgrove | morethanseven.net

1

Native To A Web Of Data

Gareth Rushgrove | morethanseven.net

“An aggregate web of connected data sources and services

Tom Coates

A Semantic Web?

Gareth Rushgrove | morethanseven.net

“The Semantic Web is the application of weblike design to data

Tim Berners-Lee

Websites Talking To Websites

Gareth Rushgrove | morethanseven.net

“Mashups are the most interesting innovation in software development in 20 years

Douglas Crockford

APIs As User Interfaces

Gareth Rushgrove | morethanseven.net

“The API is the product Todd Sampson

2Understand HTTP

Gareth Rushgrove | morethanseven.net

Methods You Know

Gareth Rushgrove | morethanseven.net

GET, POST

Sample GET Request

Gareth Rushgrove | morethanseven.net

GET /index.html HTTP/1.1Host: www.example.com

Sample Response

Gareth Rushgrove | morethanseven.net

HTTP/1.1 200 OKDate: Mon, 23 May 2005 22:38:34 GMTServer: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)Last-Modified: Wed, 08 Jan 2003 23:11:55 GMTEtag: "3f80f-1b6-3e1cb03b"Accept-Ranges: bytesContent-Length: 438Connection: closeContent-Type: text/html; charset=UTF-8

Methods You Don’t

Gareth Rushgrove | morethanseven.net

HEAD, PUT, DELETE, TRACE, OPTIONS

Everyone knows 404 Not Found

Gareth Rushgrove | morethanseven.net

And Maybe 500 Internal Server Error

Gareth Rushgrove | morethanseven.net

But What About 200 Found

Gareth Rushgrove | morethanseven.net

Or 503 Service Unavailable

Gareth Rushgrove | morethanseven.net

Applications

Gareth Rushgrove | morethanseven.net

3Understand URLs

Gareth Rushgrove | morethanseven.net

The Webs Coordinates

Gareth Rushgrove | morethanseven.net

“The Web is an information space. Human

Dan Connolly

beings have a lot of mental machinery for manipulating, imagining, and finding their way in spaces. URIs are the points in that space

URL Design

Gareth Rushgrove | morethanseven.net

“What, design a URI? I have to design URIs? Yes, you have to think about it

Tim Berners-Lee

Good or Bad?

Gareth Rushgrove | morethanseven.net

http://flickr.com/photos

http://del.icio.us/tag/highlandfling

http://news.bbc.co.uk/sport1/hi/football/eng_prem/7309369.stm

http://musicbrainz.org/ws/1/artist

Framework Of Choice

Gareth Rushgrove | morethanseven.net

from django.conf.urls.defaults import *

urlpatterns = patterns('', (r'^articles/2003/$', 'news.views.special_case_2003'), (r'^articles/(\d{4})/$', 'news.views.year'), (r'^articles/(\d{4})/(\d{2})/$', 'news.views.month'), (r'^articles/(\d{4})/(\d{2})/(\d+)/$', 'news.views.article'),)

Designing Good APIs

Gareth Rushgrove | morethanseven.net

Prodable

Gareth Rushgrove | morethanseven.net

1

Curl == Stick

Gareth Rushgrove | morethanseven.net

curl --get http://musicbrainz.org/ws/1/artist/ -d type=xml -d query="delgados"

A Response

Gareth Rushgrove | morethanseven.net

<?xml version="1.0" encoding="UTF-8"?><metadata xmlns="http://musicbrainz.org/ns/mmd-1.0#" xmlns:ext="http://musicbrainz.org/ns/ext-1.0#"> <artist-list count="1" offset="0"> <artist id="d629843e-d2b9-4665-a203-19f9c7f811ef" type="Group" ext:score="100"> <name>The Delgados</name> <sort-name>Delgados, The</sort-name> <life-span begin="1995" end="2005-04"/> </artist> </artist-list></metadata>

2Hackable

Gareth Rushgrove | morethanseven.net

A Simple Trick

Gareth Rushgrove | morethanseven.net

Tada!

Gareth Rushgrove | morethanseven.net

Variables In URLs

Gareth Rushgrove | morethanseven.net

http://twitter.com/{username}

3Multilingual

Gareth Rushgrove | morethanseven.net

Open

Gareth Rushgrove | morethanseven.net

4

Fire Eagle and Dopplr

Gareth Rushgrove | morethanseven.net

5Transparent

Gareth Rushgrove | morethanseven.net

Can Your Website Be Your API?

Gareth Rushgrove | morethanseven.net

What About Other Websites?

Gareth Rushgrove | morethanseven.net

6Obvious

Gareth Rushgrove | morethanseven.net

Understand

Gareth Rushgrove | morethanseven.net

2. HTTP

3. URLs

1. The Web As A Platform

Make Your API

6. Obvious

Gareth Rushgrove | morethanseven.net

4. Open

2. Hackable

3. Multilingual

1. Prodable

5. Transparent

Thanks flickr

Gareth Rushgrove | morethanseven.net

flickr.com/photos/stoweboyd/2350135191/

flickr.com/photos/sjaek/275710273/

flickr.com/photos/lkfdesign/365335459/

flickr.com/photos/mn_francis/418495671/

flickr.com/photos/tripu/267155109/

flickr.com/photos/jessefriedman/1435220149/

flickr.com/photos/sanbeiji/1821188052/

flickr.com/photos/lwr/2276706021/

flickr.com/photos/brocktice/1444774312/

flickr.com/photos/qwirksilver/104266807/

flickr.com/photos/deapeajay/2267569368/

flickr.com/photos/queen_of_subtle/461631577/

flickr.com/photos/wongjunhao/2189540204/

flickr.com/photos/warhead/2053343/

flickr.com/photos/stoweboyd/2350976688/

End

Gareth Rushgrove | morethanseven.net

Recommended