Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/becheran/vgn
Python API for the Verkehrsverbund Grossraum Nuernberg (VGN)
https://github.com/becheran/vgn
async nuremberg public-transport python-api rest-client vgn
Last synced: 2 months ago
JSON representation
Python API for the Verkehrsverbund Grossraum Nuernberg (VGN)
- Host: GitHub
- URL: https://github.com/becheran/vgn
- Owner: becheran
- License: mit
- Created: 2020-02-05T21:38:41.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-28T20:03:00.000Z (2 months ago)
- Last Synced: 2024-10-28T21:18:53.395Z (2 months ago)
- Topics: async, nuremberg, public-transport, python-api, rest-client, vgn
- Language: Python
- Size: 5.74 MB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# VGN
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
![Version](https://img.shields.io/pypi/v/vgn)
[![PyPI download month](https://img.shields.io/pypi/dm/vgn.svg)](https://pypi.python.org/pypi/vgn/)
[![Python versions](https://img.shields.io/pypi/pyversions/vgn.svg)](https://img.shields.io/pypi/pyversions/vgn)
[![Documentation Status](https://readthedocs.org/projects/vgn/badge/?version=stable)](https://vgn.readthedocs.io/en/stable/?badge=stable)
[![Build Status](https://gitlab.com/becheran/vgn_ci_job/badges/master/pipeline.svg)](https://gitlab.com/becheran/vgn_ci_job/pipelines)Asynchronous Python API for the *Verkehrsverbund Grossraum Nuernberg (VGN)*.
Uses the official [REST-API](https://start.vag.de/dm/) to query realtime public transport information for Nuremberg.
With the python 3.7 feature [asyncio tasks](https://docs.python.org/3/library/asyncio-task.html) fast and non-blocking queries are possible.
[Read the docs](https://vgn.readthedocs.io/en/stable/) for more information.
Consider installing `cchardet` and `aiodns` via pip for speedup (see the [aiohttp documentation](https://docs.aiohttp.org/en/stable/)).
## Example
``` python
import vgn
import asyncioasync def main():
async with vgn.VGNClient() as vgn_client:
res = await asyncio.gather(
vgn_client.api_version(),
vgn_client.departure_schedule(704),
vgn_client.departure_schedule_for_line(704, "U2"),
vgn_client.rides(vgn.TransportType.BUS, 30),
)print(f'Api version: {res[0]}')
print(f'Departures at plaerrer in nbg: {res[1]}')
print(f'Departures of underground line 2 at plaerrer in nbg: {res[2]}')
print(f'Bus departures in the next 30 minutes: {res[3]}')if __name__ == '__main__':
asyncio.run(main())
```