# 🚂 VVS API Wrapper
[![PackageVersion][package_version_img]][package_version_img]
[![PythonVersions][python_versions_img]][python_versions_img]
[![License][repo_license_img]][repo_license_url]
**Fully object-oriented library** to integrate the **VVS API** into your project.
## Installation
```bash
pip install vvspy
```
## Examples
- Detect delay in upcoming departures:
```python
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:
```python
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):
```python
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}")
```
```text
# 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:
```python
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:
```python
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][station_id_issue_url]
### Logging
vvspy uses the python logging module. If you want to change the log level of vvspy, use the following:
```python
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`:
- Add a [GitHub Star][repo_url] to the project.
- Support me on [Ko-fi][kofi_url].
## 🏆 A win-win cooperation
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][repo_issues_url]: ask questions and submit your features.
- [Pull requests][repo_pull_request_url]: send your improvements to the current.
- [Mail][mail_url]: send your ideas for the project.
- [Discord][discord_url]: add me as a friend on Discord: @zaanposni
Together, we can make this project **better** every day!
## 👀 Projects using vvspy
- [vvs_direct_connect][vvs_direct_connect_url] is a dockerized REST service providing departure data by aschuma.
## 🔥 Other projects of the authors
- [discord-masz][discord_masz_url] - MASZ is a selfhostable highly sophisticated moderation bot for Discord. Includes a web dashboard and a discord bot.
## ⚠️ License
[vvspy][repo_url] is free and open-source software licensed under
the [MIT][repo_license_url].
<!-- Repository -->
[repo_url]: https://github.com/zaanposni/vvspy
[repo_issues_url]: https://github.com/zaanposni/vvspy/issues
[repo_pull_request_url]: https://github.com/zaanposni/vvspy/pulls
[repo_license_url]: https://github.com/zaanposni/vvspy/blob/master/LICENSE
[repo_license_img]: https://img.shields.io/badge/license-MIT-red?style=for-the-badge&logo=none
[python_versions_img]: https://img.shields.io/pypi/pyversions/vvspy?style=for-the-badge
[package_version_img]: https://img.shields.io/pypi/v/vvspy?style=for-the-badge
[station_id_issue_url]: https://github.com/zaanposni/vvspy/issues/64
<!-- Author -->
[kofi_url]: https://ko-fi.com/zaanposni
[discord_masz_url]: https://github.com/zaanposni/discord-masz
[mail_url]: mailto:vvspy@zaanposni.com
[discord_url]: https://discord.com
<!-- Projects -->
[vvs_direct_connect_url]: https://github.com/aschuma/vvs_direct_connect
Raw data
{
"_id": null,
"home_page": "https://github.com/zaanposni/vvspy",
"name": "vvspy",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "vvs, api, stuttgart, wrapper, json, rest, efa, python",
"author": "zaanposni",
"author_email": "vvspy@zaanposni.com",
"download_url": "https://files.pythonhosted.org/packages/9e/4d/2abd9285340945860f194f01f46639ef82d94e54c2131ae58301fb456d4a/vvspy-2.2.0.tar.gz",
"platform": null,
"description": "# \ud83d\ude82 VVS API Wrapper\n\n[![PackageVersion][package_version_img]][package_version_img]\n[![PythonVersions][python_versions_img]][python_versions_img]\n[![License][repo_license_img]][repo_license_url]\n\n**Fully object-oriented library** to integrate the **VVS API** into your project.\n\n## Installation\n\n```bash\npip install vvspy\n```\n\n## Examples\n\n- Detect delay in upcoming departures:\n\n```python\nfrom vvspy import get_departures\nfrom vvspy.enums import Station\n\ndeps = get_departures(Station.HAUPTBAHNHOF__TIEF, limit=3)\nfor dep in deps:\n if dep.delay > 0:\n print(\"Alarm! Delay detected.\")\n print(dep) # [Delayed] [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof\n\n else:\n print(\"Train on time\")\n print(dep) # [11:47] [RB17]: Stuttgart Hauptbahnhof (oben) - Pforzheim Hauptbahnhof\n```\n\n- Detect cancellations in upcoming departures/arrivals:\n\n```python\nfrom vvspy import get_departures\nfrom vvspy.enums import Station\n\narrivals = get_departures(Station.VAIHINGEN, limit=5)\n\nfor arrival in arrivals:\n if arrival.cancelled:\n print(f\"Alarm! The train at {arrival.real_datetime} has been cancelled!\")\n # Check arrival.stop_infos and arrival.line_infos for more information\n```\n\n- Get complete trip info between two stations (including interchanges):\n\n```python\nfrom vvspy import get_trip # also usable: get_trips\nfrom vvspy.enums import Station\n\ntrip = get_trip(Station.HAUPTBAHNHOF__TIEF, Station.HARDTLINDE)\n\nprint(f\"Duration: {trip.duration / 60} minutes\")\nfor connection in trip.connections:\n print(f\"From: {connection.origin.name} - To: {connection.destination.name}\")\n```\n\n```text\n# Output:\nDuration: 58 minutes\nFrom: Wallgraben - To: Hauptbf (A.-Klett-Pl.)\nFrom: Hauptbf (Arnulf-Klett-Platz) - To: Stuttgart Hauptbahnhof (tief)\nFrom: Stuttgart Hauptbahnhof (tief) - To: Marbach (N)\nFrom: Marbach (N) Bf - To: Murr Hardtlinde\n```\n\n- Filter for specific lines:\n\n```python\nfrom vvspy import get_departures\nfrom vvspy.enums import Station\n\ndeps = get_departures(Station.HAUPTBAHNHOF__TIEF)\nfor dep in deps:\n if dep.serving_line.symbol == \"S4\":\n print(f\"Departure of S4 at {dep.real_datetime}\")\n```\n\n- Filter for specific platforms:\n\n```python\nfrom vvspy import get_departures\nfrom vvspy.enums import Station\n\ndeps = get_departures(Station.HAUPTBAHNHOF__TIEF)\nfor dep in deps:\n if dep.platform == \"101\":\n print(f\"Departure of {dep.serving_line.number} to {dep.serving_line.direction} on {dep.platform_name} at {dep.real_datetime}\")\n```\n\n### Get your station id\n\nSee: [#64][station_id_issue_url]\n\n### Logging\n\nvvspy uses the python logging module. If you want to change the log level of vvspy, use the following:\n\n```python\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(\"vvspy\")\nlogger.setLevel(logging.DEBUG)\n```\n\n## \u2b50\ufe0f Project assistance\n\nIf you want to say **thank you** or/and support active development of `vvspy`:\n\n- Add a [GitHub Star][repo_url] to the project.\n- Support me on [Ko-fi][kofi_url].\n\n## \ud83c\udfc6 A win-win cooperation\n\nAnd now, I invite you to participate in this project! Let's work **together** to\ncreate the **most useful** tool for all PietSmiet Enjoyers.\n\n- [Issues][repo_issues_url]: ask questions and submit your features.\n- [Pull requests][repo_pull_request_url]: send your improvements to the current.\n- [Mail][mail_url]: send your ideas for the project.\n- [Discord][discord_url]: add me as a friend on Discord: @zaanposni\n\nTogether, we can make this project **better** every day!\n\n## \ud83d\udc40 Projects using vvspy\n\n- [vvs_direct_connect][vvs_direct_connect_url] is a dockerized REST service providing departure data by aschuma.\n\n## \ud83d\udd25 Other projects of the authors\n\n- [discord-masz][discord_masz_url] - MASZ is a selfhostable highly sophisticated moderation bot for Discord. Includes a web dashboard and a discord bot.\n\n## \u26a0\ufe0f License\n\n[vvspy][repo_url] is free and open-source software licensed under\nthe [MIT][repo_license_url].\n\n<!-- Repository -->\n\n[repo_url]: https://github.com/zaanposni/vvspy\n[repo_issues_url]: https://github.com/zaanposni/vvspy/issues\n[repo_pull_request_url]: https://github.com/zaanposni/vvspy/pulls\n[repo_license_url]: https://github.com/zaanposni/vvspy/blob/master/LICENSE\n[repo_license_img]: https://img.shields.io/badge/license-MIT-red?style=for-the-badge&logo=none\n\n[python_versions_img]: https://img.shields.io/pypi/pyversions/vvspy?style=for-the-badge\n[package_version_img]: https://img.shields.io/pypi/v/vvspy?style=for-the-badge\n\n[station_id_issue_url]: https://github.com/zaanposni/vvspy/issues/64\n\n<!-- Author -->\n\n[kofi_url]: https://ko-fi.com/zaanposni\n[discord_masz_url]: https://github.com/zaanposni/discord-masz\n[mail_url]: mailto:vvspy@zaanposni.com\n[discord_url]: https://discord.com\n\n<!-- Projects -->\n\n[vvs_direct_connect_url]: https://github.com/aschuma/vvs_direct_connect\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "API Wrapper for VVS (Verkehrsverbund Stuttgart)",
"version": "2.2.0",
"project_urls": {
"Homepage": "https://github.com/zaanposni/vvspy"
},
"split_keywords": [
"vvs",
" api",
" stuttgart",
" wrapper",
" json",
" rest",
" efa",
" python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2d1658e83cf3ceacee67c4e374f0196e73f3eeaf039ad293687265618b7ac04e",
"md5": "4daf751e9eeb3af5d7b8ffa1bccd251f",
"sha256": "8e1ba4ceac753c5fbbdcfee300ebc25d329b351f3577ea64e216cdf285996cf0"
},
"downloads": -1,
"filename": "vvspy-2.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4daf751e9eeb3af5d7b8ffa1bccd251f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 260784,
"upload_time": "2024-06-16T14:27:55",
"upload_time_iso_8601": "2024-06-16T14:27:55.559919Z",
"url": "https://files.pythonhosted.org/packages/2d/16/58e83cf3ceacee67c4e374f0196e73f3eeaf039ad293687265618b7ac04e/vvspy-2.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e4d2abd9285340945860f194f01f46639ef82d94e54c2131ae58301fb456d4a",
"md5": "04f277dfbea13f0673861126fcbdb0f6",
"sha256": "4c59ece075c6425db107d6f35d20b15f6594e91d72c668dfac1d865e9ac0f393"
},
"downloads": -1,
"filename": "vvspy-2.2.0.tar.gz",
"has_sig": false,
"md5_digest": "04f277dfbea13f0673861126fcbdb0f6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 256333,
"upload_time": "2024-06-16T14:27:57",
"upload_time_iso_8601": "2024-06-16T14:27:57.417697Z",
"url": "https://files.pythonhosted.org/packages/9e/4d/2abd9285340945860f194f01f46639ef82d94e54c2131ae58301fb456d4a/vvspy-2.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-16 14:27:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "zaanposni",
"github_project": "vvspy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "requests",
"specs": [
[
"==",
"2.32.0"
]
]
},
{
"name": "typing",
"specs": [
[
"==",
"3.7.4.3"
]
]
}
],
"lcname": "vvspy"
}