I did manage to pull data from PurpleAir’s API. But it’s not consistent… about 80% of the time, I just see a white screen. It does seem to work a little better previewed a device than when previewed online.
I have a separate, related question:
Is there a way to specify a JSON field that contains special characters? I need to pull data from an API and the JSON object contains a field called "v1"
I tried using v1, “v1” and \“v1\” but all three ways resulted in “undefined” being returned.
In case it’s helpful to have context, this is the JSON object I’m working with and the “v1” field is part of Stats, shown in bold below:
Interestingly, when I pasted it into my post, it removed the backslashes. But the v1 field below is listed online as \“v1\”
{“mapVersion”:“0.17”,“baseVersion”:“7”,“mapVersionString”:"",“results”:[{“ID”:22077,“Label”:“TMout”,“DEVICE_LOCATIONTYPE”:“outside”,“THINGSPEAK_PRIMARY_ID”:“651834”,“THINGSPEAK_PRIMARY_ID_READ_KEY”:“6BLFLVX33137FDF4”,“THINGSPEAK_SECONDARY_ID”:“651835”,“THINGSPEAK_SECONDARY_ID_READ_KEY”:“JXDJKJ4A8D15UEO8”,“Lat”:38.106622,“Lon”:-122.543881,“PM2_5Value”:“64.3”,“LastSeen”:1598249352,“Type”:“PMS5003+PMS5003+BME280”,“Hidden”:“false”,“DEVICE_BRIGHTNESS”:“15”,“DEVICE_HARDWAREDISCOVERED”:“2.0+BME280+PMSX003-B+PMSX003-A”,“Version”:“6.01”,“LastUpdateCheck”:1598245501,“Created”:1544662588,“Uptime”:“1320”,“RSSI”:"-69",“Adc”:“0.0”,“p_0_3_um”:“10539.75”,“p_0_5_um”:“3098.29”,“p_1_0_um”:“617.59”,“p_2_5_um”:“43.54”,“p_5_0_um”:“4.21”,“p_10_0_um”:“1.29”,“pm1_0_cf_1”:“62.04”,“pm2_5_cf_1”:“97.39”,“pm10_0_cf_1”:“100.36”,“pm1_0_atm”:“40.7”,“pm2_5_atm”:“64.3”,“pm10_0_atm”:“72.75”,“isOwner”:0,“humidity”:“46”,“temp_f”:“80”,“pressure”:“1007.85”,“AGE”:1,“Stats”:"{“v”:64.3,“v1”:50.42,“v2”:47.68,“v3”:48.29,“v4”:54.91,“v5”:35.91,“v6”:11.5,“pm”:64.3,“lastModified”:1598249352327,“timeSinceModified”:119968}"},{“ID”:22078,“ParentID”:22077,“Label”:“TMout B”,“THINGSPEAK_PRIMARY_ID”:“651836”,“THINGSPEAK_PRIMARY_ID_READ_KEY”:“3XVY8E7MJ6C4XIBQ”,“THINGSPEAK_SECONDARY_ID”:“651837”,“THINGSPEAK_SECONDARY_ID_READ_KEY”:“E39DOXFOXR1QZ8A9”,“Lat”:38.106622,“Lon”:-122.543881,“PM2_5Value”:“62.93”,“LastSeen”:1598249352,“Hidden”:“false”,“Created”:1544662588,“Adc”:“0.01”,“p_0_3_um”:“10277.89”,“p_0_5_um”:“3120.74”,“p_1_0_um”:“573.98”,“p_2_5_um”:“32.0”,“p_5_0_um”:“4.15”,“p_10_0_um”:“3.09”,“pm1_0_cf_1”:“62.07”,“pm2_5_cf_1”:“95.59”,“pm10_0_cf_1”:“98.98”,“pm1_0_atm”:“40.57”,“pm2_5_atm”:“62.93”,“pm10_0_atm”:“72.11”,“isOwner”:0,“AGE”:1,“Stats”:"{“v”:62.93,“v1”:50.63,“v2”:47.8,“v3”:48.39,“v4”:55.23,“v5”:36.23,“v6”:11.87,“pm”:62.93,“lastModified”:1598249352328,“timeSinceModified”:119968}"}]}