datagovsg.environment

Client for interacting with the Environment APIs.

Example usage:

# get the 24-hour weather forecast
from datagovsg import Environment
environment = Environment()
forecast = environment.twenty_four_hour_weather_forecast()

Methods

class datagovsg.environment.client.Client

Bases: datagovsg.client.__Client

Interact with the environment-related endpoints.

air_temperature(date_time=None, dt=None)

Get air temperature readings across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of air temperature by station.

References

https://data.gov.sg/dataset/realtime-weather-readings?resource_id=17494bed-23e9-4b3b-ae89-232f87987163

four_day_weather_forecast(date_time=None, dt=None)

Retrieve the latest 4 day weather forecast.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Weather forecast for the next 4 days by area.

References

https://data.gov.sg/dataset/weather-forecast?resource_id=4df6d890-f23e-47f0-add1-fd6d580447d1

pm25(date_time=None, dt=None)

Retrieve the latest PM2.5 information in Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of PM2.5 by region.

References

https://data.gov.sg/dataset/pm2-5

psi(date_time=None, dt=None)

Retrieve the latest PSI information in Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of PSI by region.

References

https://data.gov.sg/dataset/psi

rainfall(date_time=None, dt=None)

Get rainfall readings across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of rainfall by station.

References

https://data.gov.sg/dataset/realtime-weather-readings?resource_id=8bd37e06-cdd7-4ca4-9ad8-5754eb70a33d

relative_humidity(date_time=None, dt=None)

Get relative humidity readings across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of relative humidity by station.

References

https://data.gov.sg/dataset/realtime-weather-readings?resource_id=59eb2883-2ceb-4d16-85f0-7e3a3176ef46

twenty_four_hour_weather_forecast(date_time=None, dt=None)

Retrieve the latest 24 hour weather forecast across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Weather forecast for the next 24 hours by area.

References

https://data.gov.sg/dataset/weather-forecast?resource_id=9a8bd97e-0e38-46b7-bc39-9a2cb4a53a62

two_hour_weather_forecast(date_time=None, dt=None)

Retrieve the latest two hour weather forecast across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Weather forecast for the next 2 hours by area.

References

https://data.gov.sg/dataset/weather-forecast?resource_id=571ef5fb-ed31-48b2-85c9-61677de42ca9

uv_index(date_time=None)

Retrieve the latest UV index information in Singapore.

Parameters

date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone.

Returns

(dict) Readings of UV Index by station.

References

https://data.gov.sg/dataset/ultraviolet-index-uvi

wind_direction(date_time=None, dt=None)

Get wind direction readings across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of wind direction by station.

References

https://data.gov.sg/dataset/realtime-weather-readings?resource_id=5dcf8aa5-cf6a-44e4-b359-1173eecfdf4c

wind_speed(date_time=None, dt=None)

Get wind speed readings across Singapore.

Parameters
  • date_time (datetime) – (optional) Specific date-time to retrieve the readings. Will be standardised to SGT timezone. If both dt and date_time are specified, then date_time is used.

  • dt (date) – (optional) Specific date to retrieve the readings. If both dt and date_time are specified, then dt is NOT used.

Returns

(dict) Readings of wind speed by station.

References

https://data.gov.sg/dataset/realtime-weather-readings?resource_id=16035f22-37b4-4a5c-b024-ca2381f11b48