Examples

Use the queries below to help you get a better understanding of the types of data you can get from IVA’s OData API 1.0. Here is a list of common queries that will return an abundance of data to support the trailers on your site.

We have found LINQPad to be a useful tool to help visualize the data and to run queries against the database. Download this free program and read our instructions for setting it up.

List Entertainment Programs releasing on DVD for a given date range:

LINQ

from re in ReleaseEvents.expand("EntertainmentProgram") 
where re.ReleaseDate >= #6/1/2011# and re.ReleaseDate < #7/1/2011# and re.ReleaseTypeId = 2 
select re

URL

http://api.internetvideoarchive.com/1.0/DataService/ReleaseEvents()?$filter=ReleaseDate ge datetime'2011-06-01' and ReleaseDate lt datetime'2011-07-01' and ReleaseTypeId eq 2&$expand=EntertainmentProgram&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

List Entertainment Programs releasing in theaters for a given date range

LINQ

from re in ReleaseEvents.expand("EntertainmentProgram") 
where re.ReleaseDate >= #6/1/2011# and re.ReleaseDate < #7/1/2011# and re.ReleaseTypeId = 0 
select re

URL

http://api.internetvideoarchive.com/1.0/DataService/ReleaseEvents()?$filter=ReleaseDate ge datetime'2011-06-01' and ReleaseDate lt datetime'2011-07-01' and ReleaseTypeId eq 0&$expand=EntertainmentProgram&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

List all screen captures for a particular actor (ID 8143, Tom Cruise)

LINQ

from o in PerformerScreenCaptures where o.PerformerId = 8143 select o

URL

http://api.internetvideoarchive.com/1.0/DataService/PerformerScreenCaptures()? $filter=Performerid eq 8143&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Select an EntertainmentProgram by PublishedId

LINQ

From o In EntertainmentPrograms Where o.Publishedid = 749049 Select o

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms(749049)? Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Select an EntertainmentProgram including all VideoAssets by PublishedId

LINQ

From o In EntertainmentPrograms.expand("VideoAssets") 
Where o.Publishedid = 749049 
Select o

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms(749049)? $expand=VideoAssets&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Select Title and PublishedID of all Movie Trailer VideoAssets

LINQ

From o In VideoAssets 
where o.DefaultVideoAsset = "true" and o.OkToEncodeAndServe = true and o.MediaId = 0 
Select o.PublishedId, o.Title

URL

http://api.internetvideoarchive.com/1.0/DataService/VideoAssets()?$filter=((DefaultVideoAsset eq 'true') and (OkToEncodeAndServe eq true)) and (MediaId eq 0) &$select=Publishedid,Title&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Select a ProgramToPerformerMap and expand results to include the EntertainmentProgram, the Performers, and the Images of the Performers

LINQ

From o In ProgramToPerformerMaps.expand("Performer/PerformerScreenCapture,EntertainmentProgram") 
where o.PublishedId = 749049 
Select o

URL

http://api.internetvideoarchive.com/1.0/DataService/ProgramToPerformerMaps()? $filter=PublishedId eq 749049&$expand=Performer/PerformerScreenCapture,EntertainmentProgram &Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Select All EntertainmentPrograms where the MovieCategory = Drama

LINQ

From o In EntertainmentPrograms 
where o.MovieCategory.Category = "Drama" 
Select o

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms()? $filter=MovieCategory/Category eq 'Drama'&Developerid=B43BF933-5CB5-434A-B0A8-717FC149FBED

Live Example : View Results

Return results in JSON format – get your API results returned in JSON format by adding “format=json” to your query

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms(749049)?$format=json&Developerid={yourid}

JSONP supported with the “$callback” feature

JSONP is script tag injection, passing the response from the server in to a user specified function. The following example shows the callback feature. Callback along with the format=json will allow you to pass the API request results back to a function(cb) and allows for cross domain JSON requests.

URL

http://api.internetvideoarchive.com/1.0/DataService/ReleaseEvents()?$top=1&$format=json&$callback=cb&developerid={yourid}

Paging Example Query

Since the IVA OData API can only return 500 records at a time it is sometimes required to write a query that will page through the data or get the next set. Below is an example demonstrating one way to do paging using “Top” and “Skip”. Continue the pattern to get all the records.

URL to get first set of records 1 – 500

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms?$top=500

URL to get second set of records 501 – 1000

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms?$top=500&$skip=500

URL to get third set of records 1001 – 1500

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms?$top=500&$skip=1000

Query to get video assets where width is > 1000 and all movie media types

URL

http://api.internetvideoarchive.com/1.0/DataService/VideoAssets()/$count?$filter=((cast(SourceWidth,'Edm.Int32')) gt 1000) and (((((MediaId eq 0) or (MediaId eq 5)) or (MediaId eq 6)) or (MediaId eq 10)) or (MediaId eq 20))&developerid={YOURDEVELOPERID}

