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
Parameters:
sensor_id: sensor_index for the specific sensorfields: list of fields to include in the response, defaults to fetch index, name, latitude, longitude and PM2.5 fields.
Returns:
- SensorData object with sensor information
2. get_sensors(bound)
Fetch data from sensors within a bounding box
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
}
fields: list of fields to include in the response, defaults to fetch index, name, latitude, longitude and PM2.5 fields.
Returns:
- List of SensorData objects within the bounding box.
3. get_sensor_historic(sensor_id, start_timestamp, end_timestamp, average, fields)
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 herefields: list of fields to include in the response, defaults to fetch index and PM2.5 fields.
Returns:
- List of SensorData objects contatinig the sensor's information.
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.0.tar.gz.
File metadata
- Download URL: purpleair_client-0.1.0.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 |
3a014606549346f71ddda76c2e037f5fcca73feaa7cfa1e6e4f37cc611de0f7d
|
|
| MD5 |
6f406d2c72b234d8c3dfd33e7599a64f
|
|
| BLAKE2b-256 |
eb5c15ca254d30b7ffe7c4bd354582ca93ce5d91c653418edbe4e1d854072293
|
File details
Details for the file purpleair_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: purpleair_client-0.1.0-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 |
a0199a72186a2083306ac6c8054ca3b37b2476ae4707b817d8a7f629ba948639
|
|
| MD5 |
d6b035d974fc41afe78a34bc8d5b6a01
|
|
| BLAKE2b-256 |
34da2473d0d7d64c40c4b3a77de0d3dbf1811d1d98a29fa3068bef267e34dcd4
|