Skip to main content

pydelijn

Build Status

An async, fully typed Python client for the De Lijn (Flemish public transport) open data API. It retrieves stops, lines, and realtime/scheduled passages.

Its primary purpose is to feed the De Lijn integration in Home Assistant.

Important: a developer account at https://data.delijn.be is required to generate a subscription key for the Core and Search open data APIs.

v2 is a breaking rewrite. The old dict-based pydelijn.api.Passages API is gone, replaced by DeLijnClient with typed models and exceptions. Docs for v1 are available in the git history.

Install

pip install pydelijn

Usage

import asyncio

from pydelijn import DeLijnClient
from pydelijn.exceptions import DeLijnError


async def main() -> None:
    api_key = "<your data.delijn.be subscription key>"

    async with DeLijnClient(api_key) as client:
        stops = await client.search_stops("Antwerpen Rooseveltplaats")
        stop = stops[0]

        passages = await client.get_passages(stop.number, max_passages=5)
        for passage in passages:
            print(
                f"Line {passage.line.public_number} to {passage.destination}: "
                f"due at {passage.due_at} (realtime={passage.is_realtime})"
            )


asyncio.run(main())

Errors are raised as typed exceptions (DeLijnConnectionError, DeLijnAuthError, DeLijnNotFoundError, DeLijnResponseError, all subclasses of DeLijnError) rather than logged and swallowed, so callers (e.g. a Home Assistant DataUpdateCoordinator) can react to failures.

You may pass in your own aiohttp.ClientSession; if you don't, one is created lazily and closed by client.close() (or on exiting async with).

Download files

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

Source Distribution

pydelijn-2.0.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydelijn-2.0.1-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pydelijn-2.0.1.tar.gz.

File metadata

  • Download URL: pydelijn-2.0.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pydelijn-2.0.1.tar.gz
Algorithm Hash digest
SHA256 2893e767efdbf85a09fb360c01be660457d71be99753168fcf85e9b8a5519bb2
MD5 3c59a02d2af14aa94ee459500a06ef10
BLAKE2b-256 47624e929c8bf043b0053cffaf9e80eb05a3e9c85892738c1cc1c8df531b0c9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydelijn-2.0.1.tar.gz:

Publisher: release.yml on bollewolle/pydelijn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pydelijn-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: pydelijn-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pydelijn-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3fdf0dbe6925ec4d54c8f802a550666bfc993b795c56a3b067378e9f0ed792ec
MD5 c4ae992c9ec001f378f687eff4afeabf
BLAKE2b-256 582706feb33b8ce8ca92619304f580a171f5ed7b99fd45c14943bffcde78784d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydelijn-2.0.1-py3-none-any.whl:

Publisher: release.yml on bollewolle/pydelijn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 files

2.0.0

2 files

1.1.0

2 files

1.0.0

3 files

0.6.1

3 files

0.6.0

1 file

0.5.1

1 file

0.5.0

1 file

0.4.0

1 file

0.3.1

1 file

0.3.0

1 file

0.2.0

1 file

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page