1.0.4 • Published 2 years ago

@stockholm-transit/service-alerts v1.0.4

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

🇸🇪 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

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

ServiceAlertParameters

ParameterTypeRequiredDescriptionDefault
transportModeTransportModefalseCurrent traffic types. Comma-separated string.
lineNumberstringfalseMax 10 lines. Comma-separated string.
siteIdstringtrueUnique identification number for the place.
fromDatestringfalseStart date for the current validity period.
toDatestringfalseEnd 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.

Related APIs