Back to Smartcitizen.me

No sensor data in sensor data downloads


#1

I’d like to download the sensor data for offline analysis. Unfortunately when I try to download the CSV file from the sensor page I only get the CSV headers but no actual data.

Am I the only one with this issue or is it an general one?


#2

Hi @artsa,

This is a known bug and is on the list to get fixed. You can also get the data from the API directly. Go to:

http://api.smartcitizen.me/v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/41/posts.json

Then substitute your API key for the one above, and substitute “/41/” for “/823/”. Good luck. Thanks,

-Matt
SCK 685


#3

Sorry @artsa, I was looking at your old SCK. You’ll want to substitute “/41/” for “/1621/”

-Matt
SCK 685


#4

Thanks for the reply. I’m not sure if you suggested that I could use the URL already now or after the bug fix but anyway it’s not working now for me.

Do let me know when the issue is fixed.

Thanks,
Ari


#5

rohwer - I have tried to to access the api directly but get a “device:false” message. I have substituted the api as you described and 41 for 1621 but still nothing. any advice??


#6

Hi @marciszewski,

“1621” was the SCK ID for @artsa. You need to sub in your API key, and your device ID. If you don’t know your your SCK ID, just check the URL in your web browser when you click on the map for your SCK. Mine looks like this:

So when I use the API, I sub in my API key then use 685 as my device ID. Shoot me a private message with your API key if that doesn’t work, I’ll take a look at it for you.

-Matt
SCK 685


#7

thanks Matt i got it, here’s the output, except it only shows current stats I guess? How can i get historical download?

{“device”:{“id”:“2002”,“title”:“Birdman’s Sensor”,“description”:"",“location”:“Fairview, United States”,“city”:"",“country”:"",“exposure”:“indoor”,“elevation”:“0.0”,“geo_lat”:“40.812600600000000”,“geo_long”:"-73.999028000000010",“created”:“2015-01-23 03:18:26 UTC”,“last_insert_datetime”:“2015-02-11 21:11:46 UTC”,“posts”:[{“timestamp”:“2015-02-11 21:11:44 UTC”,“temp”:21.1,“hum”:24.9,“co”:156.43,“no2”:143.09,“light”:205.2,“noise”:57,“bat”:100,“panel”:0,“nets”:13,“insert_datetime”:“2015-02-11 21:11:46 UTC”}]}}


#8

Hi @marcizewski,

Well…, old data is a bit trickier. You can use this link to see historical data for every post for the last 3 days (more or less): http://data.smartcitizen.me/testjson?device=2002

(You can see anyone’s data by substituting the “2002” with the device id of the other SCK. For example, mine is http://data.smartcitizen.me/testjson?device=685 )

For older historical data, you’ll need to request it through the API directly. Click the link below for an example of the data for device 41 (daily averages) for May 2013.

http://api.smartcitizen.me/v0.0.1/6e0428e19cf2bff1a9c05d14d0400bf4/41/posts.json?from_date=2013-05-01&to_date=2013-05-31&group_by=day

To get your SCK’s data, take the link above, sub in your API key, and substitute your device id (in your case “41” for “2002”).

You can change the daily average to hourly average by swapping the last work in the link (“day” with “hour”). You change the date range by modifying the “from_date=” and the “to_date=” parts of the link. Note the date format: YYYY-MM-DD. Another thing to keep in mind is that the response you get from the request is limited. I want to say that you’ll never get more than 500 posts (or averages), but I could be wrong about that.

I think the SC team in Barcelona is working on a new API interface as well as database management. I’m guessing that the public will eventually have good/easy way to access historical data for external analysis. I don’t know what that will look like or how long we’ll have to wait for those updates/upgrades to be fully implemented. Keep in mind that the SCK is still a crowd-sourced project and evolution is slow since this isn’t anybody’s full-time job. If you’re a coder, and want to help move things along, reach out to the team to offer your skills.

Keep posting your questions, comments, requests, and recommendations.

-Matt
SCK 685