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, cache_backend: str | BaseCache = 'sqlite')¶
Bases:
LandTransportSgInteract with the traffic-related endpoints.
References: https://datamall.lta.gov.sg/content/dam/datamall/datasets/LTA_DataMall_API_User_Guide.pdf
- carpark_availability() list[CarParkAvailabilityDict]¶
Get number of available lots from HDB, LTA and URA carpark data.
- Returns:
Available carpark lots.
- Return type:
- estimated_travel_times() list[EstimatedTravelTimesDict]¶
Get estimated travel times of expressways (in segments).
- Returns:
Expressway estimated travel times by segments.
- Return type:
- faulty_traffic_lights() list[FaultyTrafficLightsDict]¶
Get alerts of traffic lights that are currently faulty, or currently undergoing scheduled maintenance.
- Returns:
Traffic light alerts and their status.
- Return type:
- flood_alerts() list[FloodAlertsDict]¶
Get flood alert information across Singapore, provided by PUB.
- Returns:
Flood alerts.
- Return type:
- road_openings() list[RoadOpeningsDict]¶
Get all planned road openings.
- Returns:
Road openings for road works.
- Return type:
- road_works() list[RoadWorksDict]¶
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:
- traffic_images() list[TrafficImagesDict]¶
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]¶
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]¶
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 | None¶
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.FloodAlertsDict¶
Bases:
TypedDictType definition for flood_alerts()
- alertId: str¶
A number or string uniquely identifying this observation, assigned by the sender.
- Example:
“2.49.0.0.702.2-BCM-17612003774680-PUBCON-DYOONG”
- dateTime: datetime¶
Date and Time the flood observation was issued by PUB.
- Example:
datetime(2025, 5, 22, 9, 55, 0)
- msgType: str¶
Code denoting the nature of the alert message. Possible Code Values:
“Alert” - Initial information requiring attention by targeted recipients
“Cancel” - Cancels the earlier message(s) identified in ‘references’.
- Example:
“Alert”
- event: str¶
Text denoting the type of the subject event of the alert message. Event will always be ‘Flood’.
- Example:
“Flood”
- responseType: str¶
‘Avoid’.
- Example:
“Avoid”
- Type:
Alert response type. Code denoting the type of action recommended for the target audience. Default Code Value
- urgency: str¶
‘Immediate’ - Responsive action SHOULD be taken immediately.
- Example:
“Immediate”
- Type:
Code denoting the severity of the subject event of the alert message. Default Code Value
- severity: str¶
Code denoting the severity of the subject event of the alert message. Possible Code Values:
“Extreme” - Extraordinary threat to life or property
“Severe” - Significant threat to life or property
“Moderate” - Possible threat to life or property
“Minor” – Minimal to no known threat to life or property.
- Example:
“Minor”
- expires: datetime¶
A flood alert automatically expires after 24 hours by default. To remove or update a flood alert before it expires, follow the cancelled alert issued.
- Example:
datetime(2025, 10, 24, 14, 19, 37)
- senderName: str¶
Text naming the originator of the alert message. senderName will always be ‘PUB’.
- Example:
“PUB”
- description: str¶
Location of Flood. Text describing the subject event of the alert message.
- Example:
“Flash flood at Bt Timah Rd from Wilby Rd to Blackmore Dr. Please avoid the area. Issued 1705 hrs.”
- instruction: str¶
Text describing the recommended action to be taken by recipients of the alert message.
- Example:
“Please avoid this area for the next one (1) hour.”
- 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()
- 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()
- 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: float¶
Longitude map coordinates for start point for this stretch of road.
- Example:
103.86246461405193
- StartLat: float¶
Latitude map coordinates for start point for this stretch of road.
- Example:
1.3220591510051254