Skip to content

A typescript SDK wrapper for interacting with the IVAO API

License

Notifications You must be signed in to change notification settings

BBrown4/ivao-sdk

Repository files navigation

IVAO-SDK

npm version GitHub Workflow Status GitHub Workflow Status

https://www.npmjs.com/package/ivao-sdk


Introduction

The IVAO-SDK is a wrapper for interacting with the IVAO API and pulling data from IVAO for use in any web app.

Installation

$ npm i ivao-sdk -D

Usage

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
});

Quickstart Example

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);
});

Documentation

See the IVAO SDK documentation for more information and usage examples of the client methods.

About

A typescript SDK wrapper for interacting with the IVAO API

Resources

License

Stars

Watchers

Forks

Packages

No packages published