Using the Airbana API is simple...
The following Quick Start Guide is based on a PHP without using an API key

Airsoft Data

First you need to decide what data you are going to work with.

The Airbana API allows you to retrieve a collection of Sites, details of an individual Site, a collection of Events or an individual Event.

For this example we'll be using a collection of events.

Your Return Type

As mentioned on the front page the API can return data in 3 formats;

Serialized PHP:
a:3:{
  s:4:"Site";
  a:17:
   {
       s:6:"SiteID"; s:3:"100";
       s:8:"SiteName"; s:18:"Airbana Datacenter";
       s:7:"Website"; s:17:"www.Airbana.co.uk";
       s:12:"ContactPhone"; s:12:"0871 3096879";
       s:12:"ContactEmail"; s:20:"gareth@airbana.co.uk";
       s:8:"Address1"; s:0:"";
       s:8:"Address2"; s:0:"";
       s:8:"PostCode"; s:0:"";
       s:9:"ForumLink"; s:0:"";
       s:4:"Type"; s:1:"1";
       s:6:"UKASGB"; s:1:"0";
       s:5:"UKARA"; s:1:"0";
       s:10:"ShopOnSite"; s:1:"0";
       s:17:"ExplosivesAllowed"; s:1:"0";
       s:11:"Environment"; s:1:"2";
       s:15:"BatteryCharging"; s:1:"0";
       s:7:"Repairs";s:1:"0";
   }
  s:9:"TimeStamp"; i:1266081702;
  s:9:"errorcode";i:0;}

JSON:
{"Site":
   {
       "SiteID":"100",
       "SiteName":"Airbana Datacenter",
       "Website":"www.Airbana.co.uk",
       "ContactPhone":"0871 3096879",
       "ContactEmail":"gareth@airbana.co.uk",
       "Address1":"",
       "Address2":"",
       "PostCode":"",
       "ForumLink":"",
       "Type":"1",
       "UKASGB":"0",
       "UKARA":"0",
       "ShopOnSite":"0",
       "ExplosivesAllowed":"0",
       "Environment":"2",
       "BatteryCharging":"0",
       "Repairs":"0"
   },
  "TimeStamp":1266082458,
  "errorcode":0}

XML:
<xml version="1.0" encoding='UTF-8'>
<AirbanaAPI>
       <SiteID>100</SiteID>
       <SiteName>Airbana Datacenter</SiteName>
       <Website>www.Airbana.co.uk</Website>
       <ContactPhone>0871 3096879</ContactPhone>
       <ContactEmail>gareth@airbana.co.uk</ContactEmail>
       <Type>1</Type>
       <UKASGB>0</UKASGB>
       <UKARA>0</UKARA>
       <ShopOnSite>0</ShopOnSite>
       <ExplosivesAllowed>0</ExplosivesAllowed>
       <Environment>2</Environment>
       <BatteryCharging>0</BatteryCharging>
       <Repairs>0</Repairs>
       <timestamp>1266082316</timestamp>
       <errorcode>0</errorcode>
</AirbanaAPI>

We'll be using PHP which means we need to use a file with .php at the end, in this case;
http://api.airbana.net/2.0/events.php

Processing the Data

By default events.php will return the next 7 days worth of events for the entire world.
For our example we are going to limit it to just the UK (Region 1) which means we need to pass the region parameter as follows;
http://api.airbana.net/2.0/events.php?region=1

In PHP we can request this data via CURL, unserialize it and then output it!
<?php
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, "http://api.airbana.net/2.0/events.php?region=1");
    $result = curl_exec($ch);
    $resultArray = curl_getinfo($ch);

    $AirbanaAPIReturn = unserialize($result);

    if($AirbanaAPIReturn['errorcode'] == '0')
    {
       foreach($AirbanaAPIReturn['Events'] as $AirsoftEvent)
       {
          if(is_array($AirsoftEvent))
          {
             print($AirsoftEvent['EventStartDate'].' - '.$AirsoftEvent['EventName'].'<br/>');
          }
       }
    }
    else
    {        print("There was a problem retreiving the data");
    }
?>

Done!

Now that you've seen how easy it is to get the Airbana data into your appliactions I would recommend you read more about the parameters for the various parts of the API!

Sites Using the API Why not check out their website too..

Contact Details Why not get in touch?

I'm always interested to hear what the Airsoft community thinks of Airbana and what it would like to see Airbana do next.

Address:
www.Airbana.net
www.AirsoftMap.net
Phone:
+44 871 3096879
Twitter:
@Airbana
E-mail:
Gareth@Airbana.net

Flickr

...see more