A quick tour of OData using Netflix


image

OData is a web protocol based on open standards for RESTful querying and modification of exposed collections of data. It takes the basics of REST and adds mechanisms for addressing, metadata, batching, and data representation using HTTP, AtomPub, Atom and JSON.

Try to locate Nicole Kidman:

http://odata.netflix.com/Catalog/People?$filter=endswith(Name,’Kidman’)

Too many Kidmans? Choose the top record:

http://odata.netflix.com/Catalog/People?$filter=endswith(Name,’Kidman’)&$top=1

Not perhaps the best way of finding Nicole (‘Papa?’), use the primary key instead:

http://odata.netflix.com/Catalog/People(49446)

Which films has Nicole been in? Who could forget the classic “Days of Thunder” with Tom Cruise as “Cole Trickle”:

http://odata.netflix.com/Catalog/People(49446)/TitlesActedIn

What if I wanted Nicole’s info as well as the titles she’s acted in?:

http://odata.netflix.com/Catalog/People(49446)?$expand=TitlesActedIn

Too much data? Sort these titles alphabetically and return the first page of data for a page size of 3:

http://odata.netflix.com/Catalog/People(49446)/TitlesActedIn?$orderby=ShortName&$top=3

But to do paging I’ll be needing the total record count (notice m:count element with value 47):

http://odata.netflix.com/Catalog/People(49446)/TitlesActedIn?$orderby=ShortName&$top=3&$inlinecount=allpages

Next page:

http://odata.netflix.com/Catalog/People(49446)/TitlesActedIn?$orderby=ShortName&$top=3&$inlinecount=allpages&$skip=3

Prefer JSON? Well, there’s no accounting for taste but I know “Cole Trickle” preferred it too:

http://odata.netflix.com/Catalog/People(49446)/TitlesActedIn?$orderby=ShortName&$top=3&$inlinecount=allpages&$skip=3&$format=json

For more including exposing and consuming OData goto ->

 OData: The Open Data Protocol – Mike Taulty’s Blog – Mike Taulty’s Blog

Advertisements

5 thoughts on “A quick tour of OData using Netflix

  1. I don’t drop a leave a response, but after looking at a few of the responses on this page A quick tour of
    OData using Netflix | Vincent Leung .NET Tech Clips. I actually do have a couple of questions for you if you tend not to mind.
    Could it be only me or does it look like a few of these
    comments appear like they are coming from brain dead visitors?
    😛 And, if you are writing on other online social sites, I’d like to follow you.
    Could you list of the complete urls of all your shared pages like your twitter feed,
    Facebook page or linkedin profile?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s