Skip to main content

Library that interacts with TMB API

Project description

tmb - Python library for TMB API

build downloads version

Library to interact with the TMB (Transports Metropolitans de Barcelona) API.

Currently it supports the following TMB services:

  • iBus (get remain minutes for a given stop and line)
  • Planner (Get list of itineraries to go from from_coords to to_coords)

Generate API keys

  • Go to developer.tmb.cat.
  • Login using your personal account.
  • Create a new application, call it as you want.
  • Once created, you will see two variables: APP_ID and APP_KEY.

Example

iBus

Create the iBus object using the API keys generated from TMB portal.

from tmb import IBus

ibus = IBus(APP_ID, APP_KEY)
forecast = ibus.get_stop_forecast('1265','V19')
print(f"{forecast} mins")

Planner

Create the Planner object using the API keys generated from TMB portal.

from tmb import Planner

planner = Planner(APP_ID, APP_KEY)
plans = planner.get_itineraries('41.3755204,2.1498870', '41.3878951,2.1308587')
print(plans)

Projects Depending on tmb

https://github.com/home-assistant/home-assistant

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tmb-0.1.5.tar.gz (4.5 kB view hashes)

Uploaded Source

Built Distribution

tmb-0.1.5-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page