CLI tool to fetch, archive, process and explore GTFS-RT data
Project description
gtfs-cli
CLI tool to fetch, archive, process and explore GTFS-RT (General Transit Feed Specification — Realtime) data. GTFS-RT feeds provide live transit information: trip updates, vehicle positions, and service alerts in protobuf format.
Installation
uv tool install gtfs-cli
After installation, the gtfs-cli command is available globally.
Commands
fetch
Fetch a GTFS-RT feed from a URL or local file and output it as JSON.
# Fetch live trip updates
gtfs-cli fetch "https://gtfsrt.ttc.ca/trips/update?format=binary"
# Fetch vehicle positions
gtfs-cli fetch "https://gtfsrt.ttc.ca/vehicles/position?format=binary"
# Fetch service alerts
gtfs-cli fetch "https://gtfsrt.ttc.ca/alerts/all?format=binary"
# Inspect a previously saved .pb file
gtfs-cli fetch trips.pb
Filtering with jq:
# List all active alerts
gtfs-cli fetch "https://gtfsrt.ttc.ca/alerts/all?format=binary" | jq '.entity[] | .alert'
# Count entities in a feed
gtfs-cli fetch "https://gtfsrt.ttc.ca/trips/update?format=binary" | jq '.entity | length'
# Extract all trip IDs
gtfs-cli fetch "https://gtfsrt.ttc.ca/trips/update?format=binary" \
| jq '[.entity[].trip_update.trip.trip_id]'
Watch mode — continuously poll a feed and stream NDJSON (one JSON object per line):
# Poll every 30 seconds
gtfs-cli fetch --watch 30 "https://gtfsrt.ttc.ca/trips/update?format=binary"
# Count entities on each snapshot
gtfs-cli fetch --watch 30 "https://gtfsrt.ttc.ca/trips/update?format=binary" \
| jq --unbuffered '.entity | length'
# Save a long-running collection to a file
gtfs-cli fetch --watch 30 "https://gtfsrt.ttc.ca/trips/update?format=binary" \
>> snapshots.ndjson
Watch mode handles transient failures gracefully: HTTP and network errors are retried with exponential backoff (1s → 2s → 4s … capped at 60s). Stop with Ctrl+C or SIGTERM.
For all available options, run:
gtfs-cli fetch --help
Development
# Install dependencies
uv sync
# Run a command
uv run gtfs-cli fetch "https://gtfsrt.ttc.ca/trips/update?format=binary"
# Run tests
uv run pytest tests/ -v
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gtfs_cli-0.1.0.tar.gz.
File metadata
- Download URL: gtfs_cli-0.1.0.tar.gz
- Upload date:
- Size: 194.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
228b3b3ced0a1bf9665d4dac2b95d9f2265bc20ce9a5beba3a024d36272363f4
|
|
| MD5 |
97626681386ac4a867d43c24d6a293db
|
|
| BLAKE2b-256 |
7efe76006b34793fcdfa6993368a55503462a109435d5945f79304560de9de37
|
File details
Details for the file gtfs_cli-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gtfs_cli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7474470b495bd8ba429cda2d1c68a0b2bd70cfe08451d2c2343cfc2804707380
|
|
| MD5 |
ceb03a51a079bc679f24ef4a426ad225
|
|
| BLAKE2b-256 |
1ff522cf770a0034398232c940eaa711e3d2e8c0cd3fcbf2578600792d901875
|