Skip to main content

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

Apache-2.0

Download files

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

Source Distribution

aiomobilitydatabase-0.1.0.tar.gz (23.3 kB view details)

Uploaded Source

Built Distribution

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

aiomobilitydatabase-0.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

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

Hashes for aiomobilitydatabase-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60736951e454328440d8357310b0986ad64d6f9c2cd9bf14daa036303e651af2
MD5 ec7235ce04fe37bcf39f39138e390d62
BLAKE2b-256 54a704fe98dbc963203300beac8b3eacf1ee19a5d17b5ea029ead6d6e79c5383

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomobilitydatabase-0.1.0.tar.gz:

Publisher: publish.yml on raman325/aiomobilitydatabase

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

File details

Details for the file aiomobilitydatabase-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiomobilitydatabase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16303f4e8a99ef9ea8cb89cdb1d83ea464ef14b67204e25bdc4cd48fc54f5710
MD5 5e89105406091df5ece5d64cc72d6fac
BLAKE2b-256 5c8435ec9906542774c01d4614c35abaabae8672f1f64bbf1d4dc54b6dd1097b

See more details on using hashes here.

Provenance

The following attestation bundles were made for aiomobilitydatabase-0.1.0-py3-none-any.whl:

Publisher: publish.yml on raman325/aiomobilitydatabase

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

Release history Release notifications | RSS feed

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page