Fully object-oriented library to integrate the VVS API into your project.
pip install vvspy
- Detect delay in upcoming departures:
from vvspy import get_departures
from vvspy.enums import Station
deps = get_departures(Station.HAUPTBAHNHOF__TIEF, limit=3)
for dep in deps:
if dep.delay > 0:
print("Alarm! Delay detected.")
print(dep) # [Delayed] [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof
else:
print("Train on time")
print(dep) # [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof
- Detect cancellations in upcoming departures/arrivals:
from vvspy import get_departures
from vvspy.enums import Station
arrivals = get_departures(Station.VAIHINGEN, limit=5)
for arrival in arrivals:
if arrival.cancelled:
print(f"Alarm! The train at {arrival.real_datetime} has been cancelled!")
# Check arrival.stop_infos and arrival.line_infos for more information
- Get complete trip info between two stations (including interchanges):
from vvspy import get_trip # also usable: get_trips
from vvspy.enums import Station
trip = get_trip(Station.HAUPTBAHNHOF__TIEF, Station.HARDTLINDE)
print(f"Duration: {trip.duration / 60} minutes")
for connection in trip.connections:
print(f"From: {connection.origin.name} - To: {connection.destination.name}")
# Output:
Duration: 58 minutes
From: Wallgraben - To: Hauptbf (A.-Klett-Pl.)
From: Hauptbf (Arnulf-Klett-Platz) - To: Stuttgart Hauptbahnhof (tief)
From: Stuttgart Hauptbahnhof (tief) - To: Marbach (N)
From: Marbach (N) Bf - To: Murr Hardtlinde
- Filter for specific lines:
from vvspy import get_departures
from vvspy.enums import Station
deps = get_departures(Station.HAUPTBAHNHOF__TIEF)
for dep in deps:
if dep.serving_line.symbol == "S4":
print(f"Departure of S4 at {dep.real_datetime}")
- Filter for specific platforms:
from vvspy import get_departures
from vvspy.enums import Station
deps = get_departures(Station.HAUPTBAHNHOF__TIEF)
for dep in deps:
if dep.platform == "101":
print(f"Departure of {dep.serving_line.number} to {dep.serving_line.direction} on {dep.platform_name} at {dep.real_datetime}")
See: #64
vvspy uses the python logging module. If you want to change the log level of vvspy, use the following:
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger("vvspy")
logger.setLevel(logging.DEBUG)
If you want to say thank you or/and support active development of vvspy
:
- Add a GitHub Star to the project.
- Support me on Ko-fi.
And now, I invite you to participate in this project! Let's work together to create the most useful tool for all PietSmiet Enjoyers.
- Issues: ask questions and submit your features.
- Pull requests: send your improvements to the current.
- Mail: send your ideas for the project.
- Discord: add me as a friend on Discord: @zaanposni
Together, we can make this project better every day!
- vvs_direct_connect is a dockerized REST service providing departure data by aschuma.
- discord-masz - MASZ is a selfhostable highly sophisticated moderation bot for Discord. Includes a web dashboard and a discord bot.
vvspy is free and open-source software licensed under the MIT.