# Topic Subscription
# Subscribe
# URI
POST /mqtt/subscribe
# Request Message
Name | Type | Required | Default | Description |
---|---|---|---|---|
topic | String | Optional | Topic, with at least one of the topics specified | |
topics | String | Optional | Multiple topics separated by , . This field is used to subscribe to multiple topics at the same time | |
clientid | String | Required | Client identifier | |
qos | Integer | Optional | 0 | QoS level |
# Response Message
Name | Type | Description |
---|---|---|
code | Integer | 0 |
# Request Example
$ curl -u app_id:app_secret -X POST {api}/mqtt/subscribe
1
{
"topic": "d",
"qos": 1,
"clientid": "emqx_c_1"
}
1
2
3
4
5
2
3
4
5
# Response Example
{
"code": 0
}
1
2
3
2
3
# Unsubscribe
# URI
POST /mqtt/unsubscribe
# Request Message
Name | Type | Required | Default | Description |
---|---|---|---|---|
topic | String | Optional | Topic | |
clientid | String | Required | Client identifier |
# Response Message
Name | Type | Description |
---|---|---|
code | Integer | 0 |
# Request Example
$ curl -u app_id:app_secret -X POST {api}/mqtt/unsubscribe
1
{
"topic": "a",
"clientid": "emqx_c_1"
}
1
2
3
4
2
3
4
# Response Example
{
"code": 0
}
1
2
3
2
3
# Batch Subscribe
# URI
POST /mqtt/subscribe_batch
# Request Message
Name | Type | Required | Default | Description |
---|---|---|---|---|
[].topic | String | Optional | Topic, with at least one of the topics specified | |
[].topics | String | Optional | Multiple topics separated by , . This field is used to subscribe to multiple topics at the same time | |
[].clientid | String | Required | Client identifier | |
[].qos | Integer | Optional | 0 | QoS level |
# Response Message
Name | Type | Description |
---|---|---|
code | Integer | 0 |
data | Array of Objects | All the subscription information |
data[].clientid | String | clientid |
data[].topic | String | Topic |
data[].code | Integer | 0 |
# Request Example
$ curl -u app_id:app_secret -X POST {api}/mqtt/unsubscribe_batch
1
[
{
"topic": "a",
"clientid": "emqx_c_1"
}
]
1
2
3
4
5
6
2
3
4
5
6
# Response Example
{
"data": [
{
"topic": "a",
"code": 0,
"clientid": "emqx_c_1"
}
],
"code": 0
}
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
What’s on this page