< 反馈文档问题

EMQX Dedicated REST API (v5)

Download OpenAPI specification:Download

EMQX Dedicated REST API

Authentication

获取内置数据库认证器中的指定用户数据。

获取内置数据库认证器中的指定用户数据。

Authorizations:
basicAuthbearerAuth
path Parameters
user_id
required
string

用户 ID,根据设置的账号类型不同,可以是 username 或 clientid

Responses

Response samples

Content type
application/json
Example
{
  • "user_id": "user1"
}

更新内置数据库认证器中的指定用户数据。

更新内置数据库认证器中的指定用户数据。

Authorizations:
basicAuthbearerAuth
path Parameters
user_id
required
string

用户 ID,根据设置的账号类型不同,可以是 username 或 clientid

Request Body schema: application/json
password
required
string
is_superuser
boolean
Default: false

Responses

Request samples

Content type
application/json
Example
{
  • "password": "******"
}

Response samples

Content type
application/json
{
  • "regular_user": {
    },
  • "super_user": {
    }
}

删除内置数据库认证器中的指定用户数据。

删除内置数据库认证器中的指定用户数据。

Authorizations:
basicAuthbearerAuth
path Parameters
user_id
required
string

用户 ID,根据设置的账号类型不同,可以是 username 或 clientid

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

为内置数据库认证器导入用户数据。

为内置数据库认证器导入用户数据。

Authorizations:
basicAuthbearerAuth
query Parameters
type
required
string
Enum: "plain" "hash"
Example: type=hash

The import file template type, enum with plain,hash

Request Body schema: application/json

Import body

object

Responses

Request samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

获取内置数据库认证器中的用户列表。

获取内置数据库认证器中的用户列表。

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

like_user_id
string

使用用户 ID (username 或 clientid)模糊查询。

is_superuser
boolean

是否是超级用户。

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

向内置数据库认证器添加用户数据。

向内置数据库认证器添加用户数据。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
user_id
required
string
password
required
string
is_superuser
boolean
Default: false

Responses

Request samples

Content type
application/json
Example
{
  • "password": "******",
  • "user_id": "user1"
}

Response samples

Content type
application/json
Example
{
  • "user_id": "user1"
}

Authorization

显示用户名规则列表。

显示用户名规则列表。

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

like_username
string

使用字串匹配模糊搜索用户名

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

为指定的用户添加规则。

为指定的用户添加规则。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
Array
Array of objects (emqx_authz_api_mnesia.rule_item)
username
required
string

用户名

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

显示客户端规则列表。

显示客户端规则列表。

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

like_clientid
string

使用字串匹配模糊搜索客户端 ID

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

为指定客户端添加规则。

为指定客户端添加规则。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
Array
Array of objects (emqx_authz_api_mnesia.rule_item)
clientid
required
string

客户端 ID

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

获取指定客户端的规则

获取指定客户端的规则

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Example: client1

客户端 ID

Responses

Response samples

Content type
application/json
{
  • "rules": [
    ],
  • "clientid": "client1"
}

设置指定客户端的规则

设置指定客户端的规则

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Example: client1

客户端 ID

Request Body schema: application/json
Array of objects (emqx_authz_api_mnesia.rule_item)
clientid
required
string

客户端 ID

Responses

Request samples

Content type
application/json
{
  • "rules": [
    ],
  • "clientid": "client1"
}

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

删除指定客户端的规则

删除指定客户端的规则

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Example: client1

客户端 ID

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

获取指定用户名规则

获取指定用户名规则

Authorizations:
basicAuthbearerAuth
path Parameters
username
required
string
Example: user1

用户名

Responses

Response samples

Content type
application/json
{
  • "rules": [
    ],
  • "username": "user1"
}

设置指定用户名的规则

设置指定用户名的规则

Authorizations:
basicAuthbearerAuth
path Parameters
username
required
string
Example: user1

用户名

Request Body schema: application/json
Array of objects (emqx_authz_api_mnesia.rule_item)
username
required
string

用户名

Responses

Request samples

Content type
application/json
{
  • "rules": [
    ],
  • "username": "user1"
}

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

删除指定用户名的规则

删除指定用户名的规则

Authorizations:
basicAuthbearerAuth
path Parameters
username
required
string
Example: user1

用户名

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

清除内置数据库中的所有类型('users' 、'clients' 、'all')的所有规则

清除内置数据库中的所有类型('users' 、'clients' 、'all')的所有规则

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

