The Arduino IoT Cloud has different sets of APIs that provide different functionalities. This article serves as an introduction to how to work and what you can achieve with them.
The main goal of the Application API is to allow you to create and manage IoT resources like dashboards, devices, things, and variables, along with the retrieval and handling of historical data coming from your IoT Devices.
The core of those APIs is organized around REST. Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.
You can use those APIs, both directly calling our HTTP endpoints or using our clients that wrap those calls into easy-to-use abstractions like objects and functions. We have Applications API clients available in
javascript
, golang
, and python
. To use the Application API, you need to create an API Key in the API Keys section.With this API, you can:
You can find the full list of available resources and actions in the Arduino IoT Cloud Application API Technical Reference.
For learning how to successfully authenticate and interface with this API, visit the Arduino Cloud REST API & SDK article. Examples using JavaScript, Python and Golang are available here.
The Device API allows sending and receiving any kind of data (sensors' values, commands for actuators, configuration changes...) from and to IoT Devices and the Cloud. Under the hood, they:
With this API, you can:
As a wrapper for the Device API, we have the following libraries:
ArduinoIoTCloud.h
arduino-iot-js
The Arduino (C++) library allows your Arduino devices to connect and exchange data with the IoT Cloud. If you use the Arduino Cloud online environment, you do not need to install this library.
This library is also available in the library manager for Arduino IDE. With a paid subscription, you can push/pull changes to your online sketches in the offline editor.
You can find more details at:
The
arduino-iot-js
NPM module is designed for communicating with the Arduino IoT Cloud broker using the MQTT over Websocket protocol. It is primarily used to send and receive variable values.Example:
1const { ArduinoIoTCloud } = require('@arduino/arduino-iot-js');2
3ArduinoIoTCloud.connect(options)4 .then(() => {5 console.log("Connected to Arduino IoT Cloud");6 return ArduinoIoTCloud.onPropertyValue(thingId, variableName, showUpdates = value => console.log(value));7 })8 .then(() => console.log("Callback registered"))9 .catch(error => console.log(error));
Full examples and documentation can be found at:
The Arduino IoT Cloud Python Client can be installed on a board running MicroPython, and is designed to be easy to use. With just a few lines of code you can connect to the cloud, using credentials obtained during the manual device configuration.
Below is a minimal example:
1DEVICE_ID = "YOUR_DEVICE_ID"2SECRET_KEY = "YOUR_SECRET_KEY"3
4client = ArduinoCloudClient(device_id=DEVICE_ID, username=DEVICE_ID, password=SECRET_KEY)5
6client.register("variable") 7client["variable"] = 2558
9client.start()
For more information, visit the Connecting to Arduino IoT Cloud using MicroPython guide.
The Arduino IoT Cloud Python Client can also be used with regular python, and is very similar to how you connect using MicroPython, with a few adjustments.
To find out more about how to connect using Python, you can refer to the Python section of the Manual Device Configuration guide.
Public Arduino IoT Cloud APIs are exposing versioned endpoints and are committed to preserving compatibility with the following policies in place: