HTTP Request for Older Values



I’ve setup a generic device. Now i’m trying to get and post values from a Android Application.
I’ve already managed to read a value from a datastream using the HTTP request from

But only the most recent value.
Is there a similar request to read the older values from a datastream?


You can actually use the If-Modified-Since header that is part of the Long-Polling options to specify a point in history to to read from. See the docs for that here:

Here’s a little python example that shows how you would read the very first datapoint from a dataport with the alias ‘temp’:


import socket

header = """GET /api:v1/stack/alias?temp HTTP/1.1
X-Exosite-CIK: c67ef69c82981b472b739e4a7b1f121621e5576a
Accept: application/x-www-form-urlencoded; charset=utf-8
If-Modified-Since: 0


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("", 80))
print s.send(header)

print header

data = s.recv(1024)


All that being said, I would actually suggest that you use the JSON RPC API since you have to power to easily parse JSON. This is our main application API that will let you have full control over a device, including reading entire ranges of values with a single call. See the docs for that here:


Here is example code that shows a number of ways to make read requests using the JSON RPC for things like reading from a specific time in history, reading multiple data points, etc:


Thank you very much for your responses. I’m trying it out right now.
At the beginning I only wanted to write and read one specifique value and thought JSON would be kind of cracking a nut with a sledgehammer.
But I changed my opinion on that and my concept as well and now I’m using JSON. I’m especially happy with the record method because I prefer to apply my own timestamps.


Glad to hear this was helpful for you. Yes, using the JSON RPC is useful as long as creating / parsing the JSON formatted requests/responses is easy for you.


Dear MikeA,

This code has really useful for me. However, I just want to output the alias data.
When I print str(data), it gives me other stuff which I don’t need like HTTP/1.1 200 OK.
Is there a way to go about this? Many thanks in advance.




The value of data is a string you just need to parse for the body of the server’s response. Have you considered using the carriage return and blank line for this purpose?. Once you have that done it should be just as easy to decode the server’s JSON formatted response as a dictionary using the JSON module you already having imported.

If you are not in a constrained environment consider using a library that does a lot more of the request formatting and parsing for you. Sockets is a lot harder to use than Requests.