Git Product home page Git Product logo

pystibmivb's Introduction

pystibmivb GitHub version Build Status PyPI version Buy me a beer!

A Python package to retrieve realtime data of passages at stops of STIB/MIVB, the public transport company of Brussels (Belgium)

Main purpose at the moment is to feed a sensor in Home-Assistant (see: https://github.com/Emilv2/home-assistant/tree/stib-mivb/homeassistant/components/stib_mivb )

Important note: a developer account needs to be created at https://opendata.stib-mivb.be/ to generate a subscription key for the api's.

Install

pip install pystibmivb

Example usage

"""Example usage of pystibmivb."""
import asyncio

import aiohttp

from pystibmivb import STIBAPIClient, STIBStop, STIBAPIAuthClient
from pystibmivb import STIBService
from pystibmivb import ShapefileService

CLIENT_ID = ''  # Put your openapi client ID here
CLIENT_SECRET = ''  # Put your openapi client secret here


async def go(LOOP):
    stop_name = "Scherdemael"
    lines_filter = [(46, "Glibert")]
    custom_session = aiohttp.ClientSession()
    APIClient = STIBAPIClient(LOOP, custom_session, STIBAPIAuthClient(custom_session, CLIENT_ID, CLIENT_SECRET))
    service = STIBService(APIClient)

    stop = STIBStop(service, stop_name, lines_filter, 3)
    print(await stop.get_passages())

    shapefile_service = ShapefileService(APIClient)

    scherdemael = await shapefile_service.get_stop_infos(stop_name)
    print(scherdemael.get_lines())
    # doesn't really make sense to specify a filter but hey... you can
    print(scherdemael.get_lines(lines_filter))
    print(scherdemael.get_lines_with_destinations(lines_filter))

    await custom_session.close()


if __name__ == '__main__':
    LOOP = asyncio.get_event_loop()
    LOOP.run_until_complete(go(LOOP))

Old repository: https://github.com/helldog136/pystibmvib Initial inspiration came from : https://github.com/bollewolle/pydelijn

pystibmivb's People

Contributors

helldog136 avatar danito avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.