Skip to main content

HVV Geofox Python Library

Release


About

This library is a Python wrapper for the Geofox API, which provides public transport data for Hamburg, Germany (HVV). It uses aiohttp for async HTTP requests and returns fully typed Pydantic models for all responses.

How to get API credentials

Apply for credentials via the HVV website. See their official guide here (German only). After signing and returning the contract, you will receive your credentials within about a week.

Documentation

This library mirrors the data types and parameters defined in the GTI documentation. All request and response types are Pydantic models generated from the GTI OpenAPI spec.

Installation

Install from PyPI:

pip install pygti

Requirements: Python 3.12+, aiohttp, pydantic

Usage

Minimal example

import asyncio
import aiohttp
from pygti.auth import Auth
from pygti.gti import GTI
from pygti.models import InitRequest

async def main():
    async with aiohttp.ClientSession() as session:
        auth = Auth(session, "GTI_USERNAME", "GTI_PASSWORD")
        gti = GTI(auth)

        ir = await gti.init(InitRequest())
        print(ir.version, ir.buildDate)

asyncio.run(main())

Departure list

import asyncio
import aiohttp
from pygti.auth import Auth
from pygti.gti import GTI
from pygti.models import DLRequest, GTITime, SDName, SDNameType

async def main():
    async with aiohttp.ClientSession() as session:
        auth = Auth(session, "GTI_USERNAME", "GTI_PASSWORD")
        gti = GTI(auth)

        response = await gti.departureList(
            DLRequest(
                station=SDName(
                    name="Wartenau",
                    id="Master:10901",
                    type=SDNameType.STATION,
                ),
                time=GTITime(date="heute", time="jetzt"),
                maxList=5,
                maxTimeOffset=200,
                useRealtime=True,
            )
        )

        for dep in response.departures:
            print(f"{dep.line.name:5} -> {dep.line.direction}  in {dep.timeOffset} min")

asyncio.run(main())

Connection search

from pygti.models import GRRequest, SDName, SDNameType, GTITime

response = await gti.getRoute(
    GRRequest(
        start=SDName(name="Hamburg Hbf", type=SDNameType.STATION),
        dest=SDName(name="Hamburg Airport", type=SDNameType.STATION),
        time=GTITime(date="heute", time="jetzt"),
    )
)

for schedule in response.schedules:
    print(schedule.plannedDepartureTime, "->", schedule.plannedArrivalTime)

Error handling

from pygti import GTIError

try:
    response = await gti.departureList(...)
except GTIError as e:
    print(f"API error: {e.return_code} — {e.error_text}")

Options

# Custom host (e.g. test environment)
auth = Auth(session, username, password, host="api-test.geofox.de")

# English responses
gti = GTI(auth, language="en")

API reference

All methods on GTI are async and accept a typed request model, returning a typed response model.

All request and response models are importable from pygti.models. See the GTI documentation for detailed parameter descriptions.

Migrating from a pre-V1 version

See MIGRATION_TO_V1.md for a full list of breaking changes and how to update your code.

Developing

The models in pygti/models.py are generated from the GTI OpenAPI spec. To regenerate them:

uv sync
python scripts/codegen.py

Contributions are welcome!

If you want to contribute, please read the Contribution guidelines.

Metadata

Release files for pygti 1.1.1

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

Source distribution (sdist)

Source distribution for pygti 1.1.1
File Size Uploaded
pygti-1.1.1.tar.gz 83.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygti 1.1.1
File Interpreter ABI Platform
pygti-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 100.3 kB

Release files / pygti-1.1.1.tar.gz

Download URL pygti-1.1.1.tar.gz
Size 83.8 kB
Tags Source
SHA-256 checksum
How to use checksums
646bbe5e658a8a97e02c2713d45e380effc0abd8e4e4285f41e27e0e400d04ab
BLAKE2b-256 checksum
How to use checksums
fcdab509ecb8830d408ef738b2dff68510917eb6181530c616da097698134f70
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 29, 2026.

Transparency log

Release files / pygti-1.1.1-py3-none-any.whl

Download URL pygti-1.1.1-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57a3fc048eb839bac0e200b88f9beed88cefa781c85f9475557ef067c798afee
BLAKE2b-256 checksum
How to use checksums
7b2d6d710936c9c72d1d42e8f84b03bc02bd86bf241c148c1c6aae936d1aaaa6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

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 May 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.9.4

2 release files

0.9.3

1 release file

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.6

1 release file

0.8.5

1 release file

0.8.4

1 release file

0.8.2

1 release file

0.8.0

1 release file

0.7.0

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

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