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: LandTransportSg

Interact 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)

  • cache_backend (str | BaseCache)

carpark_availability() list[CarParkAvailabilityDict]

Get number of available lots from HDB, LTA and URA carpark data.

Returns:

Available carpark lots.

Return type:

list[CarParkAvailabilityDict]

estimated_travel_times() list[EstimatedTravelTimesDict]

Get estimated travel times of expressways (in segments).

Returns:

Expressway estimated travel times by segments.

Return type:

list[EstimatedTravelTimesDict]

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:

list[FaultyTrafficLightsDict]

flood_alerts() list[FloodAlertsDict]

Get flood alert information across Singapore, provided by PUB.

Returns:

Flood alerts.

Return type:

list[FloodAlertsDict]

road_openings() list[RoadOpeningsDict]

Get all planned road openings.

Returns:

Road openings for road works.

Return type:

list[RoadOpeningsDict]

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:

list[RoadWorksDict]

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]

Get links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints.

Returns:

Traffic images at expressways and checkpoints.

Return type:

list[TrafficImagesDict]

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:

list[TrafficIncidentsDict]

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:

list[TrafficSpeedBandsDict]

vms() list[VMSDict]

Get traffic advisories (via variable message services) concerning current traffic conditions that are displayed on EMAS signboards along expressways and arterial roads.

Returns:

Traffic advisories for expressways and arterial roads.

Return type:

list[VMSDict]

Types

class landtransportsg.traffic.CarParkAvailabilityDict

Bases: TypedDict

Type 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”

AvailableLots: int

Number of lots available at point of data retrieval.

Example:

352

LotType: str

Type of lots:

  • “C” - for Cars

  • “H” - for Heavy Vehicles

  • “Y” - for Motorcycles

Example:

“C”

Agency: str

Agencies.

Example:

(LTA) “LTA”

Example:

(URA) “URA”

Example:

(HDB) “HDB”

class landtransportsg.traffic.EstimatedTravelTimesDict

Bases: TypedDict

Type definition for estimated_travel_times()

Name: str

Expressway.

Example:

“AYE”

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

FarEndPoint: str

The final end point of this whole expressway in current direction of travel.

Example:

“TUAS CHECKPOINT”

StartPoint: str

Start point of this current segment.

Example:

“AYE/MCE INTERCHANGE”

EndPoint: str

End point of this current segment.

Example:

“TELOK BLANGAH RD”

EstTime: int

Estimated travel time in minutes.

Example:

2

class landtransportsg.traffic.FaultyTrafficLightsDict

Bases: TypedDict

Type definition for faulty_traffic_lights()

AlarmID: str

Technical alarm ID.

Example:

“GL703034136”

NodeID: str

A unique code to represent each unique traffic light node.

Example:

“703034136”

Type: int

Type of the technical alarm:

  • 4 - blackout.

  • 13 - flashing yellow.

Example:

13

StartDate: datetime | None

Start timestamp of the alarm.

Example:

datetime(2014, 4, 12, 1, 58, 0)

EndDate: datetime | None

End timestamp of the alarm. (Blank string if this is not a scheduled maintenance.)

Example:

blank

Message: str

Canning Message.

Example:

“(23/1)8:58 Flashing Yellow at Bedok North Interchange/Bedok North Street 1 Junc.”

class landtransportsg.traffic.FloodAlertsDict

Bases: TypedDict

Type 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”

headline: str

Text headline of the alert message.

Example:

“Flash Flood Alert”

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.”

areaDesc: str

Area description.

Example:

“Jalan Mastuli, Singapore”

circle: tuple[float, float, float]

Lat/long and radius in kilometers. The radius refers to the broadcasting radius of the specific alert, it is NOT indicative of the extent of the flooding.

Example:

(1.35479, 103.88611, 0.05)

status: str

“Actual” - Actionable by all targeted recipients.

Example:

“Actual”

Type:

Code denoting the appropriate handling of the alert message. Default Code Value

class landtransportsg.traffic.RoadOpeningsDict

Bases: TypedDict

Type definition for road_openings()

EventID: str

ID for this road opening event.

Example:

“RMAPP-201603-0900”

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)

SvcDept: str

Department or company performing this road work.

Example:

“SP POWERGRID LTD - CUSTOMER PROJ (EAST)”

RoadName: str

Name of new road to be opened.

Example:

“AH SOO GARDEN”

Other: str

Additional information or messages.

Example:

“For details, please call 62409237”

class landtransportsg.traffic.RoadWorksDict

Bases: TypedDict

Type definition for road_works()

EventID: str

ID for this road work.

Example:

“RMAPP-201512-0217”

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)

SvcDept: str

Department or company performing this road work.

Example:

“SP POWERGRID LTD - CUSTOMER PROJ (EAST)”

RoadName: str

Name of road where work is being performed.

Example:

“AH SOO GARDEN”

Other: str

Additional information or messages.

Example:

“For details, please call 62409237”

class landtransportsg.traffic.TrafficImagesDict

Bases: TypedDict

Type definition for traffic_images()

CameraID: str

A unique ID for this camera.

Example:

“5795”

Latitude: float

Latitude map coordinates.

Example:

1.326024822

Longitude: float

Longitude map coordinates.

Example:

103.905625

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: TypedDict

Type 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

Longitude: float

Longitude map coordinates for the start point of this road incident.

Example:

103.919182834377

Message: str

Description message for this incident.

Example:

“(29/3)18:22 Vehicle breakdown on ECP (towards Changi Airport) after Still Rd Sth Exit. Avoid lane 3.”

class landtransportsg.traffic.TrafficSpeedBandsDict

Bases: TypedDict

Type definition for traffic_speed_bands()

LinkID: str

Unique ID for this stretch of road.

Example:

“103046935”

RoadName: str

Road Name.

Example:

“SERANGOON ROAD”

RoadCategory: str

Road Category.

Example:

“E”

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

MinimumSpeed: int

Minimum speed in km/h.

Example:

10

MaximumSpeed: int

Maximum speed in km/h.

Example:

19

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

EndLon: float

Longitude map coordinates for end point for this stretch of road.

Example:

103.86315591911669

EndLat: float

Latitude map coordinates for end point for this stretch of road.

Example:

1.3215993547809128

class landtransportsg.traffic.VMSDict

Bases: TypedDict

Type definition for vms()

EquipmentID: str

EMAS equipment ID.

Example:

“amvms_v9104”

Latitude: float

Latitude map coordinates of electronic signboard.

Example:

1.3927176306916775

Longitude: float

Longitude map coordinates of electronic signboard.

Example:

103.82618266340947

Message: str

Variable Message being displayed on the EMAS display.

Example:

“VEH BREAKDOWN SH,AFT U.THOMSON”

landtransportsg.traffic.Url

alias of str