pa_getSensorData: Retrieve the latest data of a single sensor.

View source: R/pa_API.R

pa_getSensorDataR Documentation

Retrieve the latest data of a single sensor.

Description

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

Usage

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


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


MazamaScience/AirSensor documentation built on April 28, 2023, 11:16 a.m.