datagovsg.transport¶
Client for interacting with the Transport APIs.
Example usage:
# get the list of available taxis
from datagovsg import Transport
from datagovsg.transport.types import TaxiAvailabilityDict
transport = Transport()
taxi_availability: TaxiAvailabilityDict = transport.taxi_availability()
Methods¶
- class datagovsg.transport.client.Client(api_key: str | None = None, cache_backend: str | BaseCache = 'sqlite')¶
Bases:
DataGovSgInteract with the transport-related endpoints.
Reference: https://data.gov.sg/datasets?formats=API&topics=transport
- taxi_availability(**kwargs: Unpack[TransportArgsDict]) TaxiAvailabilityDict¶
Get locations of available taxis in Singapore.
Retrieved every 30 seconds from LTA’s Datamall.
- Parameters:
kwargs (TransportArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
GeoJSON of the taxi availabilities. (Cached for 30 seconds.)
- Return type:
- traffic_images(**kwargs: Unpack[TransportArgsDict]) list[TrafficImagesItemDict]¶
Get the latest images from traffic cameras all around Singapore.
Retrieved every 20 seconds from LTA’s Datamall. But it is recommended to retrieve the data every minute.
- Parameters:
kwargs (TransportArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Images from traffic cameras. (Cached for 1 minute.)
- Return type: