CLI reference¶
๐ Introduction¶
The TFL CLI provides a command line interface to the TFL API. It is built on top of Typer, which provides easy way to build command line interfaces. The TFL CLI is bundled with the TFL package. Once installed, you can use the CLI to access the TFL API.
โ Usage¶
The TFL CLI is available as tfl
after installation. You can see the available commands and options by running
tfl --help
:
Usage: tfl [OPTIONS] COMMAND [ARGS]...
tfl: A Python package for the Transport for London (TFL) API.
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --version Show the version and exit. โ
โ --install-completion Install completion for the current shell. โ
โ --show-completion Show completion for the current shell, to copy it or โ
โ customize the installation. โ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Commands โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ accident-stats Gets all accident details for accidents occurring in the specified year. โ
โ air-quality Get air quality data feed. โ
โ crowding Information about crowding levels within TFL stations. โ
โ lift-disruptions Get current lift disruptions. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
You can also see the available options and arguments for a specific command by running tfl <command> --help
.
For example:
which will output:
Usage: tfl lift-disruptions [OPTIONS] [KEY]
Get current lift disruptions.
โญโ Arguments โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ key [KEY] TFL API key. [env var: TFL_API_KEY] [default: None] โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
๐ Authentication¶
Anonymous access to the TFL API is limited to 50 requests a minute. You can register for an API key via the TFL API website. Once you have an API key, you can export it as an environment variable:
๐ Examples¶
Please note that the below outputs are examples, and the actual output may differ.
โ๏ธ Air quality¶
Get the current TFL air quality, run:
which will output:
Today's Air Quality
โโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ Air Pollution Banding โ Summary โ
โ โ โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ โ โ
โ Low โ Low air pollution forecast valid from Tuesday 9 May โ
โ โ to end of Thursday 11 May GMT โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
This forecast is intended to provide information on expected pollution levels in
areas of significant public exposure. It may not apply in very specific
locations close to unusually strong or short-lived local sources of pollution.
For more information, please visit: http://londonair.org.uk/forecast
๐ Lift disruptions¶
Get the current TFL lift disruptions, run:
which will output:
Lift Disruptions
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโณโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โ Station โ Message โ
โ โ โ
โกโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฉ
โ โ โ
โ Caledonian Road & Barnsbury โ Step free access is not available due to a โ
โ โ faulty lift. Call us on 0343 222 1234 if โ
โ โ you need help planning your journey. โ
โ โ โ
โ โ โ
โ Denmark Hill โ Step free access is not available to the โ
โ โ northbound platform due to a faulty lift. โ
โ โ Call us on 0343 222 1234 if you need help โ
โ โ planning your journey. โ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Current TFL lift disruptions.