• Adafruit IO Sneak Peek: New Adafruit IO API Docs! #API #HTTP #MQTT @adafruitio

    [![youtube still](/blog/images/2019-03-28-yt-still.png)](https://www.youtube.com/watch?v=DZOPQXRH9RI&feature=youtu.be)

    The Adafruit IO team is in the middle of building out a shiny new API documentation website. While updating a website for documentation doesn’t sound exciting - we have a feeling you’ll like what’s coming soon. While our current API documentation is functional, we’ve been brainstorming ideas to make it better and easier-to-use.

    Here’s a small list of the features we’re planning on adding: * Easy to Contribute to: While our pre-existing API is public on GitHub, it is not the easiest to contribute to (the v2 HTTP API sits at just over 4000 lines of JSON). The new documentation will be easier to contribute to - it’s all in everyone’s favorite formatting syntax - Markdown! * You can access Adafruit IO’s API over either MQTT or HTTP - we’re adding dedicated documentation pages for both the MQTT and the HTTP APIs. * Writing some code and not sure how to get the last known data value of your feed? Don’t want to read through lines of example code - just need the code? We’ll be including code-snippets for CuRL, Arduino CPP, Python, CircuitPython, and Ruby.

    Are you excited for the next version of the Adafruit IO API Documentation? Have features or suggestions to propose? Post up on the forum topic for this here or leave a comment below!

    Join us in the forum or on Discord in the adafruit-io channel with questions, comments, or suggestions. We’d love to hear from you!

  • Adafruit IO Update: New Line Chart and Gauge Rendering

    Hello Adafruit IO community!

    In order to reduce the amount of Javascript we send to your browser every time you visit Adafruit IO and in order to fix an annoying memory leak bug, we’ve replaced the rendering engines for the gauge and line charts you see on your Adafruit IO dashboards and feed pages. They’re low-level updates to the Adafruit IO website you all use. For the most part the changes should be invisible, but we wanted to at least mention it in case they take you by surprise.

    New gauge and line charts on an Adafruit IO dashboard

    The question you may have, then, is why fix what isn’t (obviously) broken? I’m glad you asked! We made this update for two big reasons and one small one.

    First, we’ve known for a loooong time that we have a big memory leak problem with line charts. If you’ve tried to keep a dashboard open with a line chart for more than a day, you might have noticed that you eventually came back to a frozen browser tab. If you’re unlucky, you might’ve found a crashed browser. :( Even after long hours of debugging in multiple browsers, tracing live code, and rewriting parts of the chart rendering pipeline, it’s still not clear where the problem was. It could’ve been the library we were using–an SVG based renderer–or code we wrote on top of it, but we were pushing some part of the system beyond what it could handle. By replacing the old SVG based system with a canvas based charting library we eliminate the type of memory leak we were encountering. The bonus with choosing a charting library with more options for chart types is that we’ll soon be able to introduce those to you on the dashboards. Look for that in the next few months.

    Second, our old gauges and line charts used a lot of code behind the scenes–the immensely powerful d3 library–to do just a little bit of work. We have intentionally kept our charts simple and clean, visually, but we included ~200 extra KB of uncompressed javascript code to do it. By replacing the gauge with a much smaller, hand built canvas-based plugin and line charts with a simpler library (even though it’s still powerful), we cut that code out of the bundle we have to ship to your browser. We’re sending 800KB+ of compressed/gziped, too much in our opinion, but we’re working on it :D

    Small changes that hopefully produce benefits long into the future.


    Let us know if our updates aren’t working for you or are otherwise affecting your quality of life. Join us in the forum or on Discord in the adafruit-io channel with questions, comments, or suggestions. We’d love to hear from you!

  • Adafruit IO New Feature: Interactive Dashboard Guide @adafruitio #IoT

    If you’ve logged into our internet of things service - Adafruit IO - recently, you may have noticed a new question mark icon on your dashboards.

    Click this button to launch an interactive dashboard guide.

    You’ll add a block

    Connect a feed

    Edit the block

    Make the dashboard look just right, and then save your work once everything looks the way you want it to To get started, click the blue question mark icon on an existing Adafruit IO dashboard.

    Don’t have an Adafruit IO account? You can link your Adafruit IO username - and signing up is free.

  • Adafruit IO Internals: Pagination

    Attempting to access the data points on your Adafruit IO feed and only receiving 1000 data points back? kevinljxljx on the Adafruit IO Forum was running into the same issue:

    I am trying to use the data from adafruit.io with my project, but no matter what I try, adafruit.io only gives 1000 data points to my javascript program. ( I am using XMLHttpRequest). I tried to set limit to 2000 but without luck. ( I have 1200 or so data points under my feed). Is the maximum data points I can get is 1000? or am I missing something?

    Adafruit IO’s API only returns 1000 data points at a time. To get the rest of the data (if your feed is over 1000 data points), you’ll need to “paginate” the data.

    What does this mean?

    When you perform a data query, the results are always sorted newest-to-oldest and include *x-pagination-** headers. For example:

    X-Pagination-Limit: 1000
    X-Pagination-Total: 84548
    X-Pagination-Start: 2019-02-11T22:52:18.103+0000
    X-Pagination-End: 2019-02-12T16:03:00.694+0000
    X-Pagination-Count: 1000
    

    Limit (X-Pagination-Limit) is either the requested limit or 1000, whichever is less; Total (X-Pagination-Total) is the total number of data points in the feed. Note, this value may be up to 5 minutes behind real time.

    Start (X-Pagination-Start) is the timestamp on the oldest value; End ( X-Pagination-End) is the timestamp on the newest value; and Count ( X-Pagination-Count) is the number of data points in the current request.

    Whenever Limit and Count are both 1000 and Total is more than 1000, that’s evidence that more data is available.

    You can get the next 1000 data points by using the X-Pagination-Start value OR the created_at value of the oldest data point in the API response as the end_time parameter in your next request to the data API.

    When visualized on a timeline, the concept of pagination looks like this: api-pagination.png

    Note that long running, frequently updated feeds could have more than a hundred “pages” of data. If you make requests without a delay in between, you could hit a rate limit. To avoid this, watch for 429 HTTP error responses and handle them in code by adding a 30 second timeout between requests.

    Regarding the data storage and feed history, storage size in this instance is the per-data point value size limit.

    With history on, meaning we preserve every data point, each data point value can be at most 1KB. With history off, meaning we only preserve the most recent data point, each value can be at most 100KB.

    Post originally written by AdamB on the Adafruit IO Forum, read the entire thread here…

  • Adafruit IO Update: Quick Help

    Need help getting started with Adafruit IO? Not sure what feeds are? Need a place to ask questions, but there are too many links on the internet? The Adafruit IO Team has added a new help menu directly into Adafruit IO with mini-guides designed to help you through any questions you could have about Adafruit IO, such as… How do I get started with Python? Follow the new Getting Started with Adafruit IO Python mini-guide… or “What is metadata, and how does it relate to my Adafruit IO Project?” Still have more questions? Having an issue with your code? We’ve also added links to our Discord Chatroom and the Adafruit IO Forum to the Quick Help menu - no googling necessary!

    To check it out, log into Adafruit IO (if you don’t have an account, create one - it’s free!) and click the Get Help button on the sidebar.

    Want to see anything else added to the Quick Help box? Let us know in the comments below!