repurposing the wheel

Post on 12-Sep-2021

4 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Repurposing the WheelLeveraging Web Service APIs

Jason Tan

jason@sitening.com

October 18, 2008 - BarCamp Nashville

Who am I?

(who are we?)

We like ideas

We like quick results

We like to connect things

We don’t like the boring stuff

I like food

Citysearch

Yelp

Urban Spoon

Google

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

I don’t want to reinvent the wheel

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

Yelp has an API!

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

The resulthttp://nashville.eatshere.net

The resulthttp://nashville.eatshere.net

What are your options?

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

Website link

External Link

Website syndication (RSS)

Website-provided widget

Website-provided API

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!

Complete Access and Integration

Complete Access and Integration

Complete Access and Integration

Caveats

Rate limiting

Application performance

Solution

Caching

Scheduled refreshing

interface

Implementation

XML-RPCSOAPREST

Flickr Twitter Yelp ...

API API API API

cache

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)

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

Read only or write?

GET

PUT

POST

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

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

Consider offering an API for your web application

Builds user community

The community does some of the work for you!

You’d be surprised who offers APIs

Email marketing

Support / help desks

Printing

Sports

Weather

http://programmableweb.com/apis

top related