Skip to content

Air Quality Handler

Handler to interact with the air quality API.

AirQualityHandler

Bases: base.TFLHandler

Handler to interact with the air quality API.

API reference

Example
from tfl import clients


async with clients.TFLClient(auth=clients.Auth(key="<your-tfl-api-key>")) as client:
    response = await AirQualityHandler(client).get_air_quality()

print(response.json())
Source code in tfl/clients/handlers/_air_quality_handler.py
class AirQualityHandler(base.TFLHandler):
    """Handler to interact with the air quality API.

    [API reference](https://api-portal.tfl.gov.uk/api-details#api=AirQuality&operation=AirQuality_Get)

    Example:
        ```python
        from tfl import clients


        async with clients.TFLClient(auth=clients.Auth(key="<your-tfl-api-key>")) as client:
            response = await AirQualityHandler(client).get_air_quality()

        print(response.json())
        ```
    """

    async def get_air_quality(self) -> httpx.Response:
        """Gets current air quality data feed.

        Returns:
            The response from the API.
        """
        return await self.client.get(url=f"/AirQuality")

get_air_quality() async

Gets current air quality data feed.

Returns:

Type Description
httpx.Response

The response from the API.

Source code in tfl/clients/handlers/_air_quality_handler.py
async def get_air_quality(self) -> httpx.Response:
    """Gets current air quality data feed.

    Returns:
        The response from the API.
    """
    return await self.client.get(url=f"/AirQuality")