1.0.4 • Published 3 years ago

faa-notam-sdk-test v1.0.4

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

FAA Notam API SDK

SDK for the FAA Notam API. This library acts as a wrapper around the Notam API.

Run lint

Run lint with the following commands:

npm install
npm lint

To fix possible lint errors run

npm lint:fix

How to publish this package

  • If you do not already have an npm user account, you can create an account:
    $ npm adduser
  • Or you can login with your account:
    $ npm login
  • Publish the package to npm
    $ npm publish
    NOTE: if the package name is not available than you will have to use a different name. Change the name field in the file package.json

How to use this sdk

  1. Install the sdk

    $ npm i faa-notam-sdk
  2. Create an instance of this wrapper

    const { NotamApiSdk } = require('faa-notam-sdk')
    
    const sdkInstance = new NotamApiSdk('localhost:8080/api/v1', 'apisecretkey')
    • the first argument is the API base url. E.g. 'http://localhost:8080/api/v1'
    • the second argument is the api key. E.g. 'secretapikey'
  1. Use the wrapper methods

    Every function in this wrapper will return a promise. Call the functions with the query parameters passed as a json objects. Passing invalid query params, a wrong api key or invalid base url will throw a descriptive error. Handle errors using ordinary javascript async/await or promise syntax.

    There are 3 available methods, getGeoJson(queryParams), which returns JSON data, getAidap(queryParams), which returns XML data, and getAixm(queryParams), which return XML data. The param queryParams is the query parameters to be passed to the respective API endpoint

    All URIs are relative to the base url parameter passed to NotamApiSdk.

    MethodHTTP requestDescription
    getGeoJsonGET /notams/geoJsonGet geoJson data. Returns json.
    getAidapGET /notams/aidapGet aidap data. Returns xml.
    getAixmGET /notams/aixmGet aixm data. Returns xml.

Example usage

You can replace getGeoJson in the below example with getAidap or getAixm.

const { NotamApiSdk } = require('faa-notam-sdk')

const sdkInstance = new NotamApiSdk('localhost:8080/api/v1', 'apisecretkey')

const queryParams = {
  notamNumber: 'somestring',
  pageNum: 10,
  sortOrder: 'Asc'
}

// async/await syntax
try {
  const res = await sdkInstance.getGeoJson(queryParams)
  // do something with the response

} catch(err) {
  // do something with the error

}

// promise syntax
sdkInstance.getGeoJson(queryParams)
  .then(res => {
    // do something with the response

  })
  .catch(err => {
    // do something with the error

  })
1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago