Sends a request to the PurpleAir API endpoint described at: https://api.purpleair.com/#api-sensors-get-sensor-data

pa_getSensorData(
  api_key = NULL,
  sensor_index = NULL,
  fields = SENSOR_DATA_PM25_FIELDS,
  baseUrl = "https://api.purpleair.com/v1/sensors"
)

Arguments

api_key

PurpleAir API READ key.

sensor_index

The sensor_index as found in the JSON for this specific sensor.

fields

Optional parameter specifying sensor data fields to return.

baseUrl

URL endpoint for the "Get Member Data" API.

Value

List containing all recent data for a single sensor.

Examples

# \donttest{
# Fail gracefully if any resources are not available
try({

library(AirSensor)

  pa_getSensorData(
    api_key = PURPLE_AIR_API_READ_KEY,
    sensor_index = MY_SENSOR_INDEX,
    fields = SENSOR_DATA_PM25_FIELDS
  )

}, silent = FALSE)
#> Error in MazamaCoreUtils::stopIfNull(api_key) : 
#>   object 'PURPLE_AIR_API_READ_KEY' not found
# }