adsbexchange-js-utility
v1.0.1
Published
A tiny javascript utility to make api requests to adsbexchange api server
Downloads
6
Maintainers
Readme
adsbexchange-js-utility
Developers Guide
Getting Started
- Clone the application with
git clone https://github.com/kenigbolo/adsbexchange-js-utility.git
or use sshgit clone [email protected]:kenigbolo/adsbexchange-js-utility.git
.
Dependencies
- NPM 6.x
- Node 8.x
Description
This is a tiny module that allows making requests to the adsbexchange.com api. The npm package exposes a tiny utility class called ADSBExchange. The utility class can be used to leverage making requests to the the adsbexchange api. This utility will be actively maintained in collaboration with the team at ADS-B Exchange to keep it up to date with the information available on ADS-B Exchange
NPM
This package has been published on NPM and is freely available according to the MIT license. To install via npm simply run npm install adsbexchange-js-utility
and via yarn yarn add adsbexchange-js-utility
.
NPM Package Usage
const ADSBExchange = require('adsbexchange-js-utility');
const adsbExchange = new ADSBExchange('put-your-api-key-here');
/* Request based on promise style */
adsbExchange.request('aircraft', 'json').then((response) => {
// response contains the required data
console.log(response);
});
/* Request based on async/await style */
const requestData = asyn () => {
const response = await adsbExchange.request('aircraft', 'json');
// response contains the required data
console.log(response);
}
requestData();
The utility returns a resolved or rejected promise.
Available functions
The utility exposes two core functions request
and reqQuery
. Both functions accept two arguments namely endpoint
and query
however the methods differ purely on the format of the query
argument that they take.
Accepted method arguments
- The
endpoint {Required}
- This refers to the endpoint to which the call should be made. The available option at the moment of this writing isaircraft
. Kindly consult the official documentation for any endpoints not listed here, however the pluggin is flexible to support new endpoints without any changes needed whenever new endpoints are available. This is the same for both therequest
method and thereqQuery
method.
Query for request function
- The
query {Required}
- The second argument taken by the request function is thequery
params. Kindly visit the official documentation to be sure what values are allowed in query construction. The query should strip (not contain) both the first and last/
in them e.g. for a request likehttps://adsbexchange.com/api/aircraft/json/lat/37.16611/lon/-119.44944/dist/10/
the query part of this request will bejson/lat/37.16611/lon/-119.44944/dist/10
and this is becauseaircraft
is considered the endpoint to which the query is required.
Query for reqQuery function
- The
query {Required}
- This refers to a javascript object constructed to match the require params in akey - value
format. Kindly visit the official documentation to be sure what values are allowed in query construction. The query should be constructed following the order in which they are specified in the api documentation e.g. for a request like below
From ADS-B Exchange
https://adsbexchange.com/api/aircraft/json/lat/37.16611/lon/-119.44944/dist/10/
will result a query
params constructed as a javascript key-value pair thus
{json: '', lat: 37.16611, lon: -119.44944, dist: 10}
as pointed out, aircraft
is considered the endpoint. Also fields which are not preceeded with a value e.g. json
, should be set to an empty string value in the query object.
Return type
The return type of the request method is a Promise
which when resolved holds the data response.
Future Plans
I am currently volunteering to build open source tools for the team at ADS-B Exchange and will be adding utilities for both GoLang
, Ruby
and Python
in the coming weeks/months/years. If there are any specific features you will like these utilities to have kindly let me know by creating an issue
using the Github issue tracker
. I'd be doing my best to help out. Also as an open source tool I'd be more than happy to have more contributors to help out the guys as ADS-B Exchange.