Authentication
This module contains objects for authenticating with the TFL API.
Using the Auth
class, you can authenticate with the TFL API using your API key. When a request is sent, the API key
will be added to the request URL.
You can register for an API key via the TFL API website. An API key is not required to use the TFL API. However, without registering for an API key, you will be limited to 50 requests per hour. If an invalid API key is provided an error by the TFL API will be returned.
Auth
¶
Bases: httpx.Auth
The authentication class for Transport for London API.
Using the Auth
class, you can authenticate with the TFL API using your API key. When a request is sent, the API
key will be added to the request URL.
Example
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The TFL API key. |
required |
Source code in tfl/clients/_auth.py
auth_flow(request)
¶
Add the API key to the request.
The key will be added to the request URL as a query parameter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
request |
httpx.Request
|
The request to be sent. |
required |
Returns:
Type | Description |
---|---|
Generator[httpx.Request, Any, None]
|
The request with the API key added to the URL. |