Skip to main content

A Python wrapper for the Unified API of the Transport for London

Project description

Python wrapper for the Unified API of the Transport for London

This repo contains a Python library with some classes to easily access the Unified API of the Transport for London which allows the access to the BikePoints, Bus Lines and Places services among others. These services are part of the public TfL open data platform.

In addition to the Python wrapper some test applications are included; this will help you know how everything works and, on top of that, you can use it to interact with the service. No credentials are needed to use the services covered at the moment.

The following are the requirements needed to make it work:

  • Python 3 (3.7.3+)

This Python library has been successfully tested with OSBDET S21R1 on a Debian 10 x64 host.

Remember to add the library to the PYTHONPATH environment variable if you want to use it from your code or if you want to run the tests Python scripts; you can do so by running the following line within the folder where the repo was cloned:

$ export PYTHONPATH=$PYTHONPATH:`pwd`

If you want to persist this environment variable, add it to your user's profile and it'll be created everytime you log into your computer.

BikePoint

The BikePoint class allows you to leverage information about bike point locations in the great city of London; this class wrapps the BikePoint API, although not all the functions/webmethods are wrapped.

The following are the functions/webmethods wrapped at the moment:

  • info_bikepoint_locations() - Gets all bike point locations. The Place object has an addtionalProperties array which contains the nbBikes, nbDocks and nbSpaces numbers which givethe status of the BikePoint. A mismatch in these numbers i.e. nbDocks - (nbBikes + nbSpaces) != 0 indicates broken docks.
  • info_bikepoint(bikepoint_id) - Gets the bike point with the given id.

test_bikepoint.py let you test this service easily; no credentials are needed. test_bikepoint.py -h will give you all the details on how to run it:

$ python3 tests/test_bikepoint.py -h
usage: test_bikepoint.py [-h] [-bid BIKEPOINT_ID]
                         {info_bikepoint_locations,info_bikepoint}

positional arguments:
  {info_bikepoint_locations,info_bikepoint}
                        what is going to be requested to the Unified API
                        service

optional arguments:
  -h, --help            show this help message and exit
  -bid BIKEPOINT_ID, --bikepoint_id BIKEPOINT_ID
                        bikepoint identifier for action 'info_bikepoint'

BusService

The BusService class allows you to leverage information about bus lines in the great city of London; this class wrapps the Line API, although not all the functions/webmethods are wrapped.

The following are the functions/webmethods wrapped at the moment:

  • info_bus_lines() - Gets lines that serve the given modes.
  • status_bus_lines() - Gets the line status of for all bus lines.
  • status_bus_line(bus_line_id) - Gets the line status of for given line id.

test_busservice.py let you test this service easily; no credentials are needed. test_busservice.py -h will give you all the details on how to run it:

$ python3 tests/test_busservice.py -h
usage: test_busservice.py [-h] [-bid BUS_LINE_ID]
                          {info_bus_lines,status_bus_lines,status_bus_line}

positional arguments:
  {info_bus_lines,status_bus_lines,status_bus_line}
                        what is going to be requested to the Unified API
                        service

optional arguments:
  -h, --help            show this help message and exit
  -bid BUS_LINE_ID, --bus_line_id BUS_LINE_ID
                        bus line identifier for action 'status_bus_line'

Places

The Places class allows you to leverage information about places in the great city of London; this class wrapps the Place API, although not all the functions/webmethods are wrapped. Only ChargeStation and ChargeConnector places are considered at the moment.

The following are the functions/webmethods wrapped at the moment:

  • info_charge_connectors() - Gets all available charge connectors.
  • info_charge_stations() - Gets all available charge stations.

test_places.py let you test this service easily; no credentials are needed. test_places.py -h will give you all the details on how to run it:

$ python3 tests/test_places.py -h
usage: test_places.py [-h] {info_charge_connectors,info_charge_stations}

positional arguments:
  {info_charge_connectors,info_charge_stations}
                        what is going to be requested to the Unified API
                        service

optional arguments:
  -h, --help            show this help message and exit

Changelog

  • v0.1 (20210502) - initial release.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

tfl-bsdprof-0.1.tar.gz (26.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tfl_bsdprof-0.1-py3-none-any.whl (29.6 kB view details)

Uploaded Python 3

File details

Details for the file tfl-bsdprof-0.1.tar.gz.

File metadata

  • Download URL: tfl-bsdprof-0.1.tar.gz
  • Upload date:
  • Size: 26.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3

File hashes

Hashes for tfl-bsdprof-0.1.tar.gz
Algorithm Hash digest
SHA256 d3955ab33357228cf8135df4ace0528d5178247affa739d960aac2c588461a06
MD5 252836df9c890eb936707d0a3d2b931e
BLAKE2b-256 55046e4a713f777a814fd79bea359293e08f2cef7825465a931a38e17de938af

See more details on using hashes here.

File details

Details for the file tfl_bsdprof-0.1-py3-none-any.whl.

File metadata

  • Download URL: tfl_bsdprof-0.1-py3-none-any.whl
  • Upload date:
  • Size: 29.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.3

File hashes

Hashes for tfl_bsdprof-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b00a8da5eae3690d247e19b58986d8767c12903812e6f5fdcf0a0d86c6ee5adb
MD5 6b796b6ab447dc1e0f0c1a6411ca4772
BLAKE2b-256 d98635a9033bfd286db24256a86e36cc33ce4cbe99a0245b9efbddbdadfe4229

See more details on using hashes here.

Supported by

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