Skip to main content

Storstockholms Lokaltrafik (SL) data via Trafiklab API

Project description

Trafiklab-Sl

version python version license

A data model for Storstockholms Lokaltrafik (SL) data.

Also contains an async client for fetching data from the Trafiklab API.

Installation

Install using pip install -U trafiklab-sl

Development

To install the package for development, clone the repository and run:

python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'

Usage

The client is based on the aiohttp library and is async. It is used to fetch data from the Trafiklab API. The library supports two SL APIs:

More APIs will be added in the future.

Example

Here is an example of how to use the client to get upcoming train departures at Stockholm Central (site Id 1002).

import asyncio

from tsl.clients.transport import TransportClient
from tsl.models.common import TransportMode


async def main():
    client = TransportClient()
    reponse = await client.get_site_departures(1002, transport=TransportMode.TRAIN)

    print("Upcoming trains at Stockholm Central:")
    for departure in sorted(reponse.departures, key=lambda d: d.expected):
        print(
            f"[{departure.line.designation}] platform {departure.stop_point.designation}"
            f" to {departure.destination} ({departure.display})"
        )


asyncio.run(main())

Contributing

Both bug reports and pull requests are appreciated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trafiklab-sl-0.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

trafiklab_sl-0.1.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file trafiklab-sl-0.1.1.tar.gz.

File metadata

  • Download URL: trafiklab-sl-0.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.8

File hashes

Hashes for trafiklab-sl-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b4b819156a7397a33d86cc66e43a3d382ad608ac2ce1736a9058716cc5fac00e
MD5 68f4e23830f82505eea3b9d248400368
BLAKE2b-256 88b8683cf59dd2e3a36eb6a3034b368b94d99c6dede34a3904e8b2092bc94097

See more details on using hashes here.

File details

Details for the file trafiklab_sl-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for trafiklab_sl-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51056f6409485510a0bfe73e012a1b7cc18f7d603396b437d44ca09d8a660123
MD5 e19efaf760b88d067d3c74a077861a3d
BLAKE2b-256 8a6b83e3e8399995fac3ceaefb3839c8fb6ec4e603b6881a1f6f80ad2565a026

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page