Download data from particle dashboard to python using urlopen

Hi, I a am trying to download my data from the particle dashboard using python. I would like to download a json file of my data in real time as it is published to the Particle Dashboard. Please help. Currently, I am downloading it from my ThingSpeak account.

here is my code:

import json
import urllib
from urllib.request import urlopen

url = urlopen(‘https://api.particle.io/v1/devices/0123456789abcdef01234567/brew
-d access_token=18d1c5d165477448269f57d7cb5e4906280e9be4’)

response = url.read()
data=json.loads(response)
print( data)

CODE FOR THE THINGSPEAK ACCOUNT:
conn = urlopen(“http://api.thingspeak.com/channels/%s/feeds.json?api_key=%s
% (CHANNEL_ID,READ_API_KEY))
response = conn.read().decode()
#print( “http status code=%s” % (conn.getcode()))
data=json.loads(response)

(This works but the real time feature is very slow)

I’m not a Python guy, but I guess there you could also subscribe to the SSE stream.

If you’re using Chrome try this link to see the eventstream

view-source:https://api.particle.io/v1/devices/events/?access_token=<yourAccessToken>

And for a particular device add the device ID as you did in your function call above.

Hi, tried that and it just keeps loading. doesnt give me any data

That’s some quirk I sometimes see with Chrome too, but when I click in the browser window and the address bare (sometimes back and forth a few times, it starts updating).

thank, i will try that later today

Just tried it again and obviously Chrome has changed this a bit and now the link would work without the keyword view-source:
https://api.particle.io/v1/devices/events/?access_token=<yourAccessToken>