skylink-sdk
v0.1.2
Published
TypeScript SDK for the SkyLink API
Maintainers
Readme
SkyLink TypeScript SDK
A client for the SkyLink API v3.1.
Install
bun add skylink-sdkQuick start
import { Skylink } from "skylink-sdk";
const skylink = new Skylink({
apiKey: process.env.SKYLINK_API_KEY!,
});
const metar = await skylink.getWeatherMetar({
icao: "KJFK",
parsed: true,
});Method parameters use idiomatic camelCase; the SDK converts them to the API's query names. Path parameters are URL encoded, and undefined or null query values are omitted.
Airport parameters accept either ICAO or IATA codes. The SDK uses the bundled lookup data to send the format required by each endpoint:
// METAR expects ICAO, so "JFK" is sent as "KJFK".
await skylink.getWeatherMetar({ icao: "JFK" });
// Ticket search expects IATA, so "EGLL" is sent as "LHR".
await skylink.getTicketsSearch({ origin: "EGLL", destination: "KJFK" });Codes are trimmed and normalized to uppercase. An unknown alternate-format code throws a RangeError before a billable API request is made. Airline ICAO/IATA codes, ICAO24 aircraft addresses, and aircraft type codes are left untouched. Endpoints documented to accept either airport-code format continue to pass either through. A single bundled ICAO-to-IATA lookup is used to derive both directions at startup.
RapidAPI
const skylink = new Skylink({
apiKey: process.env.RAPIDAPI_KEY!,
channel: "rapidapi",
});The client selects the correct base URL and authentication headers for either direct SkyLink or RapidAPI subscriptions. A custom baseUrl, headers, fetch implementation, and timeout are also supported.
Errors and response metadata
Unsuccessful responses throw SkylinkError, with the HTTP status, parsed response body, original Response, and rate-limit values.
import { SkylinkError } from "skylink-sdk";
try {
await skylink.getNotams({ icao: "KJFK" });
} catch (error) {
if (error instanceof SkylinkError) {
console.error(error.status, error.body, error.rateLimit.remaining);
}
}Generated endpoint methods return the decoded response body directly. Use requestWithResponse when you also need response headers and metadata:
const result = await skylink.requestWithResponse<{ raw: string }>(
"GET",
"/weather/metar/KJFK",
{ query: { parsed: true } },
);
console.log(result.data, result.rateLimit);Every request accepts { signal, headers } as its final argument. The default timeout is 15 seconds.
Endpoint coverage
The generated client covers all 58 operations in the current v3.1 OpenAPI document, including weather, schedules, airports, airlines, live and historical ADS-B, routes, charts, aircraft, NOTAMs, FAA delays, briefings and PDFs, carbon estimates, tickets, webhooks, navaids, countries, and regions.
Regenerate the endpoint types and methods from the live public specification:
bun run generateThe generator intentionally uses no OpenAPI package. Response types reflect the published schema exactly; operations whose OpenAPI response schema is empty safely return unknown rather than claiming undocumented fields.
Development
bun test
bun run typecheck