System for fetching, storing and displaying air quality data from PurpleAir
Project description
PurpleAirClient
Getting started
Import the PurpleAirClient class:
from purpleair_client import PurpleAirClient
Create your client with your PurpleAir API Key
purpleAir = PurpleAirClient(API-KEY)
Methods
1. get_sensor(sensor_ID)
Fetch data from a single sensor using the sensor index, fetches sensor index, name, latitude, longitude PM2.5 realtime fields and PM2.5_10 minute average field.
Parameters:
sensor_id: sensor_index for the specific sensor
Returns:
- SensorData object with sensor information
2. get_sensors(bound)
Fetch data from sensors within a bounding box. For each seansor fetches sensor index, fetches sensor index, name, latitude, longitude PM2.5 realtime fields and PM2.5_10 minute average field.
Parameters:
bound: Dictionary containing the northwest and southeast latitudes and longitudes that define the bounding box.
Example:
bound = {
"nwlat":float,
"nwlng":float,
"selat":float,
"selng":float
}
Returns:
- List of SensorData objects within the bounding box.
3. get_sensor_historic(sensor_id, start_timestamp, end_timestamp, average)
Fetch historic data from a sensor using its index.
Parameters:
sensor_id: the sensor indexstart_timestamp: The time stamp of the first required history entry in UNIX time stamp or ISO 8601 stringend_timestamp: The end time stamp of the history to return in UNIX time stamp or ISO 8601 string. (Not inclusive)average: The desired average in minutes. The amount of data that can be returned in a single response depends on the average used in the request. See API documentation here
Returns:
- List of SensorData objects contatinig the sensor's information. Fetches PM2.5 values.
Example:
from purpleair_client import PurpleAirClient
purpleAir = PurpleAirClient(API-KEY)
bounding_box = {
"nwlat":4.674529,
"nwlng":-74.104295,
"selat":4.614464,
"selng":-74.064736
}
start_time = "1717650000"
end_time = "1717657200"
sensor_data = purpleAir.get_sensor_historic("143910", start_time, end_time, 10)
sensors_data = purpleAir.get_sensor("143910")
sensor_historic_data = purpleAir.get_sensors(bounding_box)
print(sensor_data)
print(sensors_data)
print(sensor_historic_data)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file purpleair_client-0.1.1.tar.gz.
File metadata
- Download URL: purpleair_client-0.1.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/5.15.0-139-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfc2d41c8826d8dff0209820b91896f74b83f12ed7b1e4efde6a72196050db65
|
|
| MD5 |
043f0f7d26ed1924e02d1c1979ce30e9
|
|
| BLAKE2b-256 |
3fa42d26e4ae04e977d1a6b7e9b0fb952c8702bbab5e34006a0e19e6faf00c45
|
File details
Details for the file purpleair_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: purpleair_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.8.10 Linux/5.15.0-139-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e383729854e24541c72e33ad0069972bd7ea051f98e96a6fac8b2f5e1ce4067c
|
|
| MD5 |
cc3a22efc6af51448fd06a3fbef0c37f
|
|
| BLAKE2b-256 |
fa7e0183facae0faf54954eb1448e6048e794a0bc18b5b622e91753be3253b4d
|