Developer API for Devices
-
Abstract
The platform provides 2 type of API for developers. They are API for devices and API for apps. Please refer to your account type limitation whether you have access on them. In this doc we will learn about API for devices specifically. To learn about API for apps please refer to another doc specific for it.
You need to have some knowledge about the basic principle of API to learn the doc and practice seamlessly.
API for devices is designed for data communication between devices and SAM Element cloud services through MQTT protocol. You need to supply this API as the username and password while making an MQTT connection. The term “device” we’re talking here is any electronic device that can be in any form: sensor, actuator, washing machine, lighting, etc. So generally speaking, when you want to build your smart IoT device, you need this type of developer API for devices. Later in this documentation, when we mention the term “developer API”, it means developer API for devices.
When you create API in your developer dashboard account, it will be created in a pair of username and password.
-
How to Use
The MQTT protocol provides username and password fields in the CONNECT message for authentication. Please refer to the authentication page on how to obtain your access token. When you get the access token, then you can use the token as the username and use “jwt” as the password, to authenticate to the MQTT broker. Important information as follow:
-
- MQTT broker host is iot.samelement.com.
- Available Ports: 8883 (TCP) and 8081 (Websockets).
- Always verify your connection to make sure you are really connecting to our server.
We are now accepting MQTT connection ONLY to the secure port, which is 8883. For format and guidelines please refer to MQTT Standard Interfaces.
Last Update: November 13, 2019