Skip to main content

A Python library for interacting with Deutsche Bahn data.

Project description

Pybahn

A Python library to query Deutsche Bahn journey, departure, and arrival data using the (unofficial) API.

📚 Table of Contents

📦 Installation

Install pybahn with terminal

pip install pybahn

🛠️ Usage

🔍 Search Station

from pybahn import PyBahn

client = PyBahn(__name__)

station1 = client.station("Frankfurt")

print(station1.name)

🚆 Get a Journey

from pybahn import PyBahn

client = PyBahn(__name__)

station1 = client.station("Frankfurt")

station2 = client.station("Berlin")

journeys = client.journeys(station1.lid, stat2.lid)
# OR
journeys = client.journeys(station1, station2)

print(journeys[0].arrival_name)

🎯 Filter Departures/Arrivals

from pybahn import PyBahn
from pybahn.structs import Filter
from pybahn.structs import Products
from datetime import datetime


client = PyBahn(__name__)

station1 = client.station("Frankfurt")

station2 = client.station("Berlin")

time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S")

journeys = client.journeys(departure=station1, 
                      destination=station2, 
                      time = time,
                      products=[Products.EC_IC, Products.SBAHN],
                      only_d_ticket=True)

print(journeys[0].changes_amont)

🎯 Filter Journeys

from pybahn import PyBahn
from pybahn.structs import Products

client = PyBahn(__name__)

station1 = client.station("Frankfurt")

station2 = client.station("Berlin")


journeys = client.journeys(station1.lid, station2.lid, products=Products.REGIONALS)

print(journeys[0].changes_amont)

📄 License

MIT License

⚠️ Disclaimer

This library (pybahn) is an unofficial wrapper around Deutsche Bahn’s internal web APIs, discovered via publicly accessible browser traffic.

  • It is not affiliated with or endorsed by Deutsche Bahn.
  • It uses undocumented and unsupported endpoints, which may break or change without notice.
  • Use this library at your own risk.
  • Please respect Deutsche Bahn’s terms of use and avoid abusive behavior.

Project details


Download files

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

Source Distribution

pybahn-0.1.2.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

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

pybahn-0.1.2-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file pybahn-0.1.2.tar.gz.

File metadata

  • Download URL: pybahn-0.1.2.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pybahn-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a31b36913ce7b6c9b65201563f029e61a083af4b5050de986deaf95aad570349
MD5 358c80599afa0c65546b5fd906cf0677
BLAKE2b-256 95cefb50bc00622e6b35a296501f920d0030315bbfc5a9b419cd3b224f7630ad

See more details on using hashes here.

File details

Details for the file pybahn-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pybahn-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.4

File hashes

Hashes for pybahn-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 25560bb667d4d0e34586a94c2c82afac814e087b0c2386495cfb3546284b493c
MD5 39331d16c8bb6762ac13a5a6ecda9f44
BLAKE2b-256 d37ca047ed808c0fe21dabe6cf51d2e0922606d1d7d7e18ce432cbd9cb494454

See more details on using hashes here.

Supported by

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