Get realtime info on stop passages of De Lijn (api.delijn.be)
Project description
pydelijn
A Python package to retrieve realtime data of passages at stops of De Lijn, the public transport company in Flanders (Belgium)
Main purpose at the moment is to feed a sensor in Home-Assistant
Important note: a developer account needs to be created at https://data.delijn.be to generate a subscription key for the api's.
Install
pip install pydelijn
Example usage
"""Example usage of pydelijn."""
import asyncio
import aiohttp
from pydelijn.api import Passages
async def test_pydelijn():
"""Example usage of pydelijn."""
subscriptionkey = '<put your data.delijn.be subscriptionkey here>'
stopid = 200551
maxpassages = 10
custom_session = aiohttp.ClientSession()
delijndata = Passages(LOOP,
stopid,
maxpassages,
subscriptionkey,
custom_session,
True)
await delijndata.get_passages()
await custom_session.close()
print_data(delijndata)
def print_data(delijndata):
"""Pretty Print the data."""
for line in delijndata.passages:
print("----------------------------------------")
print("Passage #: %s" % (line['passage']))
print("Stop Name: %s" % (line['stopname']))
print("Line Number (technical): %s" % (line['line_number']))
print("Line Number (public): %s" % (line['line_number_public']))
print("Line Description: %s" % (line['line_desc']))
print("Line Transport Type: %s" % (line['line_transport_type']))
print("Direction: %s" % (line['direction']))
print("Final Destination: %s" % (line['final_destination']))
print("Due At (schedule): %s" % (line['due_at_schedule']))
print("Due At (real-time): %s" % (line['due_at_realtime']))
print("Due In (min): %s" % (line['due_in_min']))
print("Line Colour - Front: %s - Hex: %s" % (
line['line_number_colourFront'],
line['line_number_colourFrontHex']))
print("Line Colour - Back: %s - Hex: %s" % (
line['line_number_colourBack'],
line['line_number_colourBackHex']))
print("Line Colour - Front Border: %s - Hex: %s" % (
line['line_number_colourFrontBorder'],
line['line_number_colourFrontBorderHex']))
print("Line Colour - Back Border: %s - Hex: %s" % (
line['line_number_colourBackBorder'],
line['line_number_colourBackBorderHex']))
LOOP = asyncio.get_event_loop()
LOOP.run_until_complete(test_pydelijn())
LOOP.close()
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
pydelijn-1.1.0.tar.gz
(6.4 kB
view details)
Built Distribution
File details
Details for the file pydelijn-1.1.0.tar.gz
.
File metadata
- Download URL: pydelijn-1.1.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7206ada1de2a546ab923097abd1886d8edb86c7fdef6f5a4301dd7b7a392ba8 |
|
MD5 | 904a99fc111cc9b07079a39da9989cc4 |
|
BLAKE2b-256 | 6d72c3b2782bd5b28c0c97a94433c1defe5ef817eb973104f223e8beaba75b2b |
File details
Details for the file pydelijn-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: pydelijn-1.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99eb4da1368fbf6e8a0f6e1b4ecaa618d2e3e6ccd8f3cd5e82e3cf4d6e9f8fa2 |
|
MD5 | ff5e53c69c519a6e45b7ae714337dbdc |
|
BLAKE2b-256 | d3e7bb906d51aa52eb6adbfb8f83bad6048bf43d17b9cfad3da5b50940518f2f |