Patrick's Aviation API


Table of Contents

Overview
Get a Specific Video
Get Videos By Tags
Get Videos By User
PHP XML Parser

Overview

The Patrick's Aviation application programming interface (API) allows developers to retrieve data on Patrick's Aviation videos, which you can do whatever you want with. Data is retrieved using REST requests and returned via XML.

Get a Specific Video

You can retrieve data on a specific video by sending REST requests to the following URL. Replace the value of ID with the ID of the video you wish to retrieve (the ID can be found in the videos URL, ex: http://www.patricksaviation.com/videos/erwan_67/238/).

http://www.patricksaviation.com/api/?id=ID

Example Response
<response> <video> <id>238</id> <user>erwan_67</user> <name>Le Mirage Du Tchad</name> <description>This high quality video of very low level and formation flying...</description> <length>19:41</length> <size>140.69</size> <resolution>720 x 576</resolution> <rating>4.42</rating> <views>90,210</views> <comments>49</comments> <url>http://www.patricksaviation.com/videos/erwan_67/238/</url> <img>http://www.patricksaviation.com/uploads/videos/238.jpg</img> <imgThumb>http://www.patricksaviation.com/uploads/videos/thumbs/238.jpg</imgThumb> <imgTiny>http://www.patricksaviation.com/uploads/videos/tiny/238.jpg</imgTiny> </video> </response>


Get Videos By Tags

You can retrieve a list of videos and their corresponding data for a tag or keyword phrase by sending REST requests to the following URL. Replace the value of TAG with the tag or keyword phrase you wish to retrieve data for. Will return any number of videos in descending order of relevancy.

http://www.patricksaviation.com/api/?tag=TAG

By default, this returns videos that match all words specified by TAG. You can request videos that match an exact phrase by surrounding that phrase in double quotes (").

http://www.patricksaviation.com/api/?tag="Mirage 2000"

Example Response
<response> <video> <id>268</id> <user></user> <name>Eagle</name> <description>A collage of F-15 Eagle clips, harvested from various other...</description> <length>03:48</length> <size>23.77</size> <resolution>320 x 240</resolution> <rating>3.27</rating> <views>4,536</views> <comments>0</comments> <url>http://www.patricksaviation.com/videos/Guest/268/</url> <img>http://www.patricksaviation.com/uploads/videos/268.jpg</img> <imgThumb>http://www.patricksaviation.com/uploads/videos/thumbs/268.jpg</imgThumb> <imgTiny>http://www.patricksaviation.com/uploads/videos/tiny/268.jpg</imgTiny> </video> <video> ..... </video> </response>


Get Videos By User

You can retrieve a list of videos and their corresponding data uploaded by a specific user by sending REST requests to the following URL. Replace the value of USER_NAME with the user name of the user you'd like to retrieve data for (this must be encoded according to RFC 1738). Will return any number of videos in ascending order of their upload date.

http://www.patricksaviation.com/api/?user_name=USER_NAME

Example Response
<response> <video> <id>1374</id> <user>Baron</user> <name>An A4-AR Fly By</name> <description></description> <length>00:07</length> <size>1.18</size> <resolution>320 x 240</resolution> <rating>2.79</rating> <views>1,349</views> <comments>2</comments> <url>http://www.patricksaviation.com/videos/Baron/1374/</url> <img>http://www.patricksaviation.com/uploads/videos/1374.jpg</img> <imgThumb>http://www.patricksaviation.com/uploads/videos/thumbs/1374.jpg</imgThumb> <imgTiny>http://www.patricksaviation.com/uploads/videos/tiny/1374.jpg</imgTiny> </video> <video> ..... </video> </response>


PHP XML Parser

Here is an example XML parser written in PHP which can be used to retrieve and extract data.
<?php

$content 
getXML("http://www.patricksaviation.com/api/?id=ID");
foreach(
$content['items'] as $item){
    
/* Example: Print the video(s) name. */ print $item['name']."<br />\n";
}

function 
getXML($file){
    
$itemtags = array('id''user''name''description''length''size''resolution''rating''views''comments''url''img''imgThumb''imgTiny');
    
    
$ch curl_init();
    
curl_setopt($chCURLOPT_URL$file);
    
curl_setopt($chCURLOPT_USERAGENT"Please Enter Your Site Name Here");
    
curl_setopt($chCURLOPT_HEADER0);
    
curl_setopt($chCURLOPT_RETURNTRANSFER1);
    
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
    
curl_setopt($chCURLOPT_TIMEOUT5);
    
$contents curl_exec ($ch);
    
curl_close ($ch);

    
preg_match_all('/<video>(.*?)<\/video>/si'$contents$items);
    
$items $items[1];
    
$result['items'] = array();
    
$i 0;
    foreach(
$items as $item) {
        foreach(
$itemtags as $itemtag){
            
preg_match("'<$itemtag.*?>(.*?)</$itemtag>'si"$item$temp);
            if(
$temp$result['items'][$i][$itemtag] = trim($temp[1]);
        }
        
$i++;
    }
    return 
$result;
}

?>