列出适用于所有客户端规则 (即 'all' 规则)。

列出适用于所有客户端规则 (即 'all' 规则)。

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
{
  • "rules": [
    ]
}

删除 'all' 规则

删除 'all' 规则

Authorizations:
basicAuthbearerAuth

Responses

创建或更新适用于所有客户端的规则(即 'all' 规则)。

创建或更新适用于所有客户端的规则(即 'all' 规则)。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
Array of objects (emqx_authz_api_mnesia.rule_item)

Responses

Request samples

Content type
application/json
{
  • "rules": [
    ]
}

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Banned

列出目前所有被封禁的客户端 ID、用户名和 IP 地址。

列出目前所有被封禁的客户端 ID、用户名和 IP 地址。

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

清除全部黑名单数据。

清除全部黑名单数据。

Authorizations:
basicAuthbearerAuth

Responses

添加一个客户端 ID、用户名或者 IP 地址到黑名单。

添加一个客户端 ID、用户名或者 IP 地址到黑名单。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
as
required
string
Enum: "clientid" "username" "peerhost" "clientid_re" "username_re" "peerhost_net"

封禁方式,可以通过客户端 ID、用户名或者 IP 地址等方式进行封禁。

who
required
string

封禁对象,具体的客户端 ID、用户名或者 IP 地址。

by
string

封禁的发起者。

reason
string

封禁原因,记录当前对象被封禁的原因。

integer or string

封禁的起始时间,格式为 rfc3339,默认为发起操作的时间。

integer or string

封禁的结束时间,格式为 rfc3339,默认值为发起操作的时间 + 1 年。

Responses

Request samples

Content type
application/json
{
  • "as": "username",
  • "who": "Banned name",
  • "by": "mgmt_api",
  • "reason": "Too many requests",
  • "at": "2021-10-25T21:48:47+08:00",
  • "until": "2021-10-25T21:53:47+08:00"
}

Response samples

Content type
application/json
{
  • "data": [
    ]
}

将一个客户端 ID、用户名或者 IP 地址从黑名单中删除。

将一个客户端 ID、用户名或者 IP 地址从黑名单中删除。

Authorizations:
basicAuthbearerAuth
path Parameters
as
required
string
Enum: "clientid" "username" "peerhost" "clientid_re" "username_re" "peerhost_net"
Example: username

封禁方式,可以通过客户端 ID、用户名或者 IP 地址等方式进行封禁。

who
required
string
Example: Badass

封禁对象,具体的客户端 ID、用户名或者 IP 地址。

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

Clients

----


Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
Array
string

Responses

Request samples

Content type
application/json
[
  • "emqx_clientid_985bb09d",
  • "emqx_clientid_211cc01c"
]

获取指定客户端的授权缓存

获取指定客户端的授权缓存

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string

Responses

Response samples

Content type
application/json
{
  • "access": "publish",
  • "result": "allow",
  • "topic": "testtopic/1",
  • "updated_time": 1687850712989
}

清除指定客户端的授权缓存

清除指定客户端的授权缓存

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string

Responses

Response samples

Content type
application/json
{
  • "code": "CLIENTID_NOT_FOUND",
  • "message": "string"
}

获取指定客户端的详细信息

获取指定客户端的详细信息

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string

Responses

Response samples

Content type
application/json
{
  • "heap_size": 610,
  • "send_msg.dropped.expired": 0,
  • "send_oct": 31,
  • "recv_msg.qos1": 0,
  • "is_persistent": false,
  • "send_pkt": 4,
  • "clean_start": true,
  • "inflight_cnt": 0,
  • "node": "emqx@127.0.0.1",
  • "send_msg.dropped.queue_full": 0,
  • "awaiting_rel_cnt": 0,
  • "inflight_max": 32,
  • "created_at": "2024-01-01T12:34:56.789+08:00",
  • "subscriptions_cnt": 1,
  • "mailbox_len": 0,
  • "send_cnt": 4,
  • "connected": true,
  • "ip_address": "127.0.0.1",
  • "awaiting_rel_max": 100,
  • "recv_msg.qos2": 0,
  • "proto_ver": 5,
  • "mountpoint": "null",
  • "proto_name": "MQTT",
  • "port": 52571,
  • "connected_at": "2024-01-01T12:34:56.789+08:00",
  • "enable_authn": true,
  • "expiry_interval": 0,
  • "username": null,
  • "recv_msg": 0,
  • "recv_oct": 49,
  • "send_msg.dropped.too_large": 0,
  • "keepalive": 60,
  • "send_msg.qos1": 0,
  • "send_msg.qos2": 0,
  • "recv_msg.qos0": 0,
  • "send_msg.qos0": 0,
  • "subscriptions_max": "infinity",
  • "mqueue_max": 1000,
  • "mqueue_dropped": 0,
  • "clientid": "01",
  • "is_bridge": false,
  • "peerport": 52571,
  • "send_msg": 0,
  • "listener": "tcp:default",
  • "recv_cnt": 4,
  • "recv_pkt": 4,
  • "recv_msg.dropped": 0,
  • "send_msg.dropped": 0,
  • "recv_msg.dropped.await_pubrel_timeout": 0,
  • "reductions": 6836,
  • "mqueue_len": 0
}

踢出指定客户端

踢出指定客户端

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string

Responses

Response samples

Content type
application/json
{
  • "code": "CLIENTID_NOT_FOUND",
  • "message": "string"
}

批量取消订阅

批量取消订阅

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Request Body schema: application/json
Array
topic
string

Topic

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
{
  • "code": "CLIENTID_NOT_FOUND",
  • "message": "string"
}

批量订阅

批量订阅

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Request Body schema: application/json
Array
topic
required
string

Topic

qos
integer [ 0 .. 2 ]
Default: 0

QoS

nl
integer
Default: 0

No Local

rap
integer
Default: 0

Retain as Published

rh
integer
Default: 0

Retain Handling

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
[
  • {
    }
]

订阅

订阅

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Request Body schema: application/json
topic
required
string

Topic

qos
integer [ 0 .. 2 ]
Default: 0

QoS

nl
integer
Default: 0

No Local

rap
integer
Default: 0

Retain as Published

rh
integer
Default: 0

Retain Handling

Responses

Request samples

Content type
application/json
{
  • "topic": "testtopic/#",
  • "qos": 0,
  • "nl": 0,
  • "rap": 0,
  • "rh": 0
}

Response samples

Content type
application/json
{
  • "node": "emqx@127.0.0.1",
  • "topic": "testtopic/1",
  • "clientid": "emqx_clientid_xx128cdhfc",
  • "qos": 0,
  • "nl": 0,
  • "rap": 0,
  • "rh": 0
}

获取客户端消息队列中的消息。

获取客户端消息队列中的消息。

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
query Parameters
payload
string
Default: "base64"
Enum: "none" "base64" "plain"

Client's inflight/mqueue messages payload encoding. If set to none, no payload is returned in the response.

max_payload_bytes
string
Default: "1MB"
Example: max_payload_bytes=32MB

Client's inflight/mqueue messages payload limit. The total payload size of all messages in the response will not exceed this value. Messages beyond the limit will be silently omitted in the response. The only exception to this rule is when the first message payload is already larger than the limit. In this case, the first message will be returned in the response.

string or string or string
Example: position=none

An opaque token that can then be in subsequent requests to get the next chunk of results: "?position={prev_response.meta.position}"
It is used instead of "page" parameter to traverse highly volatile data.
Can be omitted or set to "none" to get the first chunk of data.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

获取客户端未确认消息。

获取客户端未确认消息。

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
query Parameters
payload
string
Default: "base64"
Enum: "none" "base64" "plain"

Client's inflight/mqueue messages payload encoding. If set to none, no payload is returned in the response.

max_payload_bytes
string
Default: "1MB"
Example: max_payload_bytes=32MB

Client's inflight/mqueue messages payload limit. The total payload size of all messages in the response will not exceed this value. Messages beyond the limit will be silently omitted in the response. The only exception to this rule is when the first message payload is already larger than the limit. In this case, the first message will be returned in the response.

string or string or string
Example: position=none

An opaque token that can then be in subsequent requests to get the next chunk of results: "?position={prev_response.meta.position}"
It is used instead of "page" parameter to traverse highly volatile data.
Can be omitted or set to "none" to get the first chunk of data.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

取消订阅

取消订阅

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string
Request Body schema: application/json
topic
string

Topic

Responses

Request samples

Content type
application/json
{
  • "topic": "testtopic/#"
}

Response samples

Content type
application/json
{
  • "code": "CLIENTID_NOT_FOUND",
  • "message": "string"
}

获取指定客户端的订阅列表

获取指定客户端的订阅列表

Authorizations:
basicAuthbearerAuth
path Parameters
clientid
required
string

Responses

Response samples

Content type
application/json
[
  • {
    }
]

列出客户端

列出客户端

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

node
string
Example: node=emqx@127.0.0.1

Node name

username
Array of strings

User name, multiple values can be specified by repeating the parameter: username=u1&username=u2

ip_address
string
Example: ip_address=127.0.0.1

Client's IP address

conn_state
string
Enum: "connected" "idle" "disconnected"

The current connection status of the client, the possible values are connected,idle,disconnected

clean_start
boolean

Whether the client uses a new session

proto_ver
string

Client protocol version

like_clientid
string

Fuzzy search clientid as substring

like_username
string

Fuzzy search username as substring

integer or string

Search client session creation time by greater than or equal method, rfc3339 or timestamp(millisecond)

integer or string

Search client session creation time by less than or equal method, rfc3339 or timestamp(millisecond)

integer or string

Search client connection creation time by greater than or equal method, rfc3339 or timestamp(epoch millisecond)

integer or string

Search client connection creation time by less than or equal method, rfc3339 or timestamp(millisecond)

clientid
Array of strings

Client ID, multiple values can be specified by repeating the parameter: clientid=c1&clientid=c2

Array of strings or string
Default: "all"

Comma separated list of client fields to return in the response

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

Subscriptions

获取集群的订阅列表。

获取集群的订阅列表。

Authorizations:
basicAuthbearerAuth
query Parameters
page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

node
string
Example: node=emqx@127.0.0.1

Node name

clientid
string

Client ID

qos
integer [ 0 .. 2 ]
Example: qos=0

QoS

topic
string

Topic, url encoding

match_topic
string

Match topic string, url encoding

share_group
string

Shared subscription group name

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Publish

Publish a batch of messages

批量发布多条消息。

可能的 HTTP 状态码如下:

200: 所有的消息都被成功发送到至少一个订阅。

202: 至少有一个消息没有匹配到任何订阅。

400: 至少有一个消息编码错误,如非法主题,或 QoS 超出范围等。

503: 至少有一个小因为服务重启的原因导致转发失败。


请求的 Body 或者 Body 中包含的某个消息无法通过 API 规范的类型检查时,HTTP 响应的消息与发布单个消息的 API
/publish 是一样的。
如果所有的消息都是合法的,那么 HTTP 返回的内容是一个 JSON 数组,每个元素代表了该消息转发的状态。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
Array
payload_encoding
string
Default: "plain"
Enum: "plain" "base64"

MQTT 消息体的编码方式,可以是 base64plain。当设置为 base64 时,消息在发布前会先被解码,可以用于发布二进制等数据。

topic
required
string

主题

qos
integer [ 0 .. 2 ]
Default: 0

QoS

clientid
string
Deprecated
payload
required
string

MQTT 消息体.

object (emqx_mgmt_api_publish.message_properties)
retain
boolean
Default: false

保留消息,布尔型字段,用于表示该消息是否是保留消息。

Responses

Request samples

Content type
application/json
[
  • {
    }
]

Response samples

Content type
application/json
[
  • {
    }
]

Publish a message

发布单条信息。

可能的 HTTP 状态码如下:

200: 消息被成功发送到至少一个订阅。

202: 没有匹配到任何订阅。

400: 消息编码错误,如非法主题,或 QoS 超出范围等。

503: 服务重启等过程中导致转发失败。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
payload_encoding
string
Default: "plain"
Enum: "plain" "base64"

MQTT 消息体的编码方式,可以是 base64plain。当设置为 base64 时,消息在发布前会先被解码,可以用于发布二进制等数据。

topic
required
string

主题

qos
integer [ 0 .. 2 ]
Default: 0

QoS

clientid
string
Deprecated
payload
required
string

MQTT 消息体.

object (emqx_mgmt_api_publish.message_properties)
retain
boolean
Default: false

保留消息,布尔型字段,用于表示该消息是否是保留消息。

Responses

Request samples

Content type
application/json
{
  • "payload_encoding": "plain",
  • "topic": "api/example/topic",
  • "qos": 0,
  • "clientid": "string",
  • "payload": "hello emqx api",
  • "properties": {
    },
  • "retain": false
}

Response samples

Content type
application/json
{
  • "id": "string"
}

Retainer

查看保留消息列表

查看保留消息列表

Authorizations:
basicAuthbearerAuth
query Parameters
topic
string

主题过滤器,支持通配符,省略此项以匹配所有消息。

page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

删除所有保留消息

删除所有保留消息

Authorizations:
basicAuthbearerAuth

Responses

不支持主题通配符

不支持主题通配符

Authorizations:
basicAuthbearerAuth
path Parameters
topic
required
string

主题

Responses

Response samples

Content type
application/json
{
  • "payload": "string",
  • "msgid": "string",
  • "topic": "string",
  • "qos": 0,
  • "publish_at": "string",
  • "from_clientid": "string",
  • "from_username": "string"
}

删除对应的消息

删除对应的消息

Authorizations:
basicAuthbearerAuth
path Parameters
topic
required
string

主题

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Metrics

EMQX 监控指标信息

EMQX 监控指标信息

Authorizations:
basicAuthbearerAuth
query Parameters
aggregate
boolean

Whether to aggregate all nodes Metrics

Responses

Response samples

Content type
application/json
Example
[ ]

当前监控(统计)数据,例如整个集群中的连接数和连接速率。

当前监控(统计)数据,例如整个集群中的连接数和连接速率。

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
{
  • "dropped_msg_rate": 0,
  • "sent_msg_rate": 0,
  • "received_msg_rate": 0,
  • "subscriptions": 0,
  • "topics": 0,
  • "connections": 0,
  • "live_connections": 0,
  • "retained_msg_count": 0,
  • "shared_subscriptions": 0,
  • "license_quota": 0
}

Connectors

Test creating connector

测试创建一个新的连接器。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
One of
type
required
string
Value: "timescale"

连接器的类型。

name
required
string

连接器的名称

enable
boolean
Default: true

启用 (是) 或 停用 (否) 该连接器。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

server
required
string

用于连接的 IPv4 或 IPv6 地址或主机名。

一个主机条目具有以下格式:Host[:Port]。

如果未指定 [:Port],将使用 PostgreSQL 默认端口5432。

database
required
string

数据库名字。

pool_size
integer >= 1
Default: 8

桥接远端服务时使用的连接池大小。

username
required
string

内部数据库的用户名。

password
string <password>

内部数据库密码。

auto_reconnect
boolean
Deprecated
Default: true

已弃用。自动重连数据库。

object (emqx.ssl_client_opts)
object (connector_postgres.resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "name": "influxdb_connector",
  • "type": "influxdb",
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    }
}

Response samples

Content type
application/json
{
  • "code": "TEST_FAILED",
  • "message": "string"
}

Get connector

通过 id 获取一个连接器。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_connector

连接器 id。必须是 {type}:{name} 的格式。

Responses

Response samples

Content type
application/json
Example
{
  • "name": "influxdb_connector",
  • "status": "connected",
  • "type": "influxdb",
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    },
  • "node_status": [
    ],
  • "actions": [
    ]
}

Update connector

通过 id 更新一个连接器。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_connector

连接器 id。必须是 {type}:{name} 的格式。

Request Body schema: application/json
One of
enable
boolean
Default: true

启用 (是) 或 停用 (否) 该连接器。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

server
required
string

用于连接的 IPv4 或 IPv6 地址或主机名。

一个主机条目具有以下格式:Host[:Port]。

如果未指定 [:Port],将使用 PostgreSQL 默认端口5432。

database
required
string

数据库名字。

pool_size
integer >= 1
Default: 8

桥接远端服务时使用的连接池大小。

username
required
string

内部数据库的用户名。

password
string <password>

内部数据库密码。

auto_reconnect
boolean
Deprecated
Default: true

已弃用。自动重连数据库。

object (emqx.ssl_client_opts)
object (connector_postgres.resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    }
}

Response samples

Content type
application/json
Example
{
  • "name": "influxdb_connector",
  • "status": "connected",
  • "type": "influxdb",
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    },
  • "node_status": [
    ],
  • "actions": [
    ]
}

Delete connector

通过 id 删除一个连接器。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_connector

连接器 id。必须是 {type}:{name} 的格式。

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Manually start a connector

在集群的所有节点上启动连接器。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_connector

连接器 id。必须是 {type}:{name} 的格式。

operation
required
string
Value: "start"
Example: start

集群可用操作:'start'。

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Enable or disable connector

在集群的所有节点上启用或禁用连接器。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_connector

连接器 id。必须是 {type}:{name} 的格式。

enable
required
boolean
Example: true

是否启用此连接器。

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

