Skip to main content

access public transport information in hamburg, germany.

Project description

HVV Geofox Python Library

Code style: black Hamburg Open Issues Release GTI version: 38 Azure Pipelines status


About

This library is a python wrapper for accessing the geofox api. This api is used to get information about the public transport in Hamburg, Germany.

How to get the api credentials

You have to apply for credentials via the HVV website. You can see their official guide here (the page is only available in German).

They will send you a contract you will have to sign and send back. After about a week, you will receive your api credentials.

Documentation

This library uses the same data types and parameters as specified in the GTI documentation. It features client side validation of the parameters.

Installation

Install the package from pypi.

pip install pygti

Usage

See the examples on how to use the library at examples.py, and see the GTI documentation for in-depth explanation of parameters.

There is also a Glitch example available. Try it out and if you want to see how it's done, just remix the app.

A minimal working example is shown below:

from pygti.gti import GTI, Auth
import asyncio
import aiohttp

GTI_USER = "" # your api username
GTI_PASS = "" # your api password


async def main():
    async with aiohttp.ClientSession() as session:
        auth = Auth(session, GTI_USER, GTI_PASS)

        gti = GTI(auth)

        ir = await gti.init()

        # see the examples.py file for more functionality and use of the payloads

asyncio.run(main())

:exclamation: If using Python 3.8: Version 3.6.2 of aiohttp uses a different EventLoopPolicy so running this MWE will currently result in an error displayed in the console! It should not affect the functionality. This should be fixed with a newer version of aiohttp. For a workaround look into the examples.py file. For more information see this Issue.

Progress

  • <input type="checkbox" checked="" disabled="" /> 1. init
  • <input type="checkbox" checked="" disabled="" /> 2. checkName
  • <input type="checkbox" checked="" disabled="" /> 3. getRoute
  • <input type="checkbox" checked="" disabled="" /> 4. departureList
  • <input type="checkbox" checked="" disabled="" /> 5. getTariff
  • <input type="checkbox" checked="" disabled="" /> 6. departureCourse
  • <input type="checkbox" checked="" disabled="" /> 7. listStations
  • <input type="checkbox" checked="" disabled="" /> 8. listLines
  • <input type="checkbox" checked="" disabled="" /> 9. getAnnouncements
  • <input type="checkbox" checked="" disabled="" /> 10. getIndividualRoute
  • <input type="checkbox" checked="" disabled="" /> 11a. getVehicleMap
  • <input type="checkbox" checked="" disabled="" /> 11b. getTrackCoordinates
  • <input type="checkbox" checked="" disabled="" /> 12. checkPostalCode
  • <input type="checkbox" checked="" disabled="" /> 13. getStationInformation
  • <input type="checkbox" checked="" disabled="" /> 14. tariffZoneNeighbours
  • <input type="checkbox" checked="" disabled="" /> 15. tariffMetaData
  • <input type="checkbox" checked="" disabled="" /> 16. singleTicketOptimizer
  • <input type="checkbox" checked="" disabled="" /> 17. ticketList

Developing

Some files in this project are generated based on the WADL and XSD schema files from GTI. To generate them, install the dev dependencies and run the script:

pip install -r requirements_dev.txt
python script/generate.py

Contributions are welcome!

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

Project details


Download files

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

Files for pygti, version 0.9.2
Filename, size File type Python version Upload date Hashes
Filename, size pygti-0.9.2-py3-none-any.whl (29.8 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pygti-0.9.2.tar.gz (44.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page