Package Exports
- @stockholm-transit/service-alerts
- @stockholm-transit/service-alerts/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/service-alerts) 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) Service alerts API π
- With this API, you can get information about current and planned disturbances in SL traffic. With the API, you can ask questions about disturbances on, for example, a certain line or a certain type of traffic. The answer consists of disturbance messages with certain meta-information.
- Trafiklab documentation is available here.
Usage
import * as serviceAlerts from '@stockholm-transit/service-alerts';
import { ServiceAlertParameters } from '@stockholm-transit/service-alerts';
serviceAlerts.init({ apiKey: process.env.STOCKHOLM_SERVICE_ALERTS_API_KEY });
const params: ServiceAlertParameters = { siteId: '9001' };
serviceAlerts.query(params).then((data) => res.send(data.ResponseData));
Functions
init
(config: StockholmBaseConfig) => void
query
(params: ServiceAlertParameters) => Promise<ServiceAlertResponse | undefined>
Types
StockholmBaseConfig
Parameter | Type | Required | Description |
---|---|---|---|
apiKey | string | true | Trafiklab API key. |
- Read how to generate Trafiklab API keys here.
ServiceAlertParameters
Parameter | Type | Required | Description | Default |
---|---|---|---|---|
transportMode | TransportMode | false | Current traffic types. Comma-separated string. | |
lineNumber | string | false | Max 10 lines. Comma-separated string. | |
siteId | string | true | Unique identification number for the place. | |
fromDate | string | false | Start date for the current validity period. | |
toDate | string | false | End date for the current validity period. |
TransportMode
"BUS"
"METRO"
(Tunnelbana)"TRAIN"
(PendeltΓ₯g)"TRAM"
"SHIP"
Building
Run npx nx build @stockholm-transit/service-alerts
to build the library.
Running unit tests
Run npx nx test @stockholm-transit/service-alerts
to execute the unit tests via Jest.