Type: | Package |
Title: | Historical Data Retrieval from 'PurpleAir' Sensors via API |
Version: | 0.1.0 |
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/. |
License: | MIT + file LICENSE |
URL: | https://github.com/heba-razzak/PurpleAirAPI |
Imports: | httr, jsonlite |
Suggests: | knitr, rmarkdown, testthat (≥ 3.0.0) |
VignetteBuilder: | knitr |
Config/testthat/edition: | 3 |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.1 |
NeedsCompilation: | no |
Packaged: | 2024-11-25 05:10:58 UTC; heba |
Author: | Heba Abdelrazzak [aut, cre] |
Maintainer: | Heba Abdelrazzak <hebaarazzak@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-11-26 12:40:05 UTC |
getPurpleairSensors
Description
Retrieves data from PurpleAir sensors based on specified fields.
Usage
getPurpleairSensors(
apiReadKey = NULL,
fields = c("latitude", "longitude", "date_created", "last_seen")
)
Arguments
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") |
Details
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 |
Value
A data frame containing the required fields for all PurpleAir sensors
References
For more details on the available fields, see the PurpleAir API documentation: https://api.purpleair.com/#api-sensors-get-sensors-data
Examples
## 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)
getSensorHistory
Description
Download historical data for PurpleAir sensors using API.
Usage
getSensorHistory(
sensorIndex = NULL,
apiReadKey = NULL,
startDate = NULL,
endDate = NULL,
average = NULL,
fields = NULL
)
Arguments
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. |
Details
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 |
Value
Dataframe of PurpleAir history data of one or multiple sensors.
References
For more details on the available fields, see the PurpleAir API documentation: https://api.purpleair.com/#api-sensors-get-sensor-history-csv
Examples
## 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)