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:
DataGovSgInteract with the environment-related endpoints.
Reference: https://data.gov.sg/datasets?formats=API&topics=environment
- air_temperature(**kwargs: Unpack[EnvironmentArgsDict]) EnvironmentReadingDict¶
Get air temperature readings across Singapore.
Has per-minute readings from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Air Temperature Information. (Cached for 1 minute.)
- Return type:
- four_day_weather_forecast(**kwargs: Unpack[EnvironmentArgsDict]) WeatherForecastFourDayDict¶
Retrieve the latest 4 day weather forecast.
Updated twice a day from NEA. The forecast is for the next 4 days.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
4 Day Weather Forecast. (Cached for 12 hours.)
- Return type:
- pm25(**kwargs: Unpack[EnvironmentArgsDict]) PM25Dict¶
Retrieve the latest PM2.5 information in Singapore.
Updated hourly from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
PM 2.5 Information. (Cached for 1 hour.)
- Return type:
- psi(**kwargs: Unpack[EnvironmentArgsDict]) PSIDict¶
Retrieve the latest PSI information in Singapore.
Updated hourly from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
PSI Information. (Cached for 1 hour.)
- Return type:
- rainfall(**kwargs: Unpack[EnvironmentArgsDict]) EnvironmentReadingDict¶
Get rainfall readings across Singapore.
5-minute readings from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Rainfall Information. (Cached for 5 minutes.)
- Return type:
- relative_humidity(**kwargs: Unpack[EnvironmentArgsDict]) EnvironmentReadingDict¶
Get relative humidity readings.
Has per-minute readings from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Relative Humidity Information. (Cached for 1 minute.)
- Return type:
- twenty_four_hour_weather_forecast(**kwargs: Unpack[EnvironmentArgsDict]) WeatherForecastTwentyFourHourDict¶
Retrieve the latest 24 hour weather forecast.
Updated multiple times throughout the day.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
24 Hour Weather Forecast. (Cached for 1 hour.)
- Return type:
- two_hour_weather_forecast(**kwargs: Unpack[EnvironmentArgsDict]) WeatherForecastTwoHourDict¶
Retrieve the latest two hour weather forecast.
Updated half-hourly from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
2 Hour Weather Forecast. (Cached for 30 minutes.)
- Return type:
- uv_index(**kwargs: Unpack[EnvironmentArgsDict]) UVIndexDict¶
Retrieve the latest UV index information in Singapore.
Updated every hour between 7 AM and 7 PM everyday. The UV index value is averaged over the preceding hour.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
UV Index Information. (Cached for 1 hour.)
- Return type:
- wind_direction(**kwargs: Unpack[EnvironmentArgsDict]) EnvironmentReadingDict¶
Get wind direction readings across Singapore.
Has per-minute readings from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Wind Direction Information. (Cached for 1 minute.)
- Return type:
- wind_speed(**kwargs: Unpack[EnvironmentArgsDict]) EnvironmentReadingDict¶
Get wind speed readings across Singapore.
Has per-minute readings from NEA.
- Parameters:
kwargs (EnvironmentArgsDict) – Key-value arguments to be passed as parameters to the endpoint URL.
- Returns:
Wind Speed Information. (Cached for 1 minute.)
- Return type: