https://www.npmjs.com/package/ivao-sdk
The IVAO-SDK is a wrapper for interacting with the IVAO API and pulling data from IVAO for use in any web app.
$ npm i ivao-sdk -D
To use the IVAO-SDK, import it into your project and instantiate a new instance of the IVAO class:
const ivaoSdk = require('ivao-sdk');
// instantiate new instance of IvaoClient
const ivaoClient = new ivaoSdk.IvaoClient(); // default data refresh rate of 15 seconds
// Listen for connected event to know when the client is ready to use.
ivaoClient.on('connected', () => {
console.log('Connected to IVAO API');
// The SDK also emits an event for when data is refreshed if you wish to perform logic on data refresh
ivaoClient.on('dataRefreshed', () => {
console.log('Data refreshed');
});
});
When instantiating a new instance, you can optionally pass in an options object to specify the data refresh rate:
const ivaoClient = new ivaoSdk.IvaoClient({
refreshRate: 30 // refresh data every 30 seconds
});
const ivaoSdk = require('ivao-sdk');
const ivaoClient = new ivaoSdk.IvaoClient();
ivaoClient.on('connected', () => {
console.log('Connected to IVAO API');
const pilots = ivaoClient.getIvaoPilotsFiltered({
flightPlan: {
aircraft: {
icaoCode: 'B738',
},
},
});
console.log(pilots);
console.log('Result count:', pilots.length);
});
See the IVAO SDK documentation for more information and usage examples of the client methods.