REST Adapter
This adapter helps to set values or get values using only POST/GET requests.
Authorization
You may add Basic Auth fill the inputs or leave empty for No Auth.
Allowed topics
Allowed MQTT topics to set or get values. All topics are set by default # Also supports two different kinds of wildcards: single-level and multi-level.
Bridge launch
After starting the bridge a new string will be added with Service ID, this ID is used to get/set values in Postman.
Variables
<base-url> host where run 2Smart Standalone project. For example <base-url> in Variables Postman :
<base_url>/service/oqd4fqhf8nixx4mdss44
Topics
Get topics
GET <base-url>/api/v1/topics?to=<topic or topic object or array of either>
- to is topic
- to is topic objects with wildcards(+, #)
- to is array of topics and topic objects
Examples
GET <base-url>/api/v1/topics?to=a/b/c
GET <base-url>/api/v1/topics?to=a/+/c
GET <base-url>/api/v1/topics?to=a/+/#
GET <base-url>/api/v1/topics?to[]=a/b/c&to[]=a/+/c&to[]=a/+/#
Response samples
{
"status": 1,
"data": {
"topics": {
"topic1":"<topic1-value>",
"topic2":"<topic2-value>",
// ...
}
}
}
Set topics
POST <base-url>/api/v1/topics/set
Body
{ topics:{ "topic1":, "topic2": } }
Response samples
{
"status": 1,
"data": {
"topics": {
"topic1":"<topic1-value>",
"topic2":"<topic2-value>",
// ...
},
"topicErrors": {
"topic1":{
"code":"<ERROR_CODE>"
},
// ...
}
}
}
Entities
Get devices
GET <base-url>/api/v1/devices?only_ids=<true|false>
- only_ids=true to return only device ids
- only_ids=false to return device objects
Response samples (only_ids=true)
{
"status": 1,
"data": {
"devices": [
"<device1-id>",
"<device2-id>",
// ...
]
}
}
Response samples (only_ids=false)
{
"status": 1,
"data": {
"devices": [
{/* device1 object */},
{/* device2 object */},
// ...
]
}
}
Get device by id
GET <base-url>/api/v1/device?deviceId=<device-id>
Response samples
{
"status": 1,
"data": {
"device": {
/* device object */
}
}
}
Get node by id
GET <base-url>/api/v1/node?deviceId=<device-id>&nodeId=<node-id>
Response samples
{
"status": 1,
"data": {
"node": {
/* node object */
}
}
}
Get sensor by id
GET <base-url>/api/v1/sensor?deviceId=<device-id>&nodeId=<node-id>&sensorId=<sensor-id>
Response samples
{
"status": 1,
"data": {
"sensor": {
/* sensor object */
}
}
}
Get option by id (of device or node)
GET <base-url>/api/v1/option?deviceId=<device-id>&optionId=<option-id>
GET <base-url>/api/v1/option?deviceId=<device-id>&nodeId=<node-id>&optionId=<option-id>
Response samples
{
"status": 1,
"data": {
"option": {
/* option object */
}
}
}
Get telemetry by id(of device or node)
GET <base-url>/api/v1/telemetry?deviceId=<device-id>&telemetryId=<telemetry-id>
GET <base-url>/api/v1/telemetry?deviceId=<device-id>&nodeId=<node-id>&telemetryId=<telemetry-id>
Response
{
"status": 1,
"data": {
"telemetry": {
/* telemetry object */
}
}
}