Giter Site home page Giter Site logo

daniel157 / vvspy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zaanposni/vvspy

0.0 0.0 0.0 591 KB

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

Home Page: https://vvspy.readthedocs.io/en/latest/

License: MIT License

Shell 0.06% Python 99.88% Batchfile 0.05%

vvspy's Introduction

VVS API Wrapper

Checkup status Checkup status

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

Installation

Python 3.6 or higher required

pip install vvspy

Examples

  • Detect delay in upcoming departures:
from vvspy import get_departures

deps = get_departures("5006115", limit=3)  # Stuttgart main station
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
  • Get complete trip info between two stations (including interchanges):
from vvspy import get_trip  # also usable: get_trips

trip = get_trip("5000355", "5005600")  # Stuttgart main station

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

deps = get_departures("5006118")  # Stuttgart main station (lower)
for dep in deps:
    if dep.serving_line.symbol == "S4":
        print(f"Departure of S4 at {dep.real_datetime}")

Get your station id

See: zaanposni#12 (comment)

Features

  • full customizable requests and parameters

  • parsing all available info into result obj

  • Well tested and maintained

  • Departures, Arrivals, Trips, Station info, Upcoming events, Maintenance work

  • See issues/projects on GitHub for upcoming features

Contributors

Projects using vvspy

License:

This project is licensed under MIT.

vvspy's People

Contributors

zaanposni avatar arpiix avatar daniel157 avatar mhorst00 avatar monkmitrad avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.