@stockholm-transit/service-alerts
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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

Related APIs

/@stockholm-transit/service-alerts/

    Package Sidebar

    Install

    npm i @stockholm-transit/service-alerts

    Weekly Downloads

    8

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    12.9 kB

    Total Files

    14

    Last publish

    Collaborators

    • rebelliard