Creating Netflix Widgets from Freebase Queries
Freebase has just finished creating a process to import Netflix film data on a daily basis. Freebase now includes in their movie metadata the key for the Netflix API. For Netflix API developers, this makes it possible to leverage Freebase’s powerful query engine and create amazing application interfaces. But even for those people who have never used the Netflix API, this functionality allows developers to leverage Netflix’ widgets to create interfaces within their existing applications, without the hassle of OAuth. I’ll walk through the process of creating a Netflix widget based on a freebase query here.
Getting the Movie
Mel Gibson is a popular guy, who’s done a bunch of movies. But what has he done for us lately? The following freebase query asks what movies he’s done since January 1, 2009. I’ll go ahead and ask for the Netflix “Tiny URL” as that’s what we’ll need to create the Netflix widget.
[{ "name" : "Mel Gibson", "film": [{ "film": [{"initial_release_date>":"2009-01-01", "name":null, "key":[{"namespace":"/authority/netflix/tiny", "value":null}]}], "id": null }], "type": "/film/actor" }]
Turns out, he’s been taking it easy recently. There’s just a couple of movies released on DVD since the beginning of last year.
{ "code": "/api/status/ok", "result": [{ "film": [ { "film": [{ "key": [{ "namespace": "/authority/netflix/tiny", "value": "BVmIj" }], "name": "Edge of Darkness" }], "id": "/m/04lr63t" }, { "film": [{ "key": [{ "namespace": "/authority/netflix/tiny", "value": "BVssN" }], "name": "The Beaver" }], "id": "/m/09vnjl6" } ], "name": "Mel Gibson", "type": "/film/actor" }], "status": "200 OK", "transaction_id": "cache;cache01.p01.sjc1:8101;2010-07-16T21:13:40Z;0034" }
Creating the Widget
Now that we have the tiny URL, we can create a widget. The Netflix widget builder can be used to create a template for the widget you want to create. When you’re done configuring your widget, you’ll end up with some Javascript code that looks like this:
<script src=”http://jsapi.netflix.com/us/api/w/s/sp100.js” settings=”id=http://movi.es/BVdT5″></script>
Once you’ve got that, it’s a simple task to create new widgets. The Tiny URL you grabbed above is used to update the ID, so in the case of “Edge of Darkness” you’d put “BVmIj” in place of BVdT5 and end up with this:
<script src=”http://jsapi.netflix.com/us/api/w/s/sp100.js” settings=”id=http://movi.es/BVmIj”></script>
Which will render on your page like so:
Once you’ve gotten this all working to your satisfaction, you can even set up the widgets to include your developer key and earn money from Netflix via the developer Affilliate Program.
GEEK STUFF
freebase netflix widget