Calling CHAPS REST API to get information about public transit in CZ
Project description
CzPubTran
A Python package to rertrieve realtime information about public transit in CZ by calling CHAPS REST API.
Main purpose at the moment is to feed a sensor in Home-Assistant
Install
pip install czpubtran
Example usage
import asyncio
import logging
from czpubtran.api import czpubtran
logging.basicConfig(level=logging.ERROR)
async def test():
session=aiohttp.ClientSession(raise_for_status=True)
bus = czpubtran(session,'')
await bus.async_find_connection('Chyne, Haje','Ortenovo namesti','ABCz')
print(f'Connection from {bus.origin} to {bus.destination} using timetable{bus.combination_id}')
print('------------------------------------------------')
print(f'Departure: {bus.departure} line {bus.line}')
print(f'Duration: {bus.duration}')
print('Connections:')
for connection in bus.connections:
print(f"line {connection['line']} "
f"at {connection['depTime']} "
f"from {connection['depStation']} "
f"-> {connection['arrStation']} "
f"{connection['arrTime']} "
f"(delay: {connection['delay']} min)")
await session.close()
asyncio.run(test())```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
czpubtran-0.1.3.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for czpubtran-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2ef749cdc44d8a6fa22966f11751a16789412f913e11edacc64bf3db54bd831 |
|
MD5 | 0e694bfecec57e6a0b71a0792e7e7fe9 |
|
BLAKE2b-256 | 20909be8e672b20fdc613a8b529e0cb073978042429298b6b25528c909f5b029 |