Hi,
I want to retrieve the last 10 values from a variable using the Python API. Below script is done in python 2.7, from a Ubuntu machine.
I actually do manage to retrieve the lastest value stored in the variable, as you can see below:
from ubidots import ApiClient
api = ApiClient(token=‘xxxxxxx’)
my_specific_variable = api.get_variable(‘yyyyyy’)
values = my_specific_variable.get_values(10)
values[0][‘value’]
Output: 58.84375
However, when I try to retrieve the second last value, then python is throwing an error message “list index out of range”, as you can see below:
values[1][‘value’]
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in ()
----> 1 values[1][‘value’]IndexError: list index out of range
I can confirm that there are actually hundrets of values in that variable on the Ubidots server. So that shouldn’t be the list’s index limitation.
Do I use the API wrong?
Thanks a lot in advance for any hint!