repurposing the wheel

32
Repurposing the Wheel Leveraging Web Service APIs Jason Tan [email protected] October 18, 2008 - BarCamp Nashville

Upload: others

Post on 12-Sep-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Repurposing the Wheel

Repurposing the WheelLeveraging Web Service APIs

Jason Tan

[email protected]

October 18, 2008 - BarCamp Nashville

Page 2: Repurposing the Wheel

Who am I?

(who are we?)

Page 3: Repurposing the Wheel

We like ideas

Page 4: Repurposing the Wheel

We like quick results

Page 5: Repurposing the Wheel

We like to connect things

Page 6: Repurposing the Wheel

We don’t like the boring stuff

Page 7: Repurposing the Wheel

I like food

Citysearch

Yelp

Urban Spoon

Google

Page 8: Repurposing the Wheel

My wishlist

Keep track of your favorite restaurants

See who else likes your restaurants

Intelligently or randomly pick a restaurant

Keep track of where and what you eat

Page 9: Repurposing the Wheel

I don’t want to reinvent the wheel

Manage a database of user-submitted restaurants?No thanks.

Page 10: Repurposing the Wheel

Yelp has an API!

In about 3 hours, I had 3 out of the 4 requirements for my site mostly implemented

Page 11: Repurposing the Wheel

The resulthttp://nashville.eatshere.net

Page 12: Repurposing the Wheel

The resulthttp://nashville.eatshere.net

Page 13: Repurposing the Wheel

What are your options?

How do you incorporate content and functionality of another website onto yours?

Page 14: Repurposing the Wheel

Website link

External Link

Page 15: Repurposing the Wheel

Website syndication (RSS)

Page 16: Repurposing the Wheel

Website-provided widget

Page 17: Repurposing the Wheel

Website-provided API

Page 18: Repurposing the Wheel

Complete Control

ShellsBells: Why is it hotupstairs and freezing downstairs? #sitening

alysonisneat: all the vents inthe front of the #Sitening offices are covered and I’m still shivering!

Page 19: Repurposing the Wheel

Complete Access and Integration

Page 20: Repurposing the Wheel

Complete Access and Integration

Page 21: Repurposing the Wheel

Complete Access and Integration

Page 22: Repurposing the Wheel

Caveats

Rate limiting

Application performance

Page 23: Repurposing the Wheel

Solution

Caching

Scheduled refreshing

Page 24: Repurposing the Wheel

interface

Implementation

XML-RPCSOAPREST

Flickr Twitter Yelp ...

API API API API

cache

Page 25: Repurposing the Wheel

API Interface

Wrap API methods with logical functions

These functions call a common request function

Check cache

Make request if no cache

Do a little processing of the returned data

flickr = new FlickrInterface(API_KEY)sets = flickr->getSets()photos = flickr->getPhotos(set)

Page 26: Repurposing the Wheel

Pseudocodeclass myApiInterface:

int cacheLifetimestring apiEndpoint

function someAwesomeApiMethod(params)result = makeRequest(‘get.awesome’, params)do some data pre-processingreturn result

function anotherAwesomeApiMethod(params) ...

function makeRequest(method, params):cache = lookup_cache(method, params);if (cache.exists and cache.date > now() - cacheLifetime)

return cached_resultelse

result = request(apiEndpoint, method, params)save result to cachereturn result

if (cache.exists)return cached_result

Page 27: Repurposing the Wheel

Read only or write?

GET

PUT

POST

Page 28: Repurposing the Wheel

Example: MetaWeblog APIhttp://ravenseo.com/pluto-edit/

Page 29: Repurposing the Wheel

Example: MetaWeblog APIhttp://ravenseo.com/pluto-edit/

Page 30: Repurposing the Wheel

Consider offering an API for your web application

Builds user community

The community does some of the work for you!

Page 31: Repurposing the Wheel

You’d be surprised who offers APIs

Email marketing

Support / help desks

Printing

Sports

Weather

http://programmableweb.com/apis