Query to get video assets and Entertainment Program Information for TV Series, TV Season, and TV Episode where the date Modified is between now and 1 day ago

LINQ

(from re in EntertainmentPrograms.expand("VideoAssets") 
where re.DateModified > datetime.now.adddays(-1) and (re.MediaId=26 or re.MediaId=24 or re.MediaId=27 or re.MediaId=25) 
select re)

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms()?$filter=(DateModified gt datetime'2012-04-09T16:30:20.9774163-04:00') and ((((MediaId eq 26) or (MediaId eq 24)) or (MediaId eq 27)) or (MediaId eq 25))&$expand=VideoAssets

Query to demonstrate the Related Entertainment Programs expansion from the EntertainmentPrograms Entity

This is good for traversing TV and finding Season and Episode information from the Series Entertainment Program.

LINQ

from s in EntertainmentPrograms.expand("RelatedEntertainmentPrograms/RelatedEntertainmentPrograms/RelatedEntertainmentPrograms") 
where s.PublishedID = 344435 
select s

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms(344435)?$expand=RelatedEntertainmentPrograms/RelatedEntertainmentPrograms/RelatedEntertainmentPrograms

Query to get a matching table to ingest IVA Published ID’s based on Title, First Released Year and Director Name

LINQ

(From o In VideoAssets 
where o.DefaultVideoAsset = "true" and o.OkToEncodeAndServe = true and o.MediaId = 0 
Select o.PublishedId, o.Title, o.EntertainmentProgram.FirstReleasedYear, o.EntertainmentProgram.Director.FullName).skip(2000).take(500)

URL

http://api.internetvideoarchive.com/1.0/DataService/VideoAssets()?$filter=((DefaultVideoAsset eq 'true') and (OkToEncodeAndServe eq true)) and (MediaId eq 0)&$skip=2000&$top=500&$expand=EntertainmentProgram,EntertainmentProgram/Director&$select=Publishedid,Title,EntertainmentProgram/FirstReleasedYear,EntertainmentProgram/Director/FullName

Matching Table Query: Use this query to ingest data from IVA to mach against your database

LINQ

(From titles In EntertainmentPrograms 
Where titles.MediaId = 0 
Select New With {titles.Title, titles.Director, titles.FirstReleasedYear, titles.Publishedid,.Performers = From p In titles.ProgramToPerformerMaps 
Select p.Performer.FullName, p.Performer.PerformerID}).Skip(5000).Take(500)

URL

http://api.internetvideoarchive.com/1.0/DataService/EntertainmentPrograms()?$filter=MediaId eq 0&$skip=5000&$top=500&$expand=Director,ProgramToPerformerMaps,ProgramToPerformerMaps/Performer&$select=Title,Director/*,FirstReleasedYear,Publishedid,ProgramToPerformerMaps/Performer/FullName,ProgramToPerformerMaps/Performer/PerformerID&developerID=(yourID)

Here are some examples that we use on our Video Detective website!

Requesting Images For A Particular Title

URL

http://api.internetvideoarchive.com/1.0/DataService/ImagesToTitleOrPerformerMaps()?$filter=PublishedId eq {Insert Publishedid}&$expand=Image,ImagesCategory&developerid={Insert Developerid}

Requesting Performers For A Particular Title

URL

http://api.internetvideoarchive.com/1.0/DataService/ProgramToPerformerMaps()?$filter=PublishedId eq {Insert Publishedid}&$expand=Performer&developerid={Insert Developerid}

Movies with a release date greater than the specified date: DateTime Format = 2012-04-10

URL

http://api.internetvideoarchive.com/1.0/DataService/ReleaseEvents()?$filter=((ReleaseDate gt datetime'{ Insert Date }') and ((cast(ReleaseTypeId,'Edm.Int32')) eq 0)) and ((cast(ReleaseCountryId,'Edm.Int32')) eq 0)&$orderby=ReleaseDate&$expand=EntertainmentProgram&developerid={Insert Developerid}

Top Box Office

URL

http://api.internetvideoarchive.com/1.0/DataService/ListToProgramMaps()?$filter=TitleListId eq 5503&$orderby=Sortorder&$expand=VideoAsset&developerid={Insert Developerid}

Get Media Poster By Publishedid

URL

http://api.internetvideoarchive.com/1.0/DataService/Posters({Insert Publishedid})&developerid={Insert Developerid}

Get Media Description if there is one By Publishedid

URL

http://api.internetvideoarchive.com/1.0/DataService/Descriptions({Insert Publishedid})?&developerid={Insert Developerid}