Quick Start
Prerequisites πβ
Before you begin, ensure you meet the following requirements for using the SkyPath Web SDK:
- Access to SkyPath NPM package @yamasee/skypath-sdk-web
- Node.js and NPM installed on your machine
- SkyPath API Key
Installation π¦β
To install the SkyPath Web SDK, use your preferred package manager:
- NPM
- Yarn
- pNPM
npm install @yamasee/skypath-sdk-web
yarn add @yamasee/skypath-sdk-web
pnpm add @yamasee/skypath-sdk-web
Alternatively, add the dependency into your package.json
file:
{
"dependencies": {
"@yamasee/skypath-sdk-web": "^0.3.14"
}
}
If you encounter any access issues, refer to our troubleshooting guide.
Importing the SDKβ
To use the SDK in your project, import it as follows:
import createSkyPathSDK from "@yamasee/skypath-sdk-web";
Initialization π οΈβ
Use createSkyPathSDK
to initializing the SDK. It authenticates and configures the SDK with your specific settings.
The function returns a promise, resolving to an object containing factory functions for the features. It should probably used on your app page load.
const sdk = await createSkyPathSDK({
apiBaseUrl: "https://api.skypath.io", // use https://satging-api.skypath.io for staging environment.
// Authentication parameters
apiKey: "XXXX-XXXX-XXXX-XXXX", // Your SkyPath API key
userId: "user123", // The current user ID
companyName: "AirlineInc", // Your current company name
});
The above authentication method - apiKey
- is for development purposes only.
When going to production, use Signed JWT
method. For more details, see SDK configuration documentation.
Usage πβ
Once the SDK is initialized, you can use the returned object to interact with the features. For example, letβs use the Observations feature to get live turbulence observations.
- First, initialize the observations flow:
const observationsFlow = sdk.createObservationsFlow();
- Next, subscribe to the
onData
event to receive real-time data updates:
observationsFlow.onData((data) => {
// Your code here, for example, update the map layer with the new data
});
- To start the flow and begin receiving data, use the
start
method:
observationsFlow.start();
This will start polling the API for new data, and the onData
callback will be called whenever new data is available. This will be called, for example, when enabling the map layer.
- You can update the configuration at any time using
updateConfig
method.
For example, if you want to set/change the polygon area for which you want to receive data on map viewport change, you need to update the flow configuration using the updateConfig
method and pass to it the new polygon and aircraft category for which you want to receive data.
// Define a new polygon area
const polygon = [
[ -85.644, 30.748 ],
[ -85.644, 23.381 ],
[ -75.192, 23.381 ],
[ -75.192, 30.748 ],
[ -85.644, 30.748 ]
];
// Specify the aircraft category (C10-C110)
const aircraftCategory = "C60";
// Pass the new polygon to the flow
observationsFlow.updateConfig({ polygon, aircraftCategory });
For full list of config options, see the specific feature page.
- To pause the flow and stop data updates, use the
stop
method. This will be called, for example, when hiding the map layer.
observationsFlow.stop();
The stop
method pauses the flow without terminating it. You can resume the flow anytime by calling start
again.
- When you're done with the flow, make sure to clean up by calling
terminate
. This should be called when the feature is no longer needed, for example, when terminating the map screen.
observationsFlow.terminate();
β¨ Congratulations!
Youβve successfully integrated the SkyPath Web SDK into your project and initialized the first feature.
Before going live, there is a QA step where the implementation should be mutually reviewed with SkyPath.