List connectors

列出所有创建的连接器。

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {},
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {},
  • {
    },
  • {
    }
]

Create connector

通过类型和名称创建一个新的连接器。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
One of
type
required
string
Value: "timescale"

连接器的类型。

name
required
string

连接器的名称

enable
boolean
Default: true

启用 (是) 或 停用 (否) 该连接器。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

server
required
string

用于连接的 IPv4 或 IPv6 地址或主机名。

一个主机条目具有以下格式:Host[:Port]。

如果未指定 [:Port],将使用 PostgreSQL 默认端口5432。

database
required
string

数据库名字。

pool_size
integer >= 1
Default: 8

桥接远端服务时使用的连接池大小。

username
required
string

内部数据库的用户名。

password
string <password>

内部数据库密码。

auto_reconnect
boolean
Deprecated
Default: true

已弃用。自动重连数据库。

object (emqx.ssl_client_opts)
object (connector_postgres.resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "name": "influxdb_connector",
  • "type": "influxdb",
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    }
}

Response samples

Content type
application/json
Example
{
  • "name": "influxdb_connector",
  • "status": "connected",
  • "type": "influxdb",
  • "ssl": {
    },
  • "description": "My example influxdb connector",
  • "server": "127.0.0.1:8086",
  • "enable": true,
  • "parameters": {
    },
  • "node_status": [
    ],
  • "actions": [
    ]
}

Rules

Test a rule

测试一个规则

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
rule_engine.ctx_delivery_dropped (object) or rule_engine.ctx_bridge_mqtt (object) or rule_engine.ctx_check_authz_complete (object) or rule_engine.ctx_connack (object) or rule_engine.ctx_disconnected (object) or rule_engine.ctx_connected (object) or rule_engine.ctx_dropped (object) or rule_engine.ctx_acked (object) or rule_engine.ctx_delivered (object) or rule_engine.ctx_unsub (object) or rule_engine.ctx_sub (object) or rule_engine.ctx_pub (object)
Default: {}

测试事件的上下文

sql
required
string

测试的 SQL

Responses

Request samples

Content type
application/json
{
  • "context": { },
  • "sql": "string"
}

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

List rules

列出所有规则

Authorizations:
basicAuthbearerAuth
query Parameters
enable
boolean

根据规则是否开启条件过滤

from
string

根据规则来源 Topic 过滤, 需要完全匹配

like_id
string

根据规则 id 过滤, 使用子串模糊匹配

like_from
string

根据规则来源 Topic 过滤, 使用子串模糊匹配

like_description
string

根据规则描述过滤, 使用子串模糊匹配

match_from
string

根据规则来源 Topic 过滤, 使用 MQTT Topic 匹配

page
integer >= 1
Default: 1
Example: page=1

Page number of the results to fetch.

limit
integer [ 1 .. 10000 ]
Default: 100
Example: limit=50

Results per page(max 10000)

Responses

Response samples

Content type
application/json
{
  • "data": [
    ],
  • "meta": {
    }
}

Create a rule

通过指定 ID 创建规则

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
name
string
Default: ""

规则名字

sql
required
string

用于处理消息的 SQL 。
示例:SELECT * FROM "test/topic" WHERE payload.x = 1

Array of rule_engine.user_provided_function (object) or rule_engine.builtin_action_console (object) or rule_engine.builtin_action_republish (object) or strings
Default: []

规则的动作列表。
动作可以是指向 EMQX 数据桥接的引用,也可以是一个指向函数的对象。
我们支持一些内置函数,如“republish”和“console”,我们还支持用户提供的函数,它的格式为:“{module}:{function}”。
列表中的动作按顺序执行。这意味着如果其中一个动作执行缓慢,则以下所有动作都不会被执行直到它返回。
如果其中一个动作崩溃,在它之后的所有动作仍然会被按照原始顺序执行。
如果运行动作时出现任何错误,则会出现错误消息,并且相应的计数器会增加。

enable
boolean
Default: true

启用或禁用规则引擎

description
string
Default: ""

规则的描述

metadata
object

规则的元数据,不要手动修改

Responses

Request samples

Content type
application/json
{
  • "name": "foo",
  • "sql": "SELECT * FROM \"test/topic\" WHERE payload.x = 1",
  • "actions": [
    ],
  • "enable": true,
  • "description": "Some description",
  • "metadata": { }
}

Response samples

