A ts/js pkg to query the OnAir Airline Manager's API.

Overview

Typescript/Javascript package for querying the OnAir API

A Typescript/Javascript wrapper around the OnAir Airline Manager's API.

NPM Version Build Status

Installation

npm i -s onair-api

Usage

The required apiKey and optional companyId can be found in the lower left corner of the options screen within the OnAir Desktop client, if You need additional help locating these ID's check the How To in the wiki.

  • apiKey
  • companyId - Optional, but required for all getCompany* methods
  • vaId - Optional, only required if using either of the VA methods getVirtualAirline or getVirtualAirlineMembers

Example using Javascript

import OnAirApi from 'onair-api'

// define the prerequisite keys
// apiKey and companyId can be found in the lower left corner of the options screen within the OnAir Desktop client
const apikey = 'YOUR-API-KEY'
const companyId = 'YOUR-COMPANY-ID'

// instantiate the OnAirApi
const Api = new OnAirApi({ apiKey, companyId });

/**
 * call one of the Api methods, like getCompany
 * which will query the OnAir API using the above credentials
 * and returns the company details
 */
let company = await Api.getCompany();
// do something with the company data

Methods

getCompany()

Fetches the company details for the given companyId.

Usage

import OnAirApi, { Company, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyDetails: Company = await api.getCompany();

Example Response

getCompanyFbos()

Fetches the FBOs for a given companyId.

Usage

import OnAirApi, { Fbo, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyFbos: Fbo[] = await api.getCompanyFbos();

Example Response

getCompanyFleet()

Fetches the aircraft that are owned, leased, or rented for a given companyId.

Usage

import OnAirApi, { Aircraft, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyFleet: Aircraft[] = await api.getCompanyFleet();

Example Response

getCompanyFlights()

Fetches the Flights for a given companyId.

Usage

import OnAirApi, { Flight, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyFlights: Flight[] = await api.getCompanyFlights();

Example Response

getCompanyMissionFlightTracks()

Fetches the flight tracks for all missions.

Usage

import OnAirApi, { FlightTrack, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyMissionFlightTracks: FlightTrack[] = await api.getCompanyMissionFlightTracks();

Example Response

getCompanyJobs(completed = false)

Fetches the pending jobs for a given companyId. Pass true as the first argument to return completed jobs.

Usage

import OnAirApi, { Job, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyJobs: Job[] = await api.getCompanyJobs();
// pass true as the first argument to return the completed jobs
let completedCompanyJobs: Job[] = await api.getCompanyJobs(true);

Example Response

getCompanyEmployees()

Fetches the Persons currently employed by a given companyId.

Usage

import OnAirApi, { People, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyEmployees: People[] = await api.getCompanyEmployees();

Example Response

getCompanyCashFlow()

Fetches the cash flow for a given companyId.

Usage

import OnAirApi, { CashFlow, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let companyCashFlow: CashFlow[] = await api.getCompanyCashFlow();

Example Response


getCompanyIncomeStatement(startDate: string, endDate: string)

Fetches the income statement within a given range for a companyId. If no startDate or endDate is provided it will return the last 30 days.

Usage

import OnAirApi, { IncomeStatement, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
// no startDate or endDate provided, returns 30 days
let companyIncomeStatement: IncomeStatement = await api.getCompanyIncomeStatement();

// providing a startDate and endDate
const startDate = '2021-12-01T00:00:00';
const endDate = '2022-01-30T02:58:39.104Z';

let companyIncomeStatement2: IncomeStatement = await api.getCompanyIncomeStatement(startDate, endDate)

Example Response

getCompanyBalanceSheet()

Fetches the company's current balance sheet. Which provides a current snapshot of the financial status of a company.

Usage

import OnAirApi, { BalanceSheet, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let balancesheet: BalanceSheet = await api.getCompanyBalanceSheet();

Example Response

getCompanyWorkOrders()

Fetches the company's currently generated work orders.

Usage

import OnAirApi, { WorkOrder, OnAirApiConfig, } from 'onair-api'


const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let workorders: WorkOrder = await api.getCompanyWorkOrders();

Example Response

getAircraft(aircraftId: string)

Fetches the Aircraft details for a given aircraftId.

Usage

import OnAirApi, { Aircraft, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
const aircraftId = '9891d561-def7-438c-9097-d3336989af93';
let companyAircraft: Aircraft = await api.getAircraft(aircraftId);

Example Response

getAircraftFlights(aircraftId: string)

Fetches the Flights flown for a given aircraftId.

Usage

import OnAirApi, { Flight, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
const aircraftId = '9891d561-def7-438c-9097-d3336989af93';
let companyAircraftFlights: Flight[] = await api.getAircraftFlights(aircraftId);

Example Response

getAirport(airportCode: string)

Fetches Airport details for a given airport Code.

Usage

import OnAirApi, { Airport, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
const airportCode = 'KLAX';
let airport: Airport = await api.getAirport(airportCode);

Example Response

getFlight(flightId: string)

Fetches Flight details for a given flightId.

Usage

import OnAirApi, { Flight, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
const flightId = '9891d561-def7-438c-9097-d3336989af93';
let flight: Flight = await api.getFlight(flightId);

Example Response

getVirtualAirline()

Fetches VirtualAirline details for a given vaId. Note: this requires the vaId to be provided during Api instantiation

Usage

import OnAirApi, { VirtualAirline, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let va: VirtualAirline = await api.getVirtualAirline();

Example Response

getVirtualAirlineMembers()

Fetches the members of a Virtual Airline for a given vaId.

Usage

import OnAirApi, { Member, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let vaMembers: Member[] = await api.getVirtualAirlineMembers();

Example Response

getVirtualAirlineShareHolders()

Fetches the ShareHolders of a Virtual Airline for a given vaId.

Usage

import OnAirApi, { ShareHolder, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let vaShareHolders: ShareHolder[] = await api.getVirtualAirlineShareHolders();

Example Response

getVirtualAirlineRoles()

Fetches the Roles for a given vaId.

Usage

import OnAirApi, { VARole, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
let roles: VARole[] = await api.getVirtualAirlineRoles();

Example Response

getEmployee(employeeId: string)

Fetches details for a given employeeId.

Usage

import OnAirApi, { People, OnAirApiConfig, } from 'onair-api'

const apiConfig: OnAirApiConfig = {
  apiKey: 'YOUR-API-KEY',
  companyId: 'YOUR-COMPANY-ID',
  vaId: 'YOUR-VA-ID'
};

const api: Api = new OnAirApi(apiConfig);
const employeeId = '596b6c2e-4ac7-44e9-b1d4-a4299030cb04';
let employee_details: People = await api.getEmployee(employeeId);

Example Response


Examples

Example using the dotenv package

import 'dotenv/config'
import { OnAirApi, } from 'onair-api'

(async function () {
    const apiKey = process.env.COMPANY_APIKEY;
    const companyId = process.env.COMPANY_ID;
    const vaId = process.env.VIRTUAL_AIRLINE_ID;

    const Api = new OnAirApi({ apiKey, companyId, vaId, });

    let company = await Api.getCompanyDetails();
    let fleet = await Api.getCompanyFleet();

    console.log({
        company,
        fleet,
    });
})();

Typescript Example using dotenv package and onair-api types

import 'dotenv/config'
import { OnAirApi, } from 'onair-api'
import { Company, Aircraft, Api, } from 'onair-api/src/types'

(async function () {
    const apiKey: string = process.env.COMPANY_APIKEY;
    const companyId: string = process.env.COMPANY_ID;
    const vaId = process.env.VIRTUAL_AIRLINE_ID;

    const api: Api = new OnAirApi({ apiKey, companyId, vaId, });

    let company: Company = await api.getCompanyDetails();
    let fleet: Aircraft[] = await api.getCompanyFleet();

    console.log({
        company,
        fleet,
    });
})();
Comments
  • Adjust queries to allow companyId as optional first parameter

    Adjust queries to allow companyId as optional first parameter

    should default to env companyId if empty.

    This will eventually require a bit of downstream refactoring as the below methods parameter order will change

    • getCompanyFlights (will now have an optional first parametet to speficy the CompanyId)
    • getCompanyJobs (will now have an optional first parametet to speficy the CompanyId)
    • getCompanyIncomeStatement (will now have an optional first parametet to speficy the CompanyId)
    • getVirtualAirlineFlights (will now have an optional first parametet to speficy the VAId)
    enhancement 
    opened by mikedevita 0
  • remove world parameter requirement from Api

    remove world parameter requirement from Api

    Now that OnAir has migrated all of the worlds onto the same server, the OnAir Api now uses the same baseUrl (https://server1.onair.company/api/v1/) for all worlds. This means that the world parameter is no longer used within the Api to differentiate companies between the various worlds.

    opened by mikedevita 0
  • convert OnAirApi to use an object for the keys and IDs

    convert OnAirApi to use an object for the keys and IDs

    @logicbox this look good?

    Keys have been altered for security 🙂.

    import OnAirApi from 'onair-api'
    import { Api, Aircraft, OnAirApiConfig, } from 'onair-api/src/types'
    
    const apiConfig: OnAirApiConfig = {
        apiKey: 'd17eaa85-aad5-429b-9297-fe2e6deca5d9',
        world: 'cumulus', // cumulus, stratus or, thunder. Cler Sky world, use stratus
        companyid: 'c3d8e51d-f2e9-4918-a2a6-c3f2cd5ab141', // Optional, but required for all `getCompany*` methods
        vaId: 'cd7df229-c5ff-4528-b74f-688b98c808fe', // Optional, only required if using either of the VA methods `getVirtualAirline` or `getVirtualAirlineMembers`
    };
    
    const api: Api = new OnAirApi(apiConfig);
    
    opened by mikedevita 0
  • Optional params

    Optional params

    Optional params on constructor to allow this:

    const Api = new OnAirApi(argv['apiKey'], argv['world'])
    
    const flight: Flight = await Api.getFlight(argv['flightId']);
    

    Also updated docs to reflect and changed import example to default for OnAirApi

    opened by logicbox 0
  • Add missing Api endpoints

    Add missing Api endpoints

    Add the below new Api methods...

    New Company Methods

    • [ ] #21

      • Should return an object containing the provided company's income and flights statistics
      • Parameter
        • companyId - type: string
      • Api route: /api/v1/company/{{companyId}}/dashboard
    • [ ] #20

      • Should return an array of company notifications such as jobs/flights changing status or being accepted
      • Parameter
        • companyId - type: string
      • Api route: /api/v1/company/{{companyId}}/notifications
    • [ ] getCompanyWorkorders(companyId:string)

      • Should return an array of pending workorders for the provided companyId
      • Parameter
        • companyId - type: string
      • Api route: /api/v1/company/{{companyId}}/workorders
    • [ ] getCompanyAircraftWorkorders(companyId:string, aircraftId:string)

      • Should return an array of pending workorders for the provided companyId and aircraftId
      • Parameter
        • companyId - type: string
        • aircraftId - type: string
      • Api route: /api/v1/company/{{companyId}}/workorders/{{aircraftId}}

    New VA Methods

    • [ ] #22

      • Should return an object containing the provided Virtual Airline's income and flights statistics
      • Parameter
        • vaId - type: string
      • Api route: /api/v1/company/{{vaId}}/dashboard
    • [ ] #23

      • Should return an array of Virtual Airline notifications such as jobs/flights changing status or being accepted
      • Parameter
        • vaId - type: string
      • Api route: /api/v1/company/{{vaId}}/notifications
    • [ ] getirtualAirlineWorkorders(vaId:string)

      • Should return an array of pending workorders for the provided vaId
      • Parameter
        • vaId - type: string
      • Api route: /api/v1/company/{{vaId}}/workorders

    New Aircraft Methods

    • [ ] getAircraftMaintenanceCosts(aircraftId:string)

      • Should return an object containing the various costs for maintenance
      • Parameter
        • aircraftId - type: string
      • Api route: /api/v1/aircraft/{{aircraftId}}/maintenance_costs
    • [ ] getAircraftEconomicDetails(aircraftId:string)

      • Should return an object containing the various aircraft and economy details such as CPR (Cost per hour), Hourly profit, avg flight hours by week, year, etc...
      • Parameter
        • aircraftId - type: string
      • Api route: /api/v1/aircraft/{{aircraftId}}/economic_details

    New FBO Methods

    • [ ] getFboJobs(fboId:string)
      • Should return an array of pending jobs at the provided FBO. Note: This will require the FBO's Id
      • Parameter
        • fboId - type: string
      • Api route: /api/v1/fbo/{{fboId}}/jobs
    enhancement help wanted 
    opened by mikedevita 0
Releases(v2.0.0)
Owner
Virtual Airline Management System
Virtual Airline Management System
Obsidian Vault Template for Software Developers/Managers working in the corporate world.

Weave A highly opinionated Obsidian Vault Template for the Corporate World to get you productive fast. Track your meetings, applications, contacts, an

Colin 78 Dec 28, 2022
A simple cli-app that allows you to divide a YouTube video into multiple separate videos base on a video's time stamps. Powered by pkg and yt-scissors library.

YouTube-Scissors CLI A simple CLI app that allows you to divide a YouTube video into multiple separate videos base on a video's time stamps. This proj

Gabe 23 Nov 8, 2022
A simple query builder, it will helps to develop DSL query for Elasticsearch

Elasticsearch Dynamic Query Builder A simple query builder, it will helps to develop DSL query for elasticsearch Installation You can start it from np

Hashemi Rafsan 4 Nov 20, 2022
API and CLI tool to fetch and query Chome DevTools heap snapshots.

Puppeteer Heap Snapshot Capture heap snapshots and query the snapshot for objects matching a set of properties. Read more about it in this blog post.

Adrian Cooney 858 Jan 3, 2023
Examples of how to do query, style, dom, ajax, event etc like jQuery with plain javascript.

You (Might) Don't Need jQuery Frontend environments evolve rapidly nowadays and modern browsers have already implemented a great deal of DOM/BOM APIs

NEFE 20.3k Dec 24, 2022
An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve and modify the bot state, respectively.

CQRS Wechaty An event-driven architecture wrapper for Wechaty that applies the CQS principle by using separate Query and Command messages to retrieve

Wechaty 3 Mar 23, 2022
Subgraph to query Doodles NFT tokens along with the traits and owners.

Doodles Subgraph API Subgraph to query Doodles NFT tokens along with the traits and owners. How to use the API Try it out here Example query: { toke

J 6 Sep 19, 2022
logseq custom.js and custom.css utilities : resize query table columns, hide namespaces...

logseq-custom-files custom.js and custom.css utilities for Logseq. current version v20220331 query table view : add handles on the query table headers

null 44 Dec 7, 2022
URL query encoder/decoder with a user configuration

@lfgroup/query-coder URL query coder/decoder with configurable user pattern. It provides the most comfortable experience for encoding and decoding com

LF Group Inc. 14 Jul 14, 2022
On-chain query batcher for CosmWasm-enabled chains

multiquery On-chain query batcher for CosmWasm. Similar to SCB 10X's multicall contract, but supports any serializable query request, not limited to W

null 7 Dec 6, 2022
A Node.js microservice to store and query time series data

Time series storage microservice This is a simple Node.js application which allows the storage and query of time series datasets in an InfluxDB 2.0 in

JTEKT 3 Apr 25, 2022
The Trino datasource allows to query and visualize Trino data from within Grafana.

Trino Grafana Data Source Plugin The Trino datasource allows to query and visualize Trino data from within Grafana. Getting started Drop this into Gra

Starburst 13 Nov 3, 2022
A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your vault.

Obsidian Media DB Plugin A plugin that can query multiple APIs for movies, series, anime, games, music and wiki articles, and import them into your va

Moritz Jung 58 Dec 21, 2022
A full query console for Cloudflare's D1 database product.

D1 Console A console/REPL for Cloudflare's D1 Database product. NPM | GitHub Supports all the features expected of a modern database client, including

Isaac McFadyen 59 Dec 23, 2022
Superkeys allow users to add short keys for websites and make search query in those sites.

Superkeys is a browser extension which allow users to add short keys for websites and make search query in those sites. Made with ❤️ @nilooy ??‍?? Dem

Niloy 9 Aug 17, 2022
Query for CSS brower support data, combined from caniuse and MDN, including version support started and global support percentages.

css-browser-support Query for CSS browser support data, combined from caniuse and MDN, including version support started and global support percentage

Stephanie Eckles 65 Nov 2, 2022
React-query devtools for swr

React-query devtools for swr

Erfan Khadivar 12 Aug 14, 2022
A movie schema sandbox for playing with EdgeDB and the EdgeQL query builder, pre-loaded with MCU data

The EdgeDB MCU sandbox ?? This is a sandbox for playing with EdgeDB and the EdgeQL query builder. It includes a simple movie database schema (dbschema

EdgeDB 13 Nov 9, 2022
A complete media query framework for CSS, to apply specific properties in specific screen

A complete media query framework for CSS, to apply specific properties in specific screen Note: Size of every media query is `50px, 100px, 150px, 200p

Rohit Chouhan 6 Aug 23, 2022