Title: | Historical Data Retrieval from 'PurpleAir' Sensors via API |
---|---|
Description: | Provides tools for retrieving and analyzing air quality data from 'PurpleAir' sensors through their API. Functions enable downloading historical measurements, accessing sensor metadata, and managing API request limitations through chunked data retrieval. For more information about the 'PurpleAir' API, see <https://api.purpleair.com/>. |
Authors: | Heba Abdelrazzak [aut, cre] |
Maintainer: | Heba Abdelrazzak <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-26 13:55:43 UTC |
Source: | CRAN |
Retrieves data from PurpleAir sensors based on specified fields.
getPurpleairSensors( apiReadKey = NULL, fields = c("latitude", "longitude", "date_created", "last_seen") )
getPurpleairSensors( apiReadKey = NULL, fields = c("latitude", "longitude", "date_created", "last_seen") )
apiReadKey |
API key for accessing the PurpleAir API. |
fields |
Vector specifying the fields to retrieve from PurpleAir API. Default: c("latitude", "longitude", "date_created", "last_seen") |
Available fields:
Station Information and Status |
name, icon, model, hardware, location_type, private, latitude, longitude, altitude, position_rating, led_brightness, firmware_version, firmware_upgrade, rssi, uptime, pa_latency, memory, last_seen, last_modified, date_created, channel_state, channel_flags, channel_flags_manual, channel_flags_auto, confidence, confidence_manual, confidence_auto |
Environmental |
humidity, humidity_a, humidity_b, temperature, temperature_a, temperature_b, pressure, pressure_a, pressure_b |
Miscellaneous |
voc, voc_a, voc_b, ozone1, analog_input |
PM1.0 |
pm1.0, pm1.0_a, pm1.0_b, pm1.0_atm, pm1.0_atm_a, pm1.0_atm_b, pm1.0_cf_1, pm1.0_cf_1_a, pm1.0_cf_1_b |
PM2.5 |
pm2.5_alt, pm2.5_alt_a, pm2.5_alt_b, pm2.5, pm2.5_a, pm2.5_b, pm2.5_atm, pm2.5_atm_a, pm2.5_atm_b, pm2.5_cf_1, pm2.5_cf_1_a, pm2.5_cf_1_b |
Visibility |
scattering_coefficient, scattering_coefficient_a, scattering_coefficient_b, deciviews, deciviews_a, deciviews_b, visual_range, visual_range_a, visual_range_b |
Particle Count |
0.3_um_count, 0.3_um_count_a, 0.3_um_count_b, 0.5_um_count, 0.5_um_count_a, 0.5_um_count_b, 1.0_um_count, 1.0_um_count_a, 1.0_um_count_b, 2.5_um_count, 2.5_um_count_a, 2.5_um_count_b, 5.0_um_count, 5.0_um_count_a, 5.0_um_count_b, 10.0_um_count, 10.0_um_count_a, 10.0_um_count_b |
ThingSpeak |
primary_id_a, primary_key_a, secondary_id_a, secondary_key_a, primary_id_b, primary_key_b, secondary_id_b, secondary_key_b |
A data frame containing the required fields for all PurpleAir sensors
For more details on the available fields, see the PurpleAir API documentation: https://api.purpleair.com/#api-sensors-get-sensors-data
## Not run: # Get sensor data with default fields sensors <- getPurpleairSensors(apiReadKey = "YOUR_API_KEY") # Get sensor data with custom fields sensors <- getPurpleairSensors( apiReadKey = "YOUR_API_KEY", fields = c("latitude", "longitude", "date_created", "last_seen", "location_type") ) ## End(Not run)
## Not run: # Get sensor data with default fields sensors <- getPurpleairSensors(apiReadKey = "YOUR_API_KEY") # Get sensor data with custom fields sensors <- getPurpleairSensors( apiReadKey = "YOUR_API_KEY", fields = c("latitude", "longitude", "date_created", "last_seen", "location_type") ) ## End(Not run)
Download historical data for PurpleAir sensors using API.
getSensorHistory( sensorIndex = NULL, apiReadKey = NULL, startDate = NULL, endDate = NULL, average = NULL, fields = NULL )
getSensorHistory( sensorIndex = NULL, apiReadKey = NULL, startDate = NULL, endDate = NULL, average = NULL, fields = NULL )
sensorIndex |
PurpleAir sensor's index. |
apiReadKey |
PurpleAir API read key. |
startDate |
Date of the first required history entry. |
endDate |
Date of the history to return. Uses end of date specified. |
average |
The desired average in minutes: 0, 10, 30, 60, 360, 1440, 10080, 43200, 525600 |
fields |
The 'sensor data fields' to include in the response. |
Available fields:
Station Information and Status |
hardware*, latitude*, longitude*, altitude*, firmware_version*, private, rssi, uptime, pa_latency, memory |
Environmental |
humidity, humidity_a, humidity_b, temperature, temperature_a, temperature_b, pressure, pressure_a, pressure_b |
Miscellaneous |
voc, voc_a, voc_b, analog_input |
PM1.0 |
pm1.0_atm, pm1.0_atm_a, pm1.0_atm_b, pm1.0_cf_1, pm1.0_cf_1_a, pm1.0_cf_1_b |
PM2.5 |
pm2.5_alt, pm2.5_alt_a, pm2.5_alt_b, pm2.5_atm, pm2.5_atm_a, pm2.5_atm_b, pm2.5_cf_1, pm2.5_cf_1_a, pm2.5_cf_1_b |
PM10.0 |
pm10.0_atm, pm10.0_atm_a, pm10.0_atm_b, pm10.0_cf_1, pm10.0_cf_1_a, pm10.0_cf_1_b |
Visibility |
scattering_coefficient, scattering_coefficient_a, scattering_coefficient_b, deciviews, deciviews_a, deciviews_b, visual_range, visual_range_a, visual_range_b |
Particle Count |
0.3_um_count, 0.3_um_count_a, 0.3_um_count_b, 0.5_um_count, 0.5_um_count_a, 0.5_um_count_b, 1.0_um_count, 1.0_um_count_a, 1.0_um_count_b, 2.5_um_count, 2.5_um_count_a, 2.5_um_count_b, 5.0_um_count, 5.0_um_count_a, 5.0_um_count_b, 10.0_um_count, 10.0_um_count_a, 10.0_um_count_b |
Dataframe of PurpleAir history data of one or multiple sensors.
For more details on the available fields, see the PurpleAir API documentation: https://api.purpleair.com/#api-sensors-get-sensor-history-csv
## Not run: # Download hourly PM2.5 data for one month history <- getSensorHistory( sensorIndex = c(6127, 9014, 3124), apiReadKey = "YOUR_API_KEY", startDate = "2024-01-01", endDate = "2024-01-31", average = 60, fields = c("pm2.5_alt", "temperature", "humidity") ) ## End(Not run)
## Not run: # Download hourly PM2.5 data for one month history <- getSensorHistory( sensorIndex = c(6127, 9014, 3124), apiReadKey = "YOUR_API_KEY", startDate = "2024-01-01", endDate = "2024-01-31", average = 60, fields = c("pm2.5_alt", "temperature", "humidity") ) ## End(Not run)