Content type
application/json
{
  • "id": "293fb66f",
  • "from": "t/#",
  • "created_at": "2021-12-01T15:00:43.153+08:00",
  • "name": "foo",
  • "sql": "SELECT * FROM \"test/topic\" WHERE payload.x = 1",
  • "actions": [
    ],
  • "enable": true,
  • "description": "Some description",
  • "metadata": { }
}

Get rule metrics

通过给定的 Id 获得规则的指标数据

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: my_rule_id

Responses

Response samples

Content type
application/json
{
  • "id": "293fb66f",
  • "metrics": {
    },
  • "node_metrics": [
    ]
}

List rule events

列出所有能被规则使用的事件

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
{
  • "event": "$events/client_connected",
  • "title": "some title",
  • "description": "some desc",
  • "columns": { },
  • "test_columns": { },
  • "sql_example": "string"
}

Reset rule metrics

重置规则计数

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: my_rule_id

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

Get rule

通过 ID 查询规则

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: my_rule_id

Responses

Response samples

Content type
application/json
{
  • "id": "293fb66f",
  • "from": "t/#",
  • "created_at": "2021-12-01T15:00:43.153+08:00",
  • "name": "foo",
  • "sql": "SELECT * FROM \"test/topic\" WHERE payload.x = 1",
  • "actions": [
    ],
  • "enable": true,
  • "description": "Some description",
  • "metadata": { }
}

Update rule

通过 ID 更新集群里所有节点上的规则

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: my_rule_id
Request Body schema: application/json
name
string
Default: ""

规则名字

sql
required
string

用于处理消息的 SQL 。
示例:SELECT * FROM "test/topic" WHERE payload.x = 1

Array of rule_engine.user_provided_function (object) or rule_engine.builtin_action_console (object) or rule_engine.builtin_action_republish (object) or strings
Default: []

规则的动作列表。
动作可以是指向 EMQX 数据桥接的引用,也可以是一个指向函数的对象。
我们支持一些内置函数,如“republish”和“console”,我们还支持用户提供的函数,它的格式为:“{module}:{function}”。
列表中的动作按顺序执行。这意味着如果其中一个动作执行缓慢,则以下所有动作都不会被执行直到它返回。
如果其中一个动作崩溃,在它之后的所有动作仍然会被按照原始顺序执行。
如果运行动作时出现任何错误,则会出现错误消息,并且相应的计数器会增加。

enable
boolean
Default: true

启用或禁用规则引擎

description
string
Default: ""

规则的描述

metadata
object

规则的元数据,不要手动修改

Responses

Request samples

Content type
application/json
{
  • "name": "foo",
  • "sql": "SELECT * FROM \"test/topic\" WHERE payload.x = 1",
  • "actions": [
    ],
  • "enable": true,
  • "description": "Some description",
  • "metadata": { }
}

Response samples

Content type
application/json
{
  • "id": "293fb66f",
  • "from": "t/#",
  • "created_at": "2021-12-01T15:00:43.153+08:00",
  • "name": "foo",
  • "sql": "SELECT * FROM \"test/topic\" WHERE payload.x = 1",
  • "actions": [
    ],
  • "enable": true,
  • "description": "Some description",
  • "metadata": { }
}

Delete rule

通过 ID 删除集群里所有节点上的规则

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: my_rule_id

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

Actions

Reset action metrics

通过 id 重置数据桥接指标。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

Manually start a bridge

启用集群中所有节点上的数据桥接。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

operation
required
string
Value: "start"
Example: start

集群可用操作:'启动'。

Responses

Response samples

Content type
application/json
{
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Enable or disable bridge

启用或禁用集群内所有节点上的数据桥接。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

enable
required
boolean
Example: true

是否启用该数据桥接。

Responses

Response samples

Content type
application/json
{
  • "code": "NOT_FOUND",
  • "message": "string"
}

List bridges

列出所有创建的数据桥接。

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    },
  • {
    }
]

Create bridge

通过类型和名称创建一个新的数据桥接。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
One of
type
required
string
Value: "timescale"

Bridge 类型

name
required
string

桥接名字

local_topic
string

MQTT 主题或主题过滤器作为数据源(动作输入)。 如果规则动作用作数据源,则应将此配置留空,否则消息将在远程系统中重复。

enable
boolean
Default: true

启用(是)或停用(否)此动作。

connector
required
string

由动作指定的连接器名称,用于选择外部资源。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

