Charges for PurpleAir API calls

Anyone else got a PurpleAir sensor and applied for an API key recently? Things certainly seem to have changed since the API was introduced.

The URL in my Registration e-mail led me - eventually - to the API PurpleAir Develop and, after jumping through a lot of hoops, I got a key and 1,000,000 credits. I also read somewhere that if you made a call every 10 minutes that credit would last for 6.3 years. . . so I immediately changed $purpleRefresh (in PWS_settings.php) from 120 secs to 600.

Imagine my surprise when I found that I was using 12,500 credits a day for 80-90 calls, and my credit was only going to last 80 days. So I changed $purpleRefresh to 1800 (only 5,000 credits a day for about 30 calls - glad I’m not using stationcron) and did a bit of digging.

Apparently you are “charged” for every single item you retrieve, and the cached purpleair.txt has about 100 items, including some that don’t change, like sensor ID, name, lat, long, etc. And the 6.3 years for 10-minute access quoted above is based on retrieving only one (e.g. AQI) item each call!

I don’t think I’ve seen any reference to charges on the Forum before?

Am I doing something wrong?

I had the same issue at first and mistakenly downloaded a bunch of data on the second day I had it installed that cost me around 300,000 points! Never did that again. After some digging around, my work around was to pull the data direct from the sensor in WD, which doesn’t use any credits. I created Highcharts graphics for multiple parameters after creating a CSV file of the data from WD. Displaying the charts costs nothing. However, using Ken’s PurpleAir script (https://novawx.dscloud.me/wxpurpleair.php) costs me 155 point each time the page is viewed. I added the Highcharts graphs to that webpage. I tried to pull the AQI data from my CSV file to display the data in a nice text format, similar to Ken’s on my webpage, but it didn’t look as nice as what Ken’s script creates.

I added my sensor to PWS (https://novawx.dscloud.me/pwsWD/index.php) and that doesn’t appear to use points.

I’ve been using an average of 620 points per day (it’s not the most popular webpage on my site), so if that rate stays the same, my points will run out around March 2026. If I hadn’t mistakenly made that first download, I’d run out of points around August 2027.

Can’t get it wotking in WD, but I can get a nice json direct from the sensor at http://192.168.1.xxx/json. I’m not skilled enough to get that into a text file that WD could upload. . . once it’s there I might be able to parse it (or persuade someone to parse it!).

I haven’t got that script in my Saratoga distribution - and I probably won’t add it!

That’s what is costing me 5,000 points a day for access every half hour :confused:
(That’s because I leave my PWS dashboard open all day.)

WD also pulls json direct from the sensor. Via Setup → Advanced/Misc Settings, in the Purpleair/Davis Air Quality tab.

I entered the Sensor ID, Local IP for the json file and also ticked the boxes to have WD add the AQI to the screen graph (https://novawx.dscloud.me/wxgraphs.php) and create a transparent dial image that I display near the bottom of the Navigation Menu on my main webpage.

Then I create the CSV file with the AQI data via Control Panel and Web Files/Web Page Real Time FTP/WDL option. In the Custom Webpage Setup/Meteotemplate.com tab, on the bottom left, Special File Conversion (for text file only), I create customtext3.txt and customtextout3.csv that contains the PurpleAir AQI parameters in testtags. Then I read the CSV file into a PHP file with Highcharts code to create the graphs.

I’ve set it up same as you (except for graph/dial upload) and it’s not working. . . Test button always shows the same AQI reading.

I’ll figure it out :wink:

Strange. Well, at least you can see it can work with those settings! Not much help otherwise, though.

I see that I can get another 1,000,000 points for $10, so that’s not going to break the bank :wink:

API Pricing - Data / API - PurpleAir Community

At my present rate 1,000,000 points last 200 days. . .

Seems to be working now :slightly_smiling_face:

Now to see what I can do with it. . .

You have to purchase points to get the data from the Purple Air sensor?

You do now. . . if you apply for a PurpleAir API key you get 1,000,000 free points to start you off, then you have to buy more. Basic price 1,000,000 for $10.

You are probably OK if you’ve had your key for a while :slightly_smiling_face:

When I was thinking of adding an air sensor to my station I gave the purple air serious consideration. After reading this thread this I’m glad I went with the Davis.

Their explanation:

"The new point system was created to assist in using our system as we make updates to expand the API further. The API system is something that does cost us to run, and the point pricing is in place to assist us in providing that mass data as well as making the updates mentioned above. The 1,000,000 points provided for each sensor are usually enough for most residential uses of our products, like downloading the data of one to two sensors. When using the API to pull large amounts of data that surpass 1,000,000 points, we need to begin charging.

The charge model is in place to cover the cost of the servers, internet connection, and processing of the requested data. The model in place allows users to add more points to their accounts for a cost equivalent to the resources we use when pulling that data on mass or in repetitive succession.

If you are looking to pull data from multiple sensors at a time, those points will be spent faster. If you are downloading data for a single sensor, those points should last you quite a long time. If this is not the case, we can do our best to work with you to obtain more points.

Below is a chart to reference regarding our pricing.

We truly appreciate your understanding and wish to assist in any way possible with your data collection."

Have to say they did give me a few more free points when I pointed out that I’m used to free API access for, e.g., WU and AerisWeather :slightly_smiling_face:

Are they using your data for something else, or just storing it so you can get it back? If they’re using it to sell to other people there’s usually some quid pro quo involved.

For example, I have a Radarbox ADS-B plane tracker box. I upload the data to the Radarbox servers for them to use in providing a plane tracking service to people who don’t have the box. I get a free Business account for providing data. A Business account costs about $400/year if you don’t provide data.

No idea. . .

I did that with a RPi for FR24 for a while, but geographical situation not ideal and internet connection flaky. So I’m back to paying for the service.

One of my purple air sensors has failed and I’ve been debating whether to buy new sensors or go with Davis. I think I’ll go with Davis.

I know they are sharing it with WU, as my sensor appears on WunderMap Air Quality, and also on aqicn.org. . .

Confirmed. And the same for PWS_Dashboard calls.

Maybe we don’t need every item in the json?

I will check if there is a new API.
The one we are now using in PWS_Dashboard has no selection of items.

https://api.purpleair.com/v1/sensors/7302?api_key=_API_SETTING_

Description:

https://api.purpleair.com/#api-sensors-get-sensor-data

We use only 13 fields from the API.
Current PM10 and PM25
PM25 history 10 minutes, 30 minutes, 60 minutes, 6 hour, 24 hour 1 week
Temperature, humidity, last_seen, time_stamp

Data returned with the currently used API

    [api_version] => V1.0.11-0.0.49
    [time_stamp] => 1693766314
    [data_time_stamp] => 1693766282
    [sensor] => Array
        (
            [sensor_index] => 7302
            [last_modified] => 1601193766
            [date_created] => 1517976119
            [last_seen] => 1693766222
            [private] => 0
            [is_owner] => 0
            [name] => Sluispark Leuven
            [icon] => 0
            [location_type] => 0
            [model] => PA-II-SD
            [hardware] => 2.0+OPENLOG+NO-DISK+DS3231+BME280+PMSX003-B+PMSX003-A
            [led_brightness] => 35
            [firmware_version] => 7.02
            [rssi] => -34
            [uptime] => 28204
            [pa_latency] => 246
            [memory] => 16184
            [position_rating] => 5
            [latitude] => 50.886353
            [longitude] => 4.700279
            [altitude] => 56
            [channel_state] => 3
            [channel_flags] => 0
            [channel_flags_manual] => 0
            [channel_flags_auto] => 0
            [confidence] => 100
            [confidence_auto] => 100
            [confidence_manual] => 100
            [humidity] => 47
            [humidity_a] => 47
            [temperature] => 81
            [temperature_a] => 81
            [pressure] => 1022.75
            [pressure_a] => 1022.75
            [analog_input] => 0.03
            [pm1.0] => 8.7
            [pm1.0_a] => 9.1
            [pm1.0_b] => 8.4
            [pm2.5] => 11.5
            [pm2.5_a] => 12
            [pm2.5_b] => 11.1
            [pm2.5_alt] => 6.7
            [pm2.5_alt_a] => 7
            [pm2.5_alt_b] => 6.5
            [pm10.0] => 12.3
            [pm10.0_a] => 12.7
            [pm10.0_b] => 12
            [scattering_coefficient] => 26.2
            [scattering_coefficient_a] => 27
            [scattering_coefficient_b] => 25.3
            [deciviews] => 14.2
            [deciviews_a] => 14.5
            [deciviews_b] => 13.9
            [visual_range] => 94.3
            [visual_range_a] => 91.9
            [visual_range_b] => 96.7
            [0.3_um_count] => 1744
            [0.3_um_count_a] => 1803
            [0.3_um_count_b] => 1686
            [0.5_um_count] => 482
            [0.5_um_count_a] => 495
            [0.5_um_count_b] => 469
            [1.0_um_count] => 55
            [1.0_um_count_a] => 58
            [1.0_um_count_b] => 52
            [2.5_um_count] => 3
            [2.5_um_count_a] => 4
            [2.5_um_count_b] => 3
            [5.0_um_count] => 0
            [5.0_um_count_a] => 0
            [5.0_um_count_b] => 1
            [10.0_um_count] => 0
            [10.0_um_count_a] => 0
            [10.0_um_count_b] => 0
            [pm1.0_cf_1] => 8.7
            [pm1.0_cf_1_a] => 9.07
            [pm1.0_cf_1_b] => 8.4
            [pm1.0_atm] => 8.7
            [pm1.0_atm_a] => 9.07
            [pm1.0_atm_b] => 8.4
            [pm2.5_atm] => 11.5
            [pm2.5_atm_a] => 11.98
            [pm2.5_atm_b] => 11.07
            [pm2.5_cf_1] => 11.5
            [pm2.5_cf_1_a] => 11.98
            [pm2.5_cf_1_b] => 11.07
            [pm10.0_atm] => 12.3
            [pm10.0_atm_a] => 12.69
            [pm10.0_atm_b] => 11.95
            [pm10.0_cf_1] => 12.3
            [pm10.0_cf_1_a] => 12.69
            [pm10.0_cf_1_b] => 11.95
            [primary_id_a] => 421366
            [primary_key_a] => MJSX2FP5VSVTYZ6D
            [primary_id_b] => 421368
            [primary_key_b] => N0GGM3BU4MAHOSD8
            [secondary_id_a] => 421367
            [secondary_key_a] => NA24TOW2IOOIOWCN
            [secondary_id_b] => 421369
            [secondary_key_b] => A3FP2L1W92BH5PDZ
            [stats] => Array
                (
                    [pm2.5] => 11.5
                    [pm2.5_10minute] => 11.2
                    [pm2.5_30minute] => 10.5
                    [pm2.5_60minute] => 11.1
                    [pm2.5_6hour] => 21.1
                    [pm2.5_24hour] => 13.6
                    [pm2.5_1week] => 4.4
                    [time_stamp] => 1693766222
                )

            [stats_a] => Array
                (
                    [pm2.5] => 12
                    [pm2.5_10minute] => 11.5
                    [pm2.5_30minute] => 10.8
                    [pm2.5_60minute] => 11.4
                    [pm2.5_6hour] => 21.4
                    [pm2.5_24hour] => 13.9
                    [pm2.5_1week] => 4.7
                    [time_stamp] => 1693766222
                )

            [stats_b] => Array
                (
                    [pm2.5] => 11.1
                    [pm2.5_10minute] => 10.9
                    [pm2.5_30minute] => 10.2
                    [pm2.5_60minute] => 10.8
                    [pm2.5_6hour] => 20.8
                    [pm2.5_24hour] => 13.4
                    [pm2.5_1week] => 4.2
                    [time_stamp] => 1693766222
                )

        )

)

Wim

I think you just have to specify each individual field that you need in the “Fields” parameter?

PurpleAir Develop

and

API Use Guidelines - Data / API - PurpleAir Community

Yes, I saw that when I trying to find all new information.

I also have to test if the old API-keys (which we acquired by sensing an email), will continue to work when using the list of fields. Would be a pity to have to start paying if we switch to this new API-“description”.

In the past there was no list of available fields. And certainly no selection of fields.
You got all fields available, and that was far less than what is available now.

The number of fields needed could be less than 20.
Question 1:
What would be the “bill” for on year loading those 20 fields every 120 seconds?
If that is to costly:
Question 2:
What is the acceptable age of the sensor data? 5 minutes or maybe 30 minutes maximum ?

Wim