landtransportsg.traffic¶
Traffic module.
Example usage:
# get the list of available car park spaces
from landtransportsg import Traffic
client = Traffic(API_KEY)
patents = client.carpark_availability()
Methods¶
- class landtransportsg.traffic.Client(account_key: str)¶
Bases:
LtaInteract with the traffic-related endpoints.
References: https://datamall.lta.gov.sg/content/dam/datamall/datasets/LTA_DataMall_API_User_Guide.pdf
- Parameters:
account_key (str)
- carpark_availability() list[CarParkAvailabilityDict | dict]¶
Get number of available lots from HDB, LTA and URA carpark data.
- Returns:
Available carpark lots.
- Return type:
- erp_rates() list[None]¶
Get ERP rates of all vehicle types across all timings for each zone.
This endpoint was removed from DataMall v6.1 on 30 September 2024. This method will be removed in this package’s next major release.
- Warns DeprecationWarning:
Inform the developer that this method has been deprecated.
- Returns:
ERP rates per vehicle type by zones. Empty list.
- Return type:
list[None]
- estimated_travel_times() list[EstimatedTravelTimesDict | dict]¶
Get estimated travel times of expressways (in segments).
- Returns:
Expressway estimated travel times by segments.
- Return type:
- faulty_traffic_lights() list[FaultyTrafficLightsDict | dict]¶
Get alerts of traffic lights that are currently faulty, or currently undergoing scheduled maintenance.
- Returns:
Traffic light alerts and their status.
- Return type:
- road_openings() list[RoadOpeningsDict | dict]¶
Get all planned road openings.
- Returns:
Road openings for road works.
- Return type:
- road_works() list[RoadWorksDict | dict]¶
Get approved road works to be carried out/being carried out.
- Returns:
Road works to be carried out/being carried out.
- Return type:
- traffic_flow() str¶
Get hourly average traffic flow, taken from a representative month of every quarter during 0700-0900 hours.
- Returns:
Link to download the hourly average traffic flow. The link will expire after 5 minutes.
- Return type:
Url
- traffic_images() list[TrafficImagesDict | dict]¶
Get links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints.
- Returns:
Traffic images at expressways and checkpoints.
- Return type:
- traffic_incidents() list[TrafficIncidentsDict | dict]¶
Get incidents currently happening on the roads, such as Accidents, Vehicle Breakdowns, Road Blocks, Traffic Diversions etc.
- Returns:
Traffic incidents currently happening.
- Return type:
- traffic_speed_bands() list[TrafficSpeedBandsDict | dict]¶
Get current traffic speeds on expressways and arterial roads, expressed in speed bands.
- Returns:
Traffic speed bands on expressways and arterial roads.
- Return type:
Types¶
- class landtransportsg.traffic.CarParkAvailabilityDict¶
Bases:
TypedDictType definition for carpark_availability()
- CarParkID: str¶
A unique code for this carpark. Example (LTA): “1”. Example (URA): “A0007”. Example (HDB): “KB7”.
- Area: str¶
Area of development / building: - blank. - “Orchard”. - “Marina”. - “Harbfront”. - “JurongLakeDistrict”. Example (LTA): “Marina”. Example (URA): “”. Example (HDB): “”.
- Development: str¶
Major landmark or address where carpark is located. Example (LTA): “Suntec City”. Example (URA): “ANGULLIA PARK OFF STREET”. Example (HDB): “BLK 69 GEYLANG BAHRU”.
- Location: str¶
Latitude and Longitude map coordinates. Example (LTA): “1.29375 103.85718”. Example (URA): “1.3114801086966732 103.77050251295184”. Example (HDB): “1.3016364093613493 103.7967913879039”.
- class landtransportsg.traffic.EstimatedTravelTimesDict¶
Bases:
TypedDictType definition for estimated_travel_times()
- Direction: int¶
Direction of travel: - 1 - Travelling from east to west, or south to north. - 2 - Travelling from west to east, or north to south. Example: 1.
- class landtransportsg.traffic.FaultyTrafficLightsDict¶
Bases:
TypedDictType definition for faulty_traffic_lights()
- class landtransportsg.traffic.RoadOpeningsDict¶
Bases:
TypedDictType definition for road_openings()
- StartDate: date¶
Start date for the works to be performed for this road opening. Example: date(2016, 3, 31).
- EndDate: date¶
End date for the works to be performed for this road opening. Example: date(2016, 9, 30).
- class landtransportsg.traffic.RoadWorksDict¶
Bases:
TypedDictType definition for road_works()
- StartDate: date¶
Start date for the works to be performed for this road work. Example: date(2016, 3, 31).
- EndDate: date¶
End date for the works to be performed for this road work. Example: date(2016, 9, 30).
- class landtransportsg.traffic.TrafficImagesDict¶
Bases:
TypedDictType definition for traffic_images()
- ImageLink: str¶
Link for downloading this image. Link will expire after 5 minutes. Example: https://dm-traffic-camera-itsc.s3.amazonaws.com/2020-04-01/09-24/1001_0918_20200401092500_e0368e.jpg?x-amz-security-token=…
- class landtransportsg.traffic.TrafficIncidentsDict¶
Bases:
TypedDictType definition for traffic_incidents()
- Type: str¶
Incident Types: - “Accident”. - “Road Works”. - “Vehicle Breakdown”. - “Weather”. - “Obstacle”. - “Road Block”. - “Heavy Traffic”. - “Misc.”. - “Diversion”. - “Unattended Vehicle”. Example: “Vehicle Breakdown”.
- Latitude: float¶
Latitude map coordinates for the start point of this road incident. Example: 1.30398068448214.
- class landtransportsg.traffic.TrafficSpeedBandsDict¶
Bases:
TypedDictType definition for traffic_speed_bands()
- RoadCategory: str¶
Road Category: - “A” - Expressways. - “B” - Major Arterial Roads. - “C” - Arterial Roads. - “D” - Minor Arterial Roads. - “E” - Small Roads. - “F” - Slip Roads. - “G” - No category info available. Example: “B”.
- SpeedBand: int¶
Speed Bands Information: - 1 - indicates speed range from 0 < 9. - 2 - indicates speed range from 10 < 19. - 3 - indicates speed range from 20 < 29. - 4 - indicates speed range from 30 < 39. - 5 - indicates speed range from 40 < 49. - 6 - indicates speed range from 50 < 59. - 7 - indicates speed range from 60 < 69. - 8 - speed range from 70 or more. Example: 2.
- StartLon: str¶
Longitude map coordinates for start point for this stretch of road. Example: “103.86246461405193”.
- StartLat: str¶
Latitude map coordinates for start point for this stretch of road. Example: “1.3220591510051254”.