required
object (bridge_pgsql.action_parameters)
object (actions_and_sources.action_resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "name": "my_azure_event_hub_producer_action",
  • "type": "azure_event_hub_producer",
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "local_topic": "mqtt/local/topic"
}

Response samples

Content type
application/json
Example
{
  • "name": "my_azure_event_hub_producer_action",
  • "status": "connected",
  • "type": "azure_event_hub_producer",
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "node_status": [
    ],
  • "local_topic": "mqtt/local/topic"
}

Test creating bridge

测试创建一个新的数据桥接。

Authorizations:
basicAuthbearerAuth
Request Body schema: application/json
One of
type
required
string
Value: "timescale"

Bridge 类型

name
required
string

桥接名字

local_topic
string

MQTT 主题或主题过滤器作为数据源(动作输入)。 如果规则动作用作数据源,则应将此配置留空,否则消息将在远程系统中重复。

enable
boolean
Default: true

启用(是)或停用(否)此动作。

connector
required
string

由动作指定的连接器名称,用于选择外部资源。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

required
object (bridge_pgsql.action_parameters)
object (actions_and_sources.action_resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "name": "my_azure_event_hub_producer_action",
  • "type": "azure_event_hub_producer",
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "local_topic": "mqtt/local/topic"
}

Response samples

Content type
application/json
{
  • "code": "TEST_FAILED",
  • "message": "string"
}

List available action types

列出所有可用的动作类型。

Authorizations:
basicAuthbearerAuth

Responses

Response samples

Content type
application/json
[
  • "http",
  • "rocketmq",
  • "cassandra",
  • "rabbitmq",
  • "pulsar",
  • "greptimedb",
  • "hstreamdb",
  • "influxdb",
  • "mongodb",
  • "azure_event_hub_producer",
  • "confluent_producer",
  • "gcp_pubsub_producer",
  • "iotdb",
  • "kafka_producer",
  • "sqlserver",
  • "syskeeper_forwarder",
  • "kinesis",
  • "opents",
  • "redis",
  • "s3",
  • "mqtt",
  • "clickhouse",
  • "tdengine",
  • "oracle",
  • "timescale",
  • "elasticsearch",
  • "matrix",
  • "mysql",
  • "pgsql",
  • "dynamo"
]

Get bridge

通过 id 获取一个数据桥接

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

Responses

Response samples

Content type
application/json
Example
{
  • "name": "my_azure_event_hub_producer_action",
  • "status": "connected",
  • "type": "azure_event_hub_producer",
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "node_status": [
    ],
  • "local_topic": "mqtt/local/topic"
}

Update bridge

通过 id 更新数据桥接

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

Request Body schema: application/json
One of
local_topic
string

MQTT 主题或主题过滤器作为数据源(动作输入)。 如果规则动作用作数据源,则应将此配置留空,否则消息将在远程系统中重复。

enable
boolean
Default: true

启用(是)或停用(否)此动作。

connector
required
string

由动作指定的连接器名称,用于选择外部资源。

tags
Array of strings

连接器的标签

description
string
Default: ""

描述性文本。

required
object (bridge_pgsql.action_parameters)
object (actions_and_sources.action_resource_opts)

Responses

Request samples

Content type
application/json
Example
{
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "local_topic": "mqtt/local/topic"
}

Response samples

Content type
application/json
Example
{
  • "name": "my_azure_event_hub_producer_action",
  • "status": "connected",
  • "type": "azure_event_hub_producer",
  • "enable": true,
  • "parameters": {
    },
  • "connector": "my_azure_event_hub_producer_connector",
  • "node_status": [
    ],
  • "local_topic": "mqtt/local/topic"
}

Delete bridge

通过 id 删除数据桥接

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

query Parameters
also_delete_dep_actions
boolean
Default: false

是否级联删除依赖的动作。

Responses

Response samples

Content type
application/json
{
  • "rules": [
    ],
  • "code": "BAD_REQUEST",
  • "message": "string"
}

Get action metrics

通过 id 来获取数据桥接的指标信息。

Authorizations:
basicAuthbearerAuth
path Parameters
id
required
string
Example: http:my_http_action

数据桥接 ID,格式必须为 {type}:{name}。

Responses

Response samples

Content type
application/json
{
  • "metrics": {
    },
  • "node_metrics": [
    ]
}

Monitor

Prometheus metrics

Prometheus metrics

Responses

Prometheus metrics about data integration

Prometheus metrics about data integration

Responses