Skip to content

Commit 4ae64ca

Browse files
authored
Merge pull request #730 from arduino/fmirabito/iot-cloud-api-changes
IoT API Article changes
2 parents b7ed10b + d4308b0 commit 4ae64ca

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
title: Arduino IoT Cloud APIs
3+
description: Arduino IoT Cloud has two different set of APIs. Read below to learn more
4+
author: Karl Söderby, Fabrizio Mirabito
5+
tags: [IoT Cloud, API, JavaScript]
6+
---
7+
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.
8+
9+
## Configuration API
10+
### What you can achieve
11+
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`.
12+
13+
To use the Configuration API, you need to create an **API Key** in the [API Keys](https://cloud.arduino.cc/home/api-keys) section.
14+
15+
**Examples**
16+
17+
- Build an automated script to create your things, in bulk
18+
- Duplicate the configuration of things, dashboards, devices
19+
- Create your own personal web application to manage your resources
20+
- Build a script that reads your variables' data and provides custom analytics
21+
22+
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/).
23+
24+
## Data API
25+
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
26+
27+
- take care of the data exchange with our MQTT broker
28+
- handle best in class authentication & security
29+
- manage compression, data format, and transport protocols
30+
31+
### What you can achieve
32+
- Send sensors' values to the cloud
33+
- Send and receive input and commands from and to dashboards
34+
- Listen for variables' values changes and act upon them
35+
36+
Inside this set of API, we have:
37+
38+
- An official Arduino IoT Cloud Library for your Arduino sketches: `ArduinoIoTCloud.h`
39+
- An NPM Javascript package: `arduino-iot-js`
40+
41+
**Arduino IoT Cloud Sketch library**
42+
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.
43+
44+
You can find more details at:
45+
46+
- The [official repository](https://github.com/arduino-libraries/ArduinoIoTCloud)
47+
- The [cheat sheet](https://docs.arduino.cc/arduino-cloud/getting-started/technical-reference)
48+
49+
**Arduino IoT JS**
50+
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.
51+
52+
Example:
53+
54+
```js
55+
const { ArduinoIoTCloud } = require('@arduino/arduino-iot-js');
56+
57+
ArduinoIoTCloud.connect(options)
58+
.then(() => {
59+
console.log("Connected to Arduino IoT Cloud");
60+
return ArduinoIoTCloud.onPropertyValue(thingId, variableName, showUpdates = value => console.log(value));
61+
})
62+
.then(() => console.log("Callback registered"))
63+
.catch(error => console.log(error));
64+
```
65+
66+
Full examples and documentation can be found at:
67+
68+
- The [official repository](https://github.com/arduino/arduino-iot-js)
69+
- The [NPM module](https://www.npmjs.com/package/arduino-iot-js) page
70+
71+
## Backward Compatibility Policy
72+
73+
Public Arduino IoT Cloud APIs are exposing versioned endpoints and are committed to preserving compatibility with the following policies in place:
74+
- When making a breaking change to the API signature or behavior, we will expose a new version of the endpoint.
75+
- If we are making a change that is backward compatible with the existing version, we won't change the endpoint version.
76+
- When introducing a new version of the API, we will preserve the previous version as deprecated for a reasonable amount of time to allow client migrations.
77+
- We will not preserve multiple previous versions, just N-1 with respect to the current last released, hence upgrades are recommended.
78+
- In any case, the frequency of version changes is expected to be less than once a year.
79+
- It's also recommended that the client keeps the base URL of the API configurable because the base URL (currently api2.arduino.cc) might also change.

0 commit comments

Comments
 (0)