Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pydelijn

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pydelijn

Get realtime info on stop passages of De Lijn (api.delijn.be)

  • 1.1.0
  • PyPI
  • Socket score

Maintainers
2

pydelijn

PyPI version Build Status

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()

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc