aiomobilitydatabase
Async Python client for the Mobility Database catalog API.
The Mobility Database is a catalog of GTFS, GTFS Realtime, and GBFS feeds from around the world. This library wraps its catalog API with a fully typed asyncio client.
Installation
pip install aiomobilitydatabase
Requires Python 3.12+.
Authentication
Sign up at mobilitydatabase.org and copy your refresh token from the account page. The client exchanges it for short-lived access tokens automatically (including proactive refresh before expiry).
Usage
import asyncio
from aiomobilitydatabase import DataType, MobilityDatabaseClient
async def main() -> None:
async with MobilityDatabaseClient("YOUR_REFRESH_TOKEN") as client:
# Free-text search across feed name, provider, and location
results = await client.search_feeds(
search_query="new york", data_types=[DataType.GTFS_RT], limit=10
)
for item in results.results:
print(item.id, item.provider, item.status)
# Full detail for one feed, including the producer URL
feed = await client.get_gtfs_rt_feed(results.results[0].id)
assert feed.source_info is not None
print(feed.source_info.producer_url)
asyncio.run(main())
With an externally managed session (e.g. Home Assistant's shared session), the client never closes it:
import aiohttp
from aiomobilitydatabase import MobilityDatabaseClient
session = aiohttp.ClientSession()
client = MobilityDatabaseClient("YOUR_REFRESH_TOKEN", session)
try:
metadata = await client.get_metadata()
finally:
await client.close() # session remains open; you own it
Error handling
All errors derive from MobilityDatabaseError:
| Exception | Meaning |
|---|---|
MobilityDatabaseConnectionError |
Network failure, timeout, or invalid response body |
MobilityDatabaseAuthenticationError |
Invalid refresh token, or unauthorized after a token refresh |
MobilityDatabaseNotFoundError |
Resource not found (404) |
MobilityDatabaseRateLimitError |
Rate limited (429) |
MobilityDatabaseApiError |
Any other 4xx/5xx (carries .status and .body) |
Development
uv sync --dev
uv run pytest
uv run ruff check . && uv run ruff format --check .
uv run mypy src
License
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 aiomobilitydatabase-0.1.0.tar.gz.
File metadata
- Download URL: aiomobilitydatabase-0.1.0.tar.gz
- Upload date:
- Size: 23.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60736951e454328440d8357310b0986ad64d6f9c2cd9bf14daa036303e651af2
|
|
| MD5 |
ec7235ce04fe37bcf39f39138e390d62
|
|
| BLAKE2b-256 |
54a704fe98dbc963203300beac8b3eacf1ee19a5d17b5ea029ead6d6e79c5383
|
Provenance
The following attestation bundles were made for aiomobilitydatabase-0.1.0.tar.gz:
Publisher:
publish.yml on raman325/aiomobilitydatabase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiomobilitydatabase-0.1.0.tar.gz -
Subject digest:
60736951e454328440d8357310b0986ad64d6f9c2cd9bf14daa036303e651af2 - Sigstore transparency entry: 2302638033
- Sigstore integration time:
-
Permalink:
raman325/aiomobilitydatabase@b425edcc47401514c2f7e34e1436f6715df75a6f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/raman325
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b425edcc47401514c2f7e34e1436f6715df75a6f -
Trigger Event:
release
-
Statement type:
File details
Details for the file aiomobilitydatabase-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiomobilitydatabase-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16303f4e8a99ef9ea8cb89cdb1d83ea464ef14b67204e25bdc4cd48fc54f5710
|
|
| MD5 |
5e89105406091df5ece5d64cc72d6fac
|
|
| BLAKE2b-256 |
5c8435ec9906542774c01d4614c35abaabae8672f1f64bbf1d4dc54b6dd1097b
|
Provenance
The following attestation bundles were made for aiomobilitydatabase-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on raman325/aiomobilitydatabase
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiomobilitydatabase-0.1.0-py3-none-any.whl -
Subject digest:
16303f4e8a99ef9ea8cb89cdb1d83ea464ef14b67204e25bdc4cd48fc54f5710 - Sigstore transparency entry: 2302638289
- Sigstore integration time:
-
Permalink:
raman325/aiomobilitydatabase@b425edcc47401514c2f7e34e1436f6715df75a6f -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/raman325
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b425edcc47401514c2f7e34e1436f6715df75a6f -
Trigger Event:
release
-
Statement type: