GTFS Station Stop
A project for organizing GTFS Real-Time data for use as a homeassistant sensor.
Usage
This is designed for use with Home Assistant GTFS Realtime Custom Component.
It can also be used for general GTFS update purposes.
Feed Subjects and Station Stops
All updates go through the Feed Subject which is setup to call updates from one or more feed URLS.
Create a feed subject like so, then pass it in the constructor for a Station Stop
from gtfs_station_stop.feed_subject import FeedSubject
from gtfs_station_stop.station_stop import StationStop
# Obtain the API keep from your GTFS provider if needed, otherwise leave blank.
api_key = "YOUR_API_KEY_HERE"
urls = ["https://gtfs.example.com/feed1", "https://gtfs.example.com/feed2"]
feed_subject = FeedSubject(urls, api_key)
# Obtain the Stop ID from GTFS static data from your provider.
# This must match those provided by the realtime feed.
station_stop_nb = StationStop("STOP_ID_NORTHBOUND", feed_subject)
station_stop_sb = StationStop("STOP_ID_SOUTHBOUND", feed_subject)
Calling feed_subject.update() will update all registered listeners.
feed_subject.update()
for arrival in station_stop_nb.arrivals:
minutes_to = (arrival.time - time.time()) / 60.0
print(f"{arrival.route} in {minutes_to}")
Active service alerts are also supported for station stops and for routes.
route_status = RouteStatus("Line 1", feed_subject)
feed_subject.update()
for alert in route_status.alerts:
print(f"{route_status.id} alert {alert.header_text['en']}")
for alert in station_stop_nb.alerts:
print(f"{station_stop_nb.id} alert {alert.header_text['en']}")
As the update will make one or more http requests, this may improve performance or integrate better with an asynchronous project.
GTFS Static Info
Static data can be loaded into a Dataset for convenient lookup to use alongside GTFS Realtime data. GTFS data can be read from a file or a URL from your service provider. The GTFS file must be provided as a .zip containing the requisite .txt files as defined by GTFS Static Reference.
from gtfs_station_stop.station_stop_info import StationStopInfoDataset
station_stop_infods = StationStopInfoDataset("gtfs_static.zip")
print(f"{station_stop_infods['STOP_ID']}")
Static info can be queried through the station_stop_info, route_info, calendar, and trip_info submodules.
GTFS providers will regularly update their static feeds. In order to account for this, the library will attempt to cache zip file downloads for static info.
Async Updates
Asynchronous updates are also supported through the async_update() method.
await feed_subject.async_update()
Static data can also be obtained similarly with gtfs_station_stop.static_Dataset.async_factory.
station_stop_info_Dataset = await async_get_gtfs_Dataset(
StationStopInfoDataset, "https://gtfsprovider.example.com/static.zip"
)
Command Line Interface
This can be run as a Python module on the command line using
$ python -m gtfs_station_stop
This must be installed with the optional group [cli].
$ pip install gtfs_station_stop[cli]
Use python -m gtfs_station_stop --help for details.
Development Setup
It is recommended to use uv to develop in this project.
$ uv pip install --group dev
Run tests with:
$ uv run pytest
Metadata
Release files for gtfs-station-stop 0.11.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| gtfs_station_stop-0.11.8.tar.gz | 181.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gtfs_station_stop-0.11.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 206.4 kB
Release files / gtfs_station_stop-0.11.8.tar.gz
| Download URL | gtfs_station_stop-0.11.8.tar.gz |
|---|---|
| Size | 181.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62355367944cad49cff0521e059e2b874404cecd93bc69a478b0dbd47ea55abd
|
|
BLAKE2b-256 checksum How to use checksums |
07d70e44c37fc65ad93c24a2c98ec8f7d75bb2472aaa6f909714f2d1df01725c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 13, 2026.
Transparency logRelease files / gtfs_station_stop-0.11.8-py3-none-any.whl
| Download URL | gtfs_station_stop-0.11.8-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba220e215ebf0313204bc8289b5d097b09408d65ebe1fab6f15e26f4dbfe2356
|
|
BLAKE2b-256 checksum How to use checksums |
9fedbea1041d98f22f0e159f625b23e8b9493b9e808e5de17dd815711daa1c25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Sep 13, 2026.
Transparency log