RBA Cash Rate: 4.35% · 1AUD = 0.67 USD · Inflation: 4.1%  
Leading Digital Marketing Experts | 1300 235 433 | Aggregation Enquires Welcome | Book Appointment
Example Interest Rates: Home Loan Variable: 5.20% (5.24%*) • Home Loan Fixed: 5.48% (6.24%*) • Fixed: 5.48% (6.24%*) • Variable: 5.20% (5.24%*) • Investment IO: 5.78% (6.81%*) • Investment PI: 5.49% (6.32%*)

Aviation Quotes API

Aviation Quotes API

As part of our ongoing introduction to our suite of APIs, we'll be providing a very basic introduction to our aviation quotes database. At the time of writing our list of quotes sits at around 5000... however there's barely 700 that are 'activated' (meaning the others haven't been verified). As such, the source should be considered very much a work in progress.

The Result

Not unlike the standard quotes API, data may be queried by quote ID (for a single quote, id=123), or by search term (type=search&search=crash). Regardless of what query is made, the data array returned in each case includes identical fields. The endpoint in all cases is as follows:

https://api.beliefmedia.com/platform/sources/quotes/aviation.json

An API Key is required, and an optional pg and number parameter may be supplied for pagination purposes. If searching results, the search type must be provided (type=search). If no search type is provided, the browse type is assumed.

Returning a Single Quote

A single quote may be returned as follows: aviation.json?apikey=xxxxx&id=gY. The result:

1
Array
2
(
3
    [code] => 200
4
    [status] => 200
5
    [message] => OK
6
    [source] => BeliefMedia
7
    [data_version] => 0.2
8
    [data] => Array
9
        (
10
            [itemid] => rE
11
            [quote] => You've never been lost until you've been lost at Mach 3.
12
            [author] => Paul F. Crickmore
13
            [nsfw] => 0
14
            
Image Error
 => Array
15
                (
16
                    [filename] => aviation/rE.jpg
17
                    [size] => 55.2K
18
                    [width] => 885
19
                    [height] => 885
20
                )
21
 
22
        )
23
 
24
)

With each result there's a a few images; just one is referenced in the returned JSON. The primary purpose of prefabricating an image is so we can send them to social without the overhead of manufacturing them in real time. Having an image also makes paginated 'visual' results easy to render. If we build you your own set of branded images the filename is honored.

Aviation Quote

Sample Image Returned via the API

Sample PHP Functions

The following are the most basic of functions necessary to retrieve data. An API Key is provided to all clients and is available to others upon request.

Returning Single Result

Returning a single result will often return multiple image formats. It may also contain data about the individual responsible for the quote.

1
<?php 
2
/*
3
 Aviation Quotes API
4
 https://www.beliefmedia.com.au/aviation-quotes-api
5
*/
6
 
7
function beliefmedia_aviation_quote($id, $apikey = 'xxxxx') {
8
 
9
  $data = @file_get_contents('https://api.beliefmedia.com/platform/sources/quotes/aviation.json?apikey=' . $apikey . '&id=' . $id);
10
  if ($data === false) return false;
11
 
12
  $data = json_decode($data, true);
13
  if ($data === false) return false;
14
 
15
  /* Likely return array of errors with code & message */
16
  if ($data['code'] != '200') return $data['message'];
17
 
18
 /* Do something with data */
19
 return (array) $data;
20
}

Usage:

1
$results = beliefmedia_aviation_quote($id = 'Ev');
2
echo '
3
<pre>' . print_r($results, true) . '</pre>
4
 
5
';

Browsing or Searching Results

1
<?php 
2
/*
3
 Aviation Quotes API
4
 https://www.beliefmedia.com.au/aviation-quotes-api
5
*/
6
 
7
function beliefmedia_aviation_quotes($page = '', $number = '', $type = false, $search = false, $apikey = 'xxxxx') {
8
 
9
  if ($page == '') $page = '1';
10
  if ($number == '') $number = '20';
11
  if ($type === false) $type = 'browse';
12
 
13
  /* Correct for invalid search type */
14
  $permitted_types = array('browse', 'search');
15
  if (!in_array($type, $permitted_types)) $type = 'browse';
16
 
17
  $type = ($type == 'browse') ? 'browse' : 'type=' . $type . '&search=' . str_replace(' ', '+', $search);
18
 
19
  $data = @file_get_contents('https://api.beliefmedia.com/platform/sources/quotes/aviation.json?apikey=' . $apikey . '&pg=' . $page . '&number=' . $number . '&' . $type);
20
  if ($data === false) return false;
21
 
22
  $data = json_decode($data, true);
23
  if ($data === false) return false;
24
 
25
  /* Likely return array of errors with code & message */
26
  if ($data['code'] != '200') return $data['message'];
27
 
28
 return (array) $data;
29
}

Usage:

1
$results = beliefmedia_aviation_quotes($page = '2', $number = '10', $type = false, $search = false, $apikey = 'xxxxx');
2
echo '
3
<pre>' . print_r($results, true) . '</pre>
4
 
5
';

Considerations

BeliefMedia are, without question, the most qualified digital agency in Australia that deals with the aviation industry. If you're after media, advertising, or marketing representation, give us a call.

  • We wrote a very mediocre "Aviation Quotes" WordPress plugin some time ago; that plugin will soon be retired and a more comprehensive product will take its place.
  • To exclude those results that may not be 'child friendly', use nsfw=0 in your request.

Featured Image: Chuck Yeager in front of the Bell X-1, which, as with all of the aircraft assigned to him, he named Glamorous Glennis (or some variation thereof), after his wife. Source: Wikipedia.

Download our 650-page guide on Finance Marketing. We'll show you exactly how we generate Billions in volume for our clients.

  E. Australia Standard Time [ UTC+10, Default ] [ CHECK TO CHANGE ]

  Want to have a chat?
 

RELATED READING

Like this article?

Share on Facebook
Share on Twitter
Share on Linkdin
Share on Pinterest

Leave a comment