Logo

Trailer Addict API

The TrailerAddict API was created for website publishers looking to easily embed trailers from TrailerAddict with variables under their control.

The TrailerAddict API currently allows for easy embedding of trailers with variables such as width, offset, trailer count, trailers by which film and more. Not only does this page provide web publishers with links and variables to use the API, but coding examples as well.

The TrailerAddict API delivers content in XML, so some type of XML parser will be necessary to use the results provided.

At this point in time, the API does NOT require an API_KEY to work. If the API were to receive too much abuse, an API_KEY requirement will be instated.


API Source

http://api.traileraddict.com/

API VARIABLES
Width: In pixels. Provide a width and the height will be created dynamically. If no width variable is provided, the player will default to 450px. Example: width=480

Count: Choose between one to eight trailers to list in the XML. The default number of trailers depends on other variables provided. Eight is the max allowed. Example: count=5

Featured: Yes or No. If featured variable does not exist, the API will default to yes. This will list all trailers TrailerAddict deems popular or important. If featured is set to 'no', then the most recent trailer additions will be listed. Example: featured=yes

Film: Want to list trailers by a particular film? Then you need the film keyword. To find this, just go to the film's page on TrailerAddict. Assuming you want all the trailers for Max Payne, you'd go to the film's page and, in the URL, you'll see: traileraddict.com/max-payne. The keyword for Max Payne is max-payne. Example: film=max-payne

Actor: Want to list trailers only by a particular actor? Then you need the actor's keyword. To find this, go to the actor's page on TrailerAddict. Assuming you want all the trailers with Brad Pitt in them, you'd go to his page and, in the URL, you'll see: traileraddict.com/tags/brad-pitt. The keyword for Brad Pitt is brad-pitt.

Please note that while the variables WIDTH and COUNT work with all API requests, FEATURED, ACTOR and FILM are their very own functions and cannot be combined.


Examples

You want a single featured trailer that rotates on your site dynamically:

http://api.traileraddict.com/?featured=yes

You want an XML to list the last 6 featured trailers on TrailerAddict:

http://api.traileraddict.com/?featured=yes&count=6

You want an XML to list the last 4 featured trailers on TrailerAddict, but you want the embed width to be 720px:

http://api.traileraddict.com/?featured=yes&count=4&width=720

You want the last three trailers released for The Curious Case of Benjamin Button.

http://api.traileraddict.com/?film=curious-case-benjamin-button&count=3

You want the most recent trailer featuring Gerard Butler:

http://api.traileraddict.com/?actor=gerard-butler

You want eight of the most recent trailers featuring Kate Beckinsale. But you also want the trailer to be 640px wide:

http://api.traileraddict.com/?actor=kate-beckinsale&count=8&width=640


Parsing the API

Once you have decided on which option(s) to choose, you can parse the API easily through PHP:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?featured=yes&count=2");

foreach(
$upcoming->trailer as $x => $updates)
{
   echo 
$updates->title;
   echo 
'<br>';
   echo 
'<span style="font-size:x-small">Source: <a href="'$updates->link .'">TrailerAddict</a></span>';
   echo 
'<br>';
   
//now echo the embedded trailer
   
echo $updates->embed;
   echo 
'<br><br>';    
    
    }
    
?>

See what this creates by going here.

*The XML can be parsed with options other than PHP. If you have PHP 4, there is a great parsing function here with instructions.


Latest Feature Trailer

If you want to feature the latest featured trailer from TrailerAddict (embed code only), you can do so by using the following code:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?featured=yes");

foreach(
$upcoming->trailer as $x => $updates)
{
   
   
//embed trailer
   
echo $updates->embed;
    
    }
    
?>

See what this creates by going here.


List 8 Links to Trailers for The Dark Knight

If you were looking to create a list of links to trailers for a given film, this would be one way to do it:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?film=the-dark-knight&count=8");

foreach(
$upcoming->trailer as $x => $updates)
{
   
    echo 
'<a href="'$updates->link .'">'$updates->title .'</a><br />';
    }
    
    
?>

See what this creates by going here.


List 4 of the Latest Trailers w/Philip Seymour Hoffman

Not only do you want the four latest trailers featuring Philip Seymour Hoffman, but your page can handle video widths up to 740px:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?actor=philip-seymour-hoffman&count=4&width=740");

foreach(
$upcoming->trailer as $x => $updates)
{
   
   echo 
$updates->embed;
   echo 
'<br><br>';    
    }
    
?>

See what this creates by going here.


IMDB ID Lookup

Have a system already in place that uses IMDB IDs for looking up films? TrailerAddict has recently implimented a beta version using IMDB IDs. But be warned, not all films (older especially) have IMDB ID numbers attached to them just yet. For the sample below, we'll use True Grit. If you search IMDB, you will see the ID number tt1403865 in the URL. That is the ID, but we only want the numbers, not the opening "tt". To get True Grit by IMDB IDyou can run the following query:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?imdb=1403865&count=4&width=680");

foreach(
$upcoming->trailer as $x => $updates)
{
   
   echo 
$updates->embed;
   echo 
'<br><br>';    
    }
    
?>

We don't have an example. But this query would pull the latest four videos from True Grit with the embed width set to 680 pixels. Remember: Height will adjust automatically to ensure proper viewing of the video at any width.


Source TrailerAddict

By default, the TrailerAddict API attempts to source its embeds back to our site. You can disable the included text link source by setting the variable "credit" to "no" in the command line. Using the example above, all we have to do is add:



<?php
$upcoming 
simplexml_load_file("http://api.traileraddict.com/?imdb=1403865&count=4&width=680&credit=no");

    
?>

And no more source... Though it saddens us... Greatly.


Simple API

Looking for an API that's easier to use for particular/single trailers? TrailerAddict recently added SimpleAPI, a function that gives embedding information, video information, and some general film info. The Simple API mimics the links on TrailerAddict, except with a different subdomain.



http://www.traileraddict.com/greenberg/trailer
(becomes)
http://simpleapi.traileraddict.com/greenberg/trailer


So, whether you have a link for a clip or a trailer, just swap out "www" in the URL and replace it with "simpleapi". If you wanted the film title, the release date of the film, the large embed code, cast and description of a given trailer...



<?php
$upcoming 
simplexml_load_file("http://simpleapi.traileraddict.com/avatar/trailer-b");
foreach(
$upcoming->trailer as $x => $updates)
{
   echo 
$updates->film;
   echo 
'<br>';
   echo 
$updates->release_date;
   echo 
'<br>';
   echo 
$updates->cast;
   echo 
'<br>';
   echo 
$updates->description;
   echo 
'<br>';
   
//now echo the embedded trailer (large)
   
echo $updates->embed_large;
    }
    
?>