Get All MQTT Subscriptions

Returns all MQTT subscriptions.

Request

HTTP Request

GET /node/api/mqtt/subscriptions

Permissions

manage-service-properties

Path parameters

No parameters required.

Request body

The request body is empty.

Response

This request returns a list of all current MQTT subscriptions.

The response incudes the following fields:

Field Type Description

owner.entityId

String

The ID of an entity that’s subscribed to the MQTT message.

owner.entityType

Integer

The type of en entity that’s subscribed to the MQTT message. 1 is object, 2 is link.

topic

String

The topic of the subscription.

dataExpiryPeriod

Integer

The time in which this subscription expires (in milliseconds). Is included in the response only if set.

The dataExpiryPeriod field is only included in the response if it has been defined.

Example

Request

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/mqtt/subscriptions

curl -X GET $url -u $login:$password
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/mqtt/subscriptions";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Authorization", auth);

let requestOptions = {
    method: "GET",
    headers: headers
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/mqtt/subscriptions";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "GET",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth
    },
    "path": path
};

let req = http.request(options, function (res) {
    let chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        let body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/mqtt/subscriptions"

response = requests.request("GET", url, auth=(login, password))
print(response.text)

Response

[
    {
        "owner": {
            "entityId": "5c64303dc2350015e23b2676",
            "entityType": 1
        },
        "topic": "/parsed/controller/22-B9-00-02-A5-11/part/1/device/1/+",
        "dataExpiryPeriod": 31449600000
    },
    ...
}