Author Topic: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.  (Read 6838 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
It appears they shut off the old queries like http://www.purpleair.com/json?show=4299 and now redirect to a server that won't respond to the query.

https://community.purpleair.com/t/discontinuation-of-the-json-and-data-json-urls/713 says
Quote
adrian
13h

After a few years of grace period, we are now redirecting these two URLs (www.purpleair.com/json and www.purpleair.com/data.json ) to a server that will not respond.

Please contact us if you have any questions or need any help getting going on our new API, at https://api.purpleair.com .

Sigh.. I've sent an email to request a READ key, and will rework my scripts to use it instead.  Meanwhile, the realtime query script(s) are very broken.. no data available.

For weather software developers that support realtime queries, they'll have to obtain keys and rewrite that portion of their software.
Grumble.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 1073
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #1 on: May 27, 2022, 02:52:19 PM »
WD already has option to use purple air api luckily

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #2 on: May 27, 2022, 03:10:14 PM »
Where do you request the API key?  I'm not seeing it readily.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #3 on: May 27, 2022, 03:13:37 PM »
Looks like just their regular "Contact us" page is to be used.
https://www2.purpleair.com/pages/contact-us
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 241
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #4 on: May 27, 2022, 03:22:40 PM »
WD already has option to use purple air api luckily
It's does but after entering my API key my graph is still flat lined. I think the graph is linked to the old method and not the new one.

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #5 on: May 27, 2022, 03:53:25 PM »
For the PHP script, I had the two sensorida and sensoridb.  Do I use the a value for Weather Display sensor number?

I got a read key, so I'm part way there I think.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #6 on: May 27, 2022, 08:13:51 PM »
I've reworked the purpleair-inc.php script to use the new API.  Seems to be working on my page now.

They were fairly fast in providing an API key, but stunningly, the process was via email...  The FAQ on their site needs to be changed now that the old method is turned off.

Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 1073
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #7 on: May 28, 2022, 02:54:11 AM »
re WD, it should still be graphing OK
what shows in file

airqualityapi.txt

also though WD can get data via local IP (if your purple air sensor is connected to your LAN)
in the file airquality.txt
is there the data
pm2.5_aqi":
and if so, is that giving the correct aqi value
« Last Edit: May 28, 2022, 03:22:38 AM by waiukuweather »

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #8 on: May 28, 2022, 11:50:01 AM »
In the old script, there was sensorida and sensoridb.  Are these the same for the new script?  Or where do I find it?
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #9 on: May 28, 2022, 11:53:22 AM »
Yes, the sensorids haven't changed with the new API.  Mine was 4299,4300 and remains that for the new API.

The API returns stats, stats_a, stats_b now so you only have to query the primary (a) sensor to get the (b) sensor data too.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #10 on: May 28, 2022, 11:58:18 AM »
Yeah, that's what I did, I'm getting no data.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #11 on: May 28, 2022, 12:01:04 PM »
re WD, it should still be graphing OK
what shows in file

airqualityapi.txt

also though WD can get data via local IP (if your purple air sensor is connected to your LAN)
in the file airquality.txt
is there the data
pm2.5_aqi":
and if so, is that giving the correct aqi value
here is the latest file I had.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #12 on: May 28, 2022, 12:05:09 PM »
 [ You are not allowed to view attachments ]
re WD, it should still be graphing OK
what shows in file

airqualityapi.txt

Here are my settings.  What's odd is when I do a test of the top one, I now get an error.  I never used to.  But after the error, it will show the numbers anyway.
I un-checked the "Use local data for 1.0 and 10.0 PM size data", just to see if the lower api part will work now.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #13 on: May 28, 2022, 12:29:57 PM »
The 302 just indicates a temporary redirect was returned.. the api.purpleair.com should be accessed via https likely.

The local URL shouldn't have changed in response (mine hasn't).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline 92merc

  • BismarckWeather.net
  • Forecaster
  • *****
  • Posts: 1398
  • BismarckWeather.net
    • BismarckWeather.net
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #14 on: May 28, 2022, 12:34:26 PM »
Even if I disable the API section, I still get that error message.  So I don't think it's related to adding the API section I never had.

On the PA Community forum, there were some questions about a firmware 7 version that is being rolled out.  I didn't pay attention to what version I had out of the box.  But I'm now at 7.00 .  I'm beginning to wonder if that could be related to the new errors, if mine did get the update, and not everyone has it yet.
https://www.BismarckWeather.net
Davis VP2, Cumulus, WeatherDisplay, Blitzortung, Saratoga Scripts, NOAA Stream via PI

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 1073
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #15 on: May 28, 2022, 02:45:48 PM »
if you have local IP working for purple air data, I have now added where it will use PM2.5 value from that data instead of trying to get it from the cloud

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 241
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #16 on: May 29, 2022, 03:23:09 PM »
I tried to use the file Ken provided but after entering my station and key I only get a blank page. What am I doing wrong?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #17 on: May 29, 2022, 03:49:01 PM »
The purpleair-inc.php doesn't directly produce visible output .. it has to be used with something like the wxpurpleair.php page attached.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 241
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #18 on: May 29, 2022, 03:59:55 PM »
Thanks Ken, I'm getting data now. Now lets see if I can incorporate the changes into the script I'm using.

Offline zeppline

  • Senior Member
  • **
  • Posts: 89
    • Las Vegas Weather Guy
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #19 on: May 29, 2022, 04:48:39 PM »
Ken I am lost. Do i still need get-purpleair-aqi or is it replaced with purple-inc and wxpurpleair. having a senior moment. I only have one ID and it is only 5 numbers? I have the keys and am waiting for purpleair to get back with two ID,s. Thanks Joe

Offline waiukuweather

  • Forecaster
  • *****
  • Posts: 1073
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #20 on: May 29, 2022, 05:12:18 PM »
i have tested the api in WD , using a Station ID number (you can  get that for your station via the purple air map) and a api key for someones purple air sensor and it does work

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #21 on: May 29, 2022, 05:24:49 PM »
Ken I am lost. Do i still need get-purpleair-aqi or is it replaced with purple-inc and wxpurpleair. having a senior moment. I only have one ID and it is only 5 numbers? I have the keys and am waiting for purpleair to get back with two ID,s. Thanks Joe

You need an API key for api.purpleair.com access to data --only the READ key need be used.  The station number of your station hasn't changed, so you already have that.

If you configure purpleair-inc.php with your station number and the API READ key, then it can pull data from api.purpleair.com.
The wxpurpleair.php page is needed to present the data gathered by purpleair-inc.php (since that script only gets, but not presents the data).

Hope this helps...
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 241
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #22 on: May 29, 2022, 08:20:47 PM »
I tried but I have no idea what I'm doing. Anyone want to look at my file and let me know what I'm doing wrong?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9619
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #23 on: May 29, 2022, 09:01:51 PM »
The issue is likely with
Code: [Select]
$PurpleAirAPI = 'blank';
You need to request API keys from contact@purpleair.com .  Include your real name and sensorid in the request.

They’ll email back with two API keys, one for Read and one for Write.  Copy the Read key to replace the word ‘blank’ and upload the changed file.  You must have a valid API key for queries to api.purpleair.com
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 241
Re: Heads-up: PurpleAir JSON query now requires an API key... grrrrr.
« Reply #24 on: May 29, 2022, 09:12:13 PM »
Hi Ken,

I have an API key but removed it before uploading the file so other don't use it.

 

anything