@stockholm-transit/departures
v1.0.4
Published
API for Storstockholms Lokaltrafiks' departures
Downloads
5
Maintainers
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.