Client
To fetch data from a 3rd party endpoint over HTTP, we recommend the HTTPClient
library that comes automatically bundled with Arduino.
Include this header in your main.cpp
file:
To parse JSON we will use the ArduinoJSON
library. Include this header in your main.cpp
file:
Goal#
We will fetch data from the following endpoint, https://www.boredapi.com/api/activity, which returns:
Our goal is to take the value of activity
every 10 minutes and display it on kublet.
Code#
Your code should look like this:
JSON Streaming#
There may be cases where the size of the response payload is too large. To manage this, use a HTTP stream instead. We recommend the following library: