API Data limit default change question

Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Locked
User avatar
wilsonRL
 
Posts: 11
Joined: Tue Jul 13, 2021 10:09 pm

API Data limit default change question

Post by wilsonRL »

I've been working on a school project all semester that uses Adafruit's IO. This morning, when I went to take a screenshot of my project's graphs (I'm creating my own with matplotlib), I noticed that it was only showing the 100 most recent data points. After hours of frustration, I discovered that yesterday Adafruit changed the default limit of records you can get from 1000 to 100: viewtopic.php?f=56&t=190636

I thought this would be a simple change of my code from:

Code: Select all

data = aio.data('test')
to:

Code: Select all

data = aio.data('test', max_results=None)
However, I keep getting the error message: TypeError: data() got an unexpected keyword argument 'max_results' Did this keyword also change with the update? The documentation I'm using (https://adafruit-io-python-client.readt ... /data.html) doesn't seem to have been updated as it still says the default limit is 1000. Is there any other way to easily retrieve all of my data with similar code?

It's not the end of the world; I have old screen shots I can include in my presentation and I'm sure my teacher will understand. It's just really frustrating.

Thank you!

User avatar
jwcooper
 
Posts: 1004
Joined: Tue May 01, 2012 9:08 pm

Re: API Data limit default change question

Post by jwcooper »

Apologies for the frustrations. We had to make that change due to how many users were calling that endpoint at their throttle capacity. Usually you wouldn't need 1000 points of data every second, as it's not possible to even read and write at that rate. We'll continue to make changes to balance user features vs server usage, and any future announcements will be made here or on our blog (https:/io.adafruit.com/blog).

If you upgrade to the latest Python library version, that max_results call should work:
https://github.com/adafruit/Adafruit_IO ... /tag/2.7.0

If you do increase back up to 1000 or beyond, please limit how often you make that call to refresh your charts, as we have had to reach out to some users for their usage activity.

User avatar
wilsonRL
 
Posts: 11
Joined: Tue Jul 13, 2021 10:09 pm

Re: API Data limit default change question

Post by wilsonRL »

Thank you so much!

I appreciate the free resource as a tool for learning and hope I didn't try to get my data too often. I should only need to get my data two more times (once for a picture and once for a demonstration). However, this does leave me wondering if it's possible to only get the new data? I'm finished with my project now (as soon as I get the picture), but if I were to do something else like this in the future, I could always store the data in a file and just add the new data to it, so I don't have to keep requesting the same data each time I test my code.

Locked
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.

Return to “Internet of Things: Adafruit IO and Wippersnapper”