Skip to main content

🚂 VVS API Wrapper

PackageVersion PythonVersions License

Fully object-oriented library to integrate the VVS 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:
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: 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}")

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:

import logging

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

⭐️ Project assistance

If you want to say thank you or/and support active development of vvspy:

👀 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 under the MIT.

Download files

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

Source Distribution

vvspy-2.3.1.tar.gz (256.3 kB view details)

Uploaded Source

Built Distribution

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

vvspy-2.3.1-py3-none-any.whl (260.9 kB view details)

Uploaded Python 3

File details

Details for the file vvspy-2.3.1.tar.gz.

File metadata

  • Download URL: vvspy-2.3.1.tar.gz
  • Upload date:
  • Size: 256.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for vvspy-2.3.1.tar.gz
Algorithm Hash digest
SHA256 4abead2aaa0ef57d81ff55859e366a328ba9a7f30c4d25d685d33b9c141645fd
MD5 978a5944908525f4c191e7d74329ed4a
BLAKE2b-256 12284d61807b0708fee27e92ecf41c7480c69bdd21b67b00fa09e90fa7c9acc0

See more details on using hashes here.

File details

Details for the file vvspy-2.3.1-py3-none-any.whl.

File metadata

  • Download URL: vvspy-2.3.1-py3-none-any.whl
  • Upload date:
  • Size: 260.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for vvspy-2.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1e32cc0e49b7c2daad2887e7d5704523cbe7aaae483e57c274af74bc17067e23
MD5 39e453ffbf16aa0c5987fb9e120c0c57
BLAKE2b-256 6c380aca6734aa226723091805cd0a8cc9c2839c477ddb701878fe51ad0e105a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.3.1 This release

2 files

2.3.0

2 files

2.2.0

2 files

2.1.0

2 files

2.0.2

2 files

2.0.1

2 files

2.0.0

2 files

1.2.0

2 files

1.1.4

2 files

1.1.3

1 file

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.0

1 file

0.3.0

1 file

0.2.1

1 file

0.2.0

1 file

0.1.1

1 file

0.1.0

1 file

0.0.9

1 file

0.0.8

1 file

Supported by

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