Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

simple python module for the VVS and SSB API (Verkehrsverbund Stuttgart)

License

NotificationsYou must be signed in to change notification settings

zaanposni/vvspy

Repository files navigation

PackageVersionPythonVersionsLicense

Fully object-oriented library to integrate theVVS API into your project.

Installation

pip install vvspy

Examples

Tip

For optimal performance on low-spec hardware such as Raspberry Pi, it is advisable to use the string values of the enum directly to avoid the overhead associated with loading the full enum.

  • Detect delay in upcoming departures:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF,limit=3)fordepindeps:ifdep.delay>0:print("Alarm! Delay detected.")print(dep)# [Delayed] [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhofelse:print("Train on time")print(dep)# [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof
  • Detect cancellations in upcoming departures/arrivals:
fromvvspyimportget_departuresfromvvspy.enumsimportStationarrivals=get_departures(Station.VAIHINGEN,limit=5)forarrivalinarrivals:ifarrival.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):
fromvvspyimportget_trip# also usable: get_tripsfromvvspy.enumsimportStationtrip=get_trip(Station.HAUPTBAHNHOF__TIEF,Station.HARDTLINDE)print(f"Duration:{trip.duration/60} minutes")forconnectionintrip.connections:print(f"From:{connection.origin.name} - To:{connection.destination.name}")
# Output:Duration: 58 minutesFrom: 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:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF)fordepindeps:ifdep.serving_line.symbol=="S4":print(f"Departure of S4 at{dep.real_datetime}")
  • Filter for specific platforms:
fromvvspyimportget_departuresfromvvspy.enumsimportStationdeps=get_departures(Station.HAUPTBAHNHOF__TIEF)fordepindeps:ifdep.platform=="101":print(f"Departure of{dep.serving_line.number} to{dep.serving_line.direction} on{dep.platform_name} at{dep.real_datetime}")

Get your station id

See:#64

Logging

vvspy uses the python logging module. If you want to change the log level of vvspy, use the following:

importlogginglogging.basicConfig(level=logging.INFO)logger=logging.getLogger("vvspy")logger.setLevel(logging.DEBUG)

⭐️ Project assistance

If you want to saythank you or/and support active development ofvvspy:

👀 Projects using vvspy

🔥 Other projects of the authors

  • discord-masz - MASZ is a selfhostable highly sophisticated moderation bot for Discord. Includes a web dashboard and a discord bot.

⚠️ License

vvspy is free and open-source software licensed undertheMIT.


[8]ページ先頭

©2009-2025 Movatter.jp