Skip to content

[IOTC] Update cloud APIs article #1027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,62 @@
title: Arduino IoT Cloud APIs
description: Arduino IoT Cloud has two different set of APIs. Read below to learn more
author: Karl Söderby, Fabrizio Mirabito
tags: [IoT Cloud, API, JavaScript]
tags: [IoT Cloud, Device API, Application API, JavaScript]
---

The [Arduino IoT Cloud](https://create.arduino.cc/iot/) 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.

## Configuration API
### What you can achieve
The main goal of Configuration 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](http://en.wikipedia.org/wiki/Representational_State_Transfer). Our API has predictable resource-oriented URLs, accepts [form-encoded](https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms) request bodies, returns [JSON-encoded](http://www.json.org/) 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`.
## Application API

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.

To use the Configuration API, you need to create an **API Key** in the [API Keys](https://cloud.arduino.cc/home/api-keys) section.
The core of those APIs is organized around [REST](http://en.wikipedia.org/wiki/Representational_State_Transfer). Our API has predictable resource-oriented URLs, accepts [form-encoded](https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms) request bodies, returns [JSON-encoded](http://www.json.org/) responses, and uses standard HTTP response codes, authentication, and verbs.

**Examples**
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](https://cloud.arduino.cc/home/api-keys) section.

With this API, you can:
- Build an automated script to create your things, in bulk
- Duplicate the configuration of things, dashboards, devices
- Create your own personal web application to manage your resources
- Build a script that reads your variables' data and provides custom analytics

You can find the full list of available resources and actions in the [Arduino IoT Cloud Configuration API Technical Reference](https://www.arduino.cc/reference/en/iot/api/).
### Resources

You can find the full list of available resources and actions in the [Arduino IoT Cloud Application API Technical Reference](https://www.arduino.cc/reference/en/iot/api/).

***For learning how to successfully authenticate and interface with this API, visit the [Arduino Cloud REST API & SDK](https://docs.arduino.cc/arduino-cloud/getting-started/arduino-iot-api) article. Examples using JavaScript, Python and Golang are available here.***

## Data API
Data 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
## Device API

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:

- take care of the data exchange with our MQTT broker
- handle best in class authentication & security
- manage compression, data format, and transport protocols

### What you can achieve
With this API, you can:
- Send sensors' values to the cloud
- Send and receive input and commands from and to dashboards
- Listen for variables' values changes and act upon them

Inside this set of API, we have:
As a wrapper for the Device API, we have the following libraries:

- An official Arduino IoT Cloud Library for your Arduino sketches: `ArduinoIoTCloud.h`
- An NPM Javascript package: `arduino-iot-js`

**Arduino IoT Cloud Sketch library**
As described above, is the Arduino library that allows your Arduino devices to connect and exchange data with the IoT Cloud. If you edit your sketch directly inside IoT Cloud or Cloud Editor, you don't need to install it: it comes out of the box.
### Arduino IoT Cloud Sketch library

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](https://www.arduino.cc/en/software). With a paid subscription, you can push/pull changes to your online sketches in the offline editor.

You can find more details at:

- The [official repository](https://github.com/arduino-libraries/ArduinoIoTCloud)
- The [cheat sheet](https://docs.arduino.cc/arduino-cloud/getting-started/technical-reference)

**Arduino IoT JS**
### Arduino IoT JS

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:
Expand Down