https://github.com/ce11an/tfl
A Python package for the Transport for London (TFL) API.
https://github.com/ce11an/tfl
cli client python tfl transport-for-london
Last synced: 7 months ago
JSON representation
A Python package for the Transport for London (TFL) API.
- Host: GitHub
- URL: https://github.com/ce11an/tfl
- Owner: Ce11an
- License: mit
- Created: 2023-05-01T13:08:01.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-09-25T14:58:11.000Z (over 2 years ago)
- Last Synced: 2025-06-21T04:08:38.581Z (12 months ago)
- Topics: cli, client, python, tfl, transport-for-london
- Language: Python
- Homepage: https://ce11an.github.io/tfl/
- Size: 950 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README

[](https://pypi.org/project/py-tfl/)
[](https://github.com/psf/black)
[](http://mypy-lang.org/)
[](https://github.com/charliermarsh/ruff)
[](https://github.com/Ce11an/tfl/blob/main/.pre-commit-config.yaml)
[](https://github.com/Ce11an/tfl/releases)


[](https://codecov.io/gh/Ce11an/tfl)
[](https://www.codefactor.io/repository/github/ce11an/tfl)
A Python package for the [Transport for London (TFL) API](https://api-portal.tfl.gov.uk).
The TFL API is a RESTful API that provides data related to all modes of transport in London, including cycle hire,
buses, roads, and the underground. Anonymous access to the TFL API is limited to 50 requests a minute. If you want to
call the API more than that, you'll need to subscribe to a "Product" which lets you bypass this limit with a
subscription-key that you append to your requests.
Currently, we support the following APIs:
- [Accident Stats API](https://api-portal.tfl.gov.uk/api-details#api=AccidentStats&operation=AccidentStats_Get)
- [Air Quality API](https://api-portal.tfl.gov.uk/api-details#api=AirQuality&operation=AirQuality_Get)
- [Crowding API](https://api-portal.tfl.gov.uk/api-details#api=crowding&operation=dayofweek)
- [Lift Disruptions API](https://api-portal.tfl.gov.uk/api-details#api=Disruptions-Lifts-v2&operation=get)
The plan is to add support for all the TFL APIs. Contributions are welcome!
## 🫶 Installation
```bash
pip install py-tfl
```
or install with [Poetry](https://python-poetry.org/):
```bash
poetry add py-tfl
```
## ⚡️Quickstart
### ⌨️ CLI
The TFL CLI provides a command line interface to the TFL API. It is built on top of
[Typer](https://typer.tiangolo.com/), which provides easy way to build command line interfaces.
```bash
tfl --help
```
### 🦋 Client
The TFL client provides a Python interface to the TFL API. It provides a Pythonic interface to the API, and handles
authentication and rate limiting for you. The client is built on top of [HTTPX](https://www.python-httpx.org/), which
provides a fast, async HTTP client.
```python
from tfl import clients
async with clients.TFLClient(auth=clients.Auth(key="")) as client:
response = await client.handlers.lift_disruptions_v2_handler.get_lift_disruptions()
print(response.json())
```
## 📈 Releases
You can see the list of available releases on the [GitHub Releases](https://github.com/Ce11an/tfl/releases)
page.
We follow [Semantic Versions](https://semver.org/) specification.
We use [`Release Drafter`](https://github.com/marketplace/actions/release-drafter). As pull requests are merged, a draft
release is kept up-to-date listing the changes, ready to publish when you’re ready. With the categories option, you can
categorize pull requests in release notes using labels.
## 🛡 License
[](https://github.com/Ce11an/tfl/blob/main/LICENSE)
This project is licensed under the terms of the `MIT` license. See [LICENSE](https://github.com/Ce11an/tfl/blob/main/LICENSE)
for more details.
## 🚀 Credits
A special thanks to HTTPX, Typer, and the TFL API team for making this project possible.
This project was built using [IntelliJ IDEA](https://www.jetbrains.com/community/opensource/?utm_campaign=opensource&utm_content=approved&utm_medium=email&utm_source=newsletter&utm_term=jblogo#support).
