1.0.4 β€’ Published 2 years ago

@stockholm-transit/departures v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

πŸ‡ΈπŸ‡ͺ Storstockholms Lokaltrafiks (SL) Departures πŸš†

  • With this API, you can get real-time information regarding bus, metro, commuter train and local train.
  • Trafiklab documentation is available here.

Usage

import * as departures from '@stockholm-transit/departures';
import { DepartureParameters } from '@stockholm-transit/departures';

departures.init({ apiKey: process.env.STOCKHOLM_DEPARTURES_API_KEY });

const params: DepartureParameters = { siteId: '9001' };
departures.query(params).then((data) => res.send(data.ResponseData));

Functions

init

(config: StockholmBaseConfig) => void

query

(params: DepartureParameters) => Promise<DepartureResponse | undefined>

Types

StockholmBaseConfig

ParameterTypeRequiredDescription
apiKeystringtrueTrafiklab API key.
  • Read how to generate Trafiklab API keys here.

DepartureParameters

ParameterTypeRequiredDescriptionDefault
siteIdstringtrueUnique identification number for the place.
timeWindowbooleanfalsePick up departures within the desired time window.60

Building

Run npx nx build @stockholm-transit/departures to build the library.

Running unit tests

Run npx nx test @stockholm-transit/departures to execute the unit tests via Jest.

Related APIs