In pyHaFAS, we often use the following terms. Please read them, so you can understand the documentation and project better.
Most other pyHaFAS-specific words are defined in the :doc:`/glossary`. If one of these words is used in this documentation it's marked as a link with a superscript G as follows: :term:`profile`G
Term | Meaning |
---|---|
profile | Customization for each HaFAS deployment - Contains the endpoint, tokens and possible changes for the deployment |
FPTF | Abbreviation for Friendly Public Transport Format - Used as the basis for returned data |
Station Board | Generalization for :func:`arrivals <pyhafas.client.HafasClient.arrivals>` and :func:`departures <pyhafas.client.HafasClient.departures>` requests |
You only need to install the pyhafas package, for example using pip:
$ pip install pyhafas
Below is a sample code for easy usage. It has multiple parts:
- It imports the :class:`HafasClient <pyhafas.client.HafasClient>` and the :class:`DBProfile <pyhafas.profile.db.DBProfile>` of pyHaFAS and creates the :class:`HafasClient <pyhafas.client.HafasClient>` with the :term:`profile`G. The :class:`DBProfile <pyhafas.profile.db.DBProfile>` is the :term:`profile`G belonging to the HaFAS deployment of Deutsche Bahn.
- It searches for locations (stations) with the term "Berlin" and prints the result
- It searches for departing trains at Berlin Central Station. Every station is identified by an ID, which (in this case 8011160) can be obtained by a location-request with pyhafas.
from pyhafas import HafasClient
from pyhafas.profile import DBProfile
client = HafasClient(DBProfile())
print(client.locations("Berlin"))
print(client.departures(
station='8011160',
date=datetime.datetime.now(),
max_journeys=5
))
For a good start with pyHaFAS you should go on reading the documentation. Especially the pages :doc:`/usage/examples` and :doc:`profiles` are a good start.