Title: | Call Real Time APIs from Data Gov Singapore |
---|---|
Description: | A wrapper for the Data.gov.sg developer resources, which provide real time and historical information, ranging from carpark availability to weather forecasts. The functions makes the API calls for a given date and time, before returning the relevant information in a data frame. All APIs are supported, less the IPOS one which is not returning any data. Relevant information can be found here <https://data.gov.sg/developer>. |
Authors: | Clinton Wong <[email protected]> |
Maintainer: | Clinton Wong <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.1 |
Built: | 2024-09-26 06:20:00 UTC |
Source: | CRAN |
This functions calls upon the carpark availability API from data.gov.sg and processes the returning page.
carpark_availability(date_time = "")
carpark_availability(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
A dataframe containing the carpark id, type, last update, total lots, and current lots.
carpark_availability() carpark_availability(date = "2019-06-05T10:10:10") carpark_availability(date = "2018-12-01T19:32:56")
carpark_availability() carpark_availability(date = "2019-06-05T10:10:10") carpark_availability(date = "2018-12-01T19:32:56")
Helper function to check if the date was input correctly before returning a url to be called by the GET function. Also returns an error if the API called can only provide data for a specific date-time, and not date only.
parse_api_date(api, input_date = "", summary)
parse_api_date(api, input_date = "", summary)
api |
The api to be called, i.e. api = "environment/air-temperature" |
input_date |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS or YYYY-MM-DD |
summary |
Returns an error if the user inputs a date only time when not supported by the API. |
A url to be called by the API.
Helper function to extract the content returned from the API. Returns the status code otherwise.
parse_api_output(inputcontent)
parse_api_output(inputcontent)
inputcontent |
Takes the output of the GET function, runs an error check and returns the parsed output. |
The extracted content if not error has occured. Otherwise, the error message is returned.
This functions calls upon the PM2.5 API from data.gov.sg and returns a data frame of the different measures of PM2.5 across 5 different areas in Singapore. This data provided by the API is updated hourly from NEA.
pm25(date_time = "")
pm25(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
Note that this function is different from the 'pm25_summary' function, which returns the PM2.5 measures for a given day.
A dataframe containing various PM2.5 measures across 5 corners of Singapore
pm25() pm25(date_time = "2019-11-08T17:30:00") pm25(date_time = "2018-01-04T09:16:17")
pm25() pm25(date_time = "2019-11-08T17:30:00") pm25(date_time = "2018-01-04T09:16:17")
This functions calls upon the PM2.5 API from data.gov.sg and returns a data frame of the different measures of the PM2.5 across 5 different areas in Singapore for each hour. This data provided by the API is updated hourly from NEA.
pm25_summary(date = "")
pm25_summary(date = "")
date |
Defaults to current (SGD) time. Format: YYYY-MM-DD |
Note that this function is different from the 'pm25' function, which returns the PM2.5 measures for a given date and time.
A dataframe containing various PM2.5 measures across 5 corners of Singapore and time of day. Dependent on the data availible, not all results range from 0000 to 2300.
pm25_summary() pm25_summary(date = "2019-11-08") pm25_summary(date = "2018-01-04")
pm25_summary() pm25_summary(date = "2019-11-08") pm25_summary(date = "2018-01-04")
This functions calls upon the PSI API from data.gov.sg and returns a data frame of the different measures of the PSI across 5 different areas in Singapores and the overall measure for the given data-time. This data provided by the API is updated hourly.
psi(date_time = "")
psi(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
Note that this function is different from the 'PSI_summary' function, which returns the PSI measures for a given day.
A dataframe containing various PSI measures across 5 corners of Singapore
psi() psi(date = "2019-11-08T17:30:00") psi(date = "2018-01-04T09:16:17")
psi() psi(date = "2019-11-08T17:30:00") psi(date = "2018-01-04T09:16:17")
This functions calls upon the PSI API from data.gov.sg and returns a data frame of the different measures of the PSI across 5 different areas in Singapores and the overall measure for the given date. This data provided by the API is updated hourly.
psi_summary(date = "")
psi_summary(date = "")
date |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
Note that this function is different from the 'PSI' function, which returns the PSI measures for a given date-time.
A dataframe containing various PSI measures across 5 corners of Singapore and time of day. Dependent on the data availible, not all results range from 0000 to 2300.
psi_summary() psi_summary(date = "2019-11-08") psi_summary(date = "2018-01-04")
psi_summary() psi_summary(date = "2019-11-08") psi_summary(date = "2018-01-04")
This functions calls upon the taxi availability API from data.gov.sg and returns a data frame of the locations of all availible taxis.
taxi_availability(date_time = "")
taxi_availability(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
A dataframe containing the longitude and latitude values of availible taxis.
taxi_availability() taxi_availability(date = "2019-08-07T09:30:00") taxi_availability(date = "2018-06-05T13:45:00")
taxi_availability() taxi_availability(date = "2019-08-07T09:30:00") taxi_availability(date = "2018-06-05T13:45:00")
This functions calls upon the Traffic Images API from data.gov.sg and returns links to images of live traffic conditions along expressways and Woodlands & Tuas Checkpoints, including details of the camera location. This data provided by the API is updated every minute.
traffic_images(date_time = "")
traffic_images(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
A dataframe containing links to the traffic images of current traffic conditions
traffic_images() traffic_images(date = "2022-07-01T15:32:45") traffic_images(date = "2021-02-11T14:11:07")
traffic_images() traffic_images(date = "2022-07-01T15:32:45") traffic_images(date = "2021-02-11T14:11:07")
This functions calls upon the UVI API from data.gov.sg and returns a data frame of the different measures of the UVI across Singapore and returns the closest UVI value presently and for the past few hours. This data provided by the API is updated hourly.
uvi(date_time = "")
uvi(date_time = "")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
A dataframe containing the current and past hourly UVI
uvi() uvi(date = "2022-09-03T16:45:23") uvi(date = "2021-12-06T11:01:55")
uvi() uvi(date = "2022-09-03T16:45:23") uvi(date = "2021-12-06T11:01:55")
This functions calls upon the weather forecast API from data.gov.sg and returns a data frame containing different metrics of the forecast. 2-hour, 24-hour and 4-day forecasts are availible. This data provided by the API is updated half-hourly.
weather_forecast(date_time = "", forecast = "2-hour")
weather_forecast(date_time = "", forecast = "2-hour")
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
forecast |
Defaults to "2-hour". Also availible for "24-hour" and "4-day" |
A dataframe the forecast for a given date and time, and forecast period.
weather_forecast() weather_forecast(date = "2019-11-08T17:30:00", forecast = "24-hour") weather_forecast(date = "2018-01-04T09:16:17", forecast = "4-day")
weather_forecast() weather_forecast(date = "2019-11-08T17:30:00", forecast = "24-hour") weather_forecast(date = "2018-01-04T09:16:17", forecast = "4-day")
This functions calls upon the weather reading API from data.gov.sg and returns a list containing the air temperature, rainfall, relative humidity, wind direction and speed across Singapore. Data is updated every 5 minutes for the rainfall API, and every half minute for the other 4 API from NEA.
weather_reading(date_time = "", simplify = FALSE)
weather_reading(date_time = "", simplify = FALSE)
date_time |
Defaults to current (SGD) time. Format: YYYY-MM-DDTHH:MM:SS |
simplify |
Defaults to FALSE. Otherwise, simplify = TRUE would return a data frame where all 5 metrics are joined according to weather stations, but return several NAs, as most weather stations collect rainfall data only. |
This API takes slighlty longer than the other APIs in the package as 5 APIs are wrapped within this function.
A dataframe containing various weather readings from weather stations
weather_reading() weather_reading(date = "2019-11-08T17:30:00") weather_reading(date = "2018-01-04T09:16:17", simplify = TRUE)
weather_reading() weather_reading(date = "2019-11-08T17:30:00") weather_reading(date = "2018-01-04T09:16:17", simplify = TRUE)