FsHafas-Python documentation¶
FsHafas-Python is a client for the HAFAS public transport APIs. It is generated (via Fable) by the fshafas F# library.
Example¶
Get journeys between locations and print start station, end station and departure time.
import asyncio
import sys
from fshafas import HafasClient
from fshafas.profiles import db_profile
async def main(argv) -> int:
with HafasClient(db_profile) as client:
journeys = await client.journeys(argv[0], argv[1])
for j in journeys.journeys:
for l in j.legs:
print(l.origin.fields[0].name, l.destination.fields[0].name, l.departure)
return 0
if __name__ == "__main__":
if len(sys.argv) == 3:
asyncio.run(main(sys.argv[1:]))
python3.10 example.py Hamburg Berlin
Installation¶
pip install https://github.com/bergmannjg/fshafas/releases/download/2.3.0/fshafas-0.0.23-py3-none-any.whl