Package Exports
- @stockholm-transit/departures
- @stockholm-transit/departures/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stockholm-transit/departures) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
πΈπͺ 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
Parameter | Type | Required | Description |
---|---|---|---|
apiKey | string | true | Trafiklab API key. |
- Read how to generate Trafiklab API keys here.
DepartureParameters
Parameter | Type | Required | Description | Default |
---|---|---|---|---|
siteId | string | true | Unique identification number for the place. | |
timeWindow | boolean | false | Pick 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.