Hello All,
Just thought I would share with you a side project I’ve been working on. This is the link to the repository: https://github.com/carlkid1499/purple_air_data_logger#readme
In a nutshell, the “PurpleAirAPI.py” sends get requests using the python request library. Not all supported requests have been implemented. At the moment only fetching data from one sensor is supported. In the works is the ability to fetch data from multiple sensors, along with the historical parts of the new PAA.
Alongside the “PurpleAirAPI.py” there is a “PurpleAirDataLogger.py”. This file currently supports the ability to insert data from a single sensor into a TimeScaleDB PostgreSQL database.
Lastly, the “PurpleAirDataLoggerPSQLStatements.py” file just contains all the PSQL query statements that are used in “PurpleAirDataLogger.py”.
References:
What is TimeScaleDB
Hi @carlkidcrypto-paa, nice work. I just looked into the repo. These codes will now be able to extract data from multiple sensors right?
For all others, here’s an updated post with newer stuff: Python Purple Air Data Logger(s)
Great work @carlkidcrypto-paa . It looks like, for csv download - you can’t get historical data. Do I need to replace “request_multiple_sensors_data” with “request_sensor_historic_data” in the PurpleAirDataLogger? I need to download outdoor PA data (temp, pm2.5, pm10) within Cali for 2018. For sample I chose the following geographical domain which should have a bunch of sensors. My .json file is something like this:
{
“fields”: “humidity, temperature, pm2.5, pm10.0”,
“location_type”: null,
“modified_since”: null,
“read_keys”: null,
“show_only”: null,
“max_age”: null,
“nwlng” : -121.50410498648533,
“nwlat”: 38.599954503592734,
“selng”: -121.47678330123237,
“selat”: 38.57528258909881
}
I am using the the command line as shown below:
python purpleair_data_logger/PurpleAirCSVDataLogger.py -save_file_path pa_data/ -paa_read_key xx -paa_multiple_sensor_request_json_file …/multi_sensors_sample.json
Using the above command, I am able to make a successful connection. But not able to achieve what I wanted. My questions are: is the format for parameters used in the .json file correct (especially the lat-lon boundaries)? How to use this repo to download historical data of PA sensors within a geographical boundary? Any help is appreciated. Thank you!
@Praful_Dodda There is a current issue opened for this: add historic multiple sensor data to PAA · Issue #17 · carlkid1499/purpleair_data_logger · GitHub
The API for historical access is not available at the moment ( Downloaded data not appearing in CSV file - #5 by Ethan_Breinholt). I think you’ll need special access to download historical data. Especially if it is for a big time range. I would suggest reaching out to purple air support for help.
contact@purpleair.com
…
For the python side of things let me look deeper into the code for some of your questions.
Thanks!
1 Like
Hey @carlkidcrypto-paa! I appreciate your timely replies. I got the permission for using historical API. Now, I am trying to use your python codes to extract the data. Wish me luck
Thanks,
Praful
Hello @Praful_Dodda hopefully it’s been working for you. In looking deeper at the code and writing some behave tests. I found a bug that might be affecting your ability to request historical data. If it hasn’t been working for you feel free to try out this branch: GitHub - carlkid1499/purpleair_data_logger at 25-create-behave-code-tests
Thanks
Hi Carlos,
I got the data for a few months in 2019. For now, I am just using that for my project. But I will be using the whole year’s data in the near future. Thanks for your help. I will definitely check this branch out
Thanks,
Praful