Back to Smartcitizen.me

Historical data not available from API

I borrowed some devices from work last year and collected data at home over the winter, connecting via wifi and accessing data via the API which worked well. Had to return those devices and believe they have been reused by someone else.

Have borrowed some different devices to collect data this winter, again connecting via wifi. Tried to pull data for both groups of devices from the API. It returns data for this year’s devices but nothing for the devices I’d been using previously. Can’t work out why. Does data get deleted if a device isn’t used for a period? Does it get deleted if a device is used by a different user? Is there any way to get my old data back?

Any advice much appreciated.

Example of device ID from last year: 16873 [API not returning data]
Example of device ID from this year: 18329 [API returning data]

Update: I went in to my profile via the platform, where all the devices linked to my profile are listed (from last year and this). It seems I can download the data for last year’s devices as a csv which will solve my problem. But does leave me puzzled why I can’t get this via the API so still interested to understand that :slightly_smiling_face:

Hey Nick!

Aha, sorry you’re having trouble - can I ask you - what API endpoints are you querying, and with what parameters? I can see data for your old device at https://smartcitizen.me/kits/16873, and if I query the API readings endpoint I get data back - see for example for the light sensor: https://api.smartcitizen.me/v0/devices/16873/readings?from=2023-12-09T23:00:00.000Z&rollup=10m&sensor_id=14&to=2024-04-24T21:59:59.999Z

Let me know how you’re trying to get to it, and I’m sure we can straighten this out!

Thanks!

Tim

Hi Tim

This was my query for one of last year’s devices which didn’t return any data: https://api.smartcitizen.me/v0/devices/16873/readings?sensor_id=14&rollup=1h. So same as you but without from/to.

The same query for one of the current devices does returns data: https://api.smartcitizen.me/v0/devices/18329/readings?sensor_id=14&rollup=1h

And your query with from/to also returns data. So this suggests there may be a default which limits the time period covered unless you specify otherwise - would that be the case?

Either way, this gives a simple fix which is great. Many thanks.

Regards

Nick

Aha, you’re absolutely right - that part of the API is from before my time and I haven’t looked at it closely, but by default it’ll return the last 6 weeks worth of data, unless you specify from and to dates. We should document that better. Thanks for bringing it to my attention, and glad you’ve managed to retrieve your data!

1 Like