faa-notam-sdk-test v1.0.4
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
NOTE: if the package name is not available than you will have to use a different name. Change the$ npm publish
name
field in the filepackage.json
How to use this sdk
Install the sdk
$ npm i faa-notam-sdk
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'
- the first argument is the API base url. E.g.
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, andgetAixm(queryParams)
, which return XML data. The paramqueryParams
is the query parameters to be passed to the respective API endpointAll URIs are relative to the base url parameter passed to
NotamApiSdk
.Method HTTP request Description getGeoJson GET /notams/geoJson Get geoJson data. Returns json. getAidap GET /notams/aidap Get aidap data. Returns xml. getAixm GET /notams/aixm Get 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
})