get_sensor_history {PurpleAir}R Documentation

get sensor history

Description

Retrieves the latest history of a single sensor matching the provided sensor_index. Find more details on sensor fields at https://api.purpleair.com/#api-sensors-get-sensor-history.

Usage

get_sensor_history(
  sensor_index,
  fields,
  start_timestamp,
  end_timestamp,
  average = c("10min", "30min", "60min", "6hr", "1day", "1week", "1month", "1year",
    "real-time"),
  purple_air_api_key = Sys.getenv("PURPLE_AIR_API_KEY"),
  read_key = NULL
)

Arguments

sensor_index

Integer (or numeric, character object coerceable to integer) sensor_index

fields

A character vector of which 'sensor data fields' to return

start_timestamp

time stamp of first required history entry (inclusive)

end_timestamp

end time stamp of history to return (exclusive)

average

time frame to request averaged results for

purple_air_api_key

A character that is your PurpleAir API READ key

read_key

A character key required to read data from private devices

Value

a list of sensor data, named by the provided fields

Examples

## Not run: 
get_sensor_history(
  sensor_index = 175413,
  fields = c("pm1.0_cf_1", "pm1.0_atm", "pm2.5_cf_1", "pm2.5_atm"),
  start_timestamp = as.POSIXct("2024-07-02"),
  end_timestamp = as.POSIXct("2024-07-05")
)

## End(Not run)

[Package PurpleAir version 1.0.0 Index]