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)
# OR
journeys = client.journeys(departure=station2,
destination=station1,
products=[Products.EC_IC, Products.REGIONAL])
print(journeys[0].changes_amont)
📄 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pybahn-0.1.3.tar.gz.
File metadata
- Download URL: pybahn-0.1.3.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3b4454dff5d8f2adc27ce8b28780dd0fc3b17a6481463d992a7919b9b1f9687
|
|
| MD5 |
525f43ee8fc88449c693822c00518006
|
|
| BLAKE2b-256 |
5cbb7471ff946bd657a80fb775facd90684de8c360206c3415639fa7c2ade6b7
|
File details
Details for the file pybahn-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pybahn-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fadb8eb74cd08a9574511328815d7b137f536fefe84238f40dd9261f827bbe9d
|
|
| MD5 |
7ef5706b62b06ffd7a0e2388d52b9efc
|
|
| BLAKE2b-256 |
8b9971c83e4981303f70e81526f6bee3fcd67afd632c12513871617b8c3743d3
|