The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WebService::ADSBExchange

SYNOPSIS

 use WebService::ADSBExchange;
 
 my $adsb = WebService::ADSBExchange->new( key => $key );
 
 my $registration = 'N161UW';
 my $position  = $adsb->single_aircraft_position_by_registration($registration);
 my $latitude  = $position->{ac}[0]->{lat};
 my $longitude = $position->{ac}[0]->{lon};
 my $flight    = $position->{ac}[0]->{flight};
 say "$registration is flight $flight and its current position is $latitude by $longitude";

DESCRIPTION

This interface helps the user to communicate with the API at adsbexchange.com to track aircraft information. The API could be used, for example, to alert you when an aircraft is within four miles and flying under 5000 feet, or when an aircraft squawks 7700. To use the API you need to register at https://rapidapi.com/adsbx/api/adsbexchange-com1 and buy a subscription.

To use the module, you first create a WebService::ADSBExchange object. The new() function takes one parameter: your API Key.

 my $adsb = WebService::ADSBExchange->new( key => $key );
 

... and then you are ready to use the methods on your $adsb object. If you send no key you will get an error message from the module. If you send an invalid key, the module will use it and you'll get an error from the API.

The API URL is fixed in the module, but if it changes you can also pass the new one to the new() function:

 my $adsb = WebService::ADSBExchange->new( key => $key, api_url => 'new_api_url.com' );

METHODS

Each method returns the full API response in a hash. The API responds with JSON, and this interface parses it into a hash for you to read. A complete example of accessing the information is in the synopsis. If you want to mess with the "raw" JSON response, just call get_json_response(). This could be useful if you want to inspect the result to determine which pieces of data you want. You could also use Data::Dumper on the hash to see everything formatted nice and pretty, but that's no fun.

single_aircraft_position_by_registration

 $adsb->single_aircraft_position_by_registration('N161UW');

single_aircraft_position_by_hex_id

 $adsb->single_aircraft_position_by_hex_id('A0F73C');

aircraft_live_position_by_hex_id

 $adsb->aircraft_live_position_by_hex_id('A0F73C');
 

This call appears to be the same as single_aircraft_position_by_hex_id

aircraft_last_position_by_hex_id

 $adsb->aircraft_last_position_by_hex_id("A0F73C");

aircraft_by_callsign

 $adsb->aircraft_by_callsign('AAL2630');

aircraft_by_squawk

 $adsb->aircraft_by_squawk('2025');

tagged_military_aircraft

 $adsb->tagged_military_aircraft();
 

Note this method takes no parameters.

aircraft_within_n_mile_radius

 $adsb->aircraft_within_n_mile_radius( '45.09634', '-94.41019', '30' );
 

Latitude, Longitude, and miles

do_call

do_call is not meant to be accessed directly, but if additional API calls are implemented before this interface is updated to use them, you could still use this interface and make the API call like this:

 $adsb->do_call('new_api_call_example/new_api_call_parameters');
 

For example, if there was a new API call that returned aircraft by country of registration, it might look something like this:

 $adsb->do_call('country/Austria'); 

get_json_response

This is the only method that doesn't make an API call; it returns the full JSON response from the previous call. This is useful if you wish to see what information is available from the call or wish to parse it in a different way.