Back to Smartcitizen.me

Get Historical Readings from my sensor using API (Python)

Dear all,
I would like to Get Historical Readings from my sensor using API (in Python).
I read SmartCitizen API Reference, and this example is working well (In a web browser)
https://api.smartcitizen.me/v0/devices/1616/readings?sensor_id=7&rollup=4h&from=2015-07-28&to=2015-07-30
But not with my sensor id
https://api.smartcitizen.me/v0/devices/14861/readings?sensor_id=7&rollup=4h&from=2022-01-10&to=2022-01-12
With my sensor id this is working well:
https://api.smartcitizen.me/v0/devices/14861
Do you know how can I Get Historical Readings from my sensor using API?
Do I need to authenticate using My API Key? (I would like to implement in Python).
If I need to authenticate using My API Key, is there any example in Python?
Thank you very much,
Jose

Hi Jose,

Welcome to the forum.

The sensor_id field relates to one of the id fields here. For instance, the SHT31 temperature sensor would be id = 55:

It is normal that the query doesn’t work, because your kit does not have any sensor with id = 7.

Do I need to authenticate using My API Key? (I would like to implement in Python).

No need to use the key to get readings.

Example in python:

This is all done in this python package: scdata · PyPI - You can contribute to it in here too: GitHub - fablabbcn/smartcitizen-data: A python package for analyzing environmental sensor's data

Hope it works!

Thank you very much for all the information. It is very useful. I installed scdata package and I am able to get all data from my sensors.

1 Like