Skip to main content

Python-JLT-BusSchedule-Scraper

Python library that scrapes the JLT site for bus schedules.

JLT (Jönköpings Länstrafik) has no public API for departures, so this library scrapes the HTML fragment used by the departure board on jlt.se, and the stop search of the travel planner that jlt.se embeds from etiscloud.net.

It is used by the JLT Bus Schedule Home Assistant integration.

Installation

pip install jlt-bus-schedule

Requires Python 3.11 or later.

Usage

import asyncio

from jlt_bus_schedule import JltApiClient


async def main() -> None:
    async with JltApiClient() as client:
        stops = await client.async_search_stops("Rådhusparken")
        stop = stops[0]
        print(f"{stop.name} ({stop.id})")

        for departure in await client.async_get_departures(stop.id, take=10):
            print(
                f"{departure.departure_time} {departure.line:>3} "
                f"{departure.destination} ({departure.time_to_departure})"
            )


asyncio.run(main())
Jönköping Rådhusparken (6001320)
13:20   3 Råslätt via Asecs-Ryhov (Avgår nu)
13:21 141 Sävsjö via Vrigstad (Avgår nu)
13:22   4 Huskvarna via Solåsen-Ryhov (Avgår om 1 min)
...

Sharing an aiohttp session

Pass an existing aiohttp.ClientSession to share it with the rest of your application, as Home Assistant integrations should. The client never closes a session it did not create.

from homeassistant.helpers.aiohttp_client import async_get_clientsession

client = JltApiClient(async_get_clientsession(hass))

Without a session the client creates its own, which is closed by await client.close() or when leaving an async with block.

A custom User-Agent header can be set with JltApiClient(session, user_agent="MyApp/1.0").

API

JltApiClient

Method Description
async_get_departures(stop_id, take=20, timeout=10) Upcoming departures for all lines at a stop, as a list of Departure. Departures that have already left are skipped.
async_search_stops(query, timeout=10) Stops matching a name, best match first, as a list of Stop.
close() Close the session, if it was created by the client.

Both methods raise JltConnectionError on HTTP errors, connection errors and timeouts. All exceptions raised by the library inherit from JltError.

Departure

Attribute Type Example
line str "1"
destination str "Huskvarna via Centrum-Elmia"
direction str "mot Huskvarna via Centrum-Elmia"
departure datetime Timezone aware, in JLT_TIMEZONE (Europe/Stockholm)
departure_time str "11:41"
time_to_departure str "Avgår om 5 min"

Stop

Attribute Type Example
id int 6001320
name str "Jönköping Rådhusparken"

Parsers

parse_departures(html, now) and parse_stops(html) parse the HTML fragments without doing any network requests. parse_departures uses now to place the clock times on the right date, so departures after midnight end up on the next day.

Development

pip install -e ".[test]"
pytest

Tests marked live call the real jlt.se site to detect markup changes. Skip them with pytest -m "not live".

Releasing

Releases are published to PyPI by the Publish to PyPI workflow when a GitHub release is published, using trusted publishing. Bump __version__ in src/jlt_bus_schedule/const.py before creating the release.

Metadata

Release files for jlt-bus-schedule 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jlt-bus-schedule 1.0.0
File Size Uploaded Provenance Actions
jlt_bus_schedule-1.0.0.tar.gz 12.9 kB With provenance Details for jlt_bus_schedule-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jlt-bus-schedule 1.0.0
File Interpreter ABI Platform Actions
jlt_bus_schedule-1.0.0-py3-none-any.whl Python 3 none any Details for jlt_bus_schedule-1.0.0-py3-none-any.whl

Total release size: 21.3 kB

Release files / jlt_bus_schedule-1.0.0.tar.gz

Download URL jlt_bus_schedule-1.0.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ee55832f593fdcedc0c066b136725fe7c47939e27e166b83657beb9c3d91170f
BLAKE2b-256 checksum
How to use checksums
9f6d7647980c3fa4da66ab750d739a7df658ffd4434a68308b8a608115a5b8e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Release files / jlt_bus_schedule-1.0.0-py3-none-any.whl

Download URL jlt_bus_schedule-1.0.0-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d1a3b5ff2c3e698839f6e6ed4993e395640ade655c8c7239e3ffdc9f39460c83
BLAKE2b-256 checksum
How to use checksums
ff77c72902f46c94127c85d7237c37ff20b85fd6af62b4741562b1498eb717b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

Security for jlt-bus-schedule 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for jlt_bus_schedule-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

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