Skip to content

/api/broadcast

getChannelInfo

  • 🛠 获取指定消息通道的信息
  • /api/broadcast/getChannelInfo

请求

ts
/**
 * Get the information of specified broadcast channel
 */
export interface IPayload {
    /**
     * broadcast channel name
     */
    readonly name: string;
}
json5
/**
 * schemas/kernel/api/broadcast/getChannelInfo/payload.schema.json5
 * 获取指定频道的信息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.2/kernel/api/broadcast.go#L169-L198
 * @pathname: /api/broadcast/getChannelInfo
 * @version: 2.10.2
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannelInfo/payload.schema.json5',
    $comment: 'v2.10.2',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Get the information of specified broadcast channel',

            type: 'object',
            additionalProperties: false,
            required: [
                'name',
            ],
            properties: {
                name: {
                    // 广播通道名称
                    type: 'string',
                    description: 'broadcast channel name',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannelInfo/payload.schema.json",
    "$comment": "v2.10.2",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Get the information of specified broadcast channel",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "name"
            ],
            "properties": {
                "name": {
                    "type": "string",
                    "description": "broadcast channel name"
                }
            }
        }
    }
}

响应

ts
/**
 * Get the information of specified broadcast channel
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * response data
 */
export interface IData {
    readonly channel: IChannel;
}

/**
 * channel object
 */
export interface IChannel {
    /**
     * The count of broadcast channel listener
     */
    readonly count: number;
    /**
     * channel name
     */
    readonly name: string;
}
json5
/**
 * schemas/kernel/api/broadcast/getChannelInfo/response.schema.json5
 * 获取指定频道的信息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.2/kernel/api/broadcast.go#L169-L198
 * @pathname: /api/broadcast/getChannelInfo
 * @version: 2.10.2
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannelInfo/response.schema.json5',
    $comment: 'v2.10.2',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get the information of specified broadcast channel',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'response data',

            type: 'object',
            additionalProperties: false,
            required: [
                'channel',
            ],
            properties: {
                channel: {
                    $ref: '#/$defs/channel',
                },
            },
        },
        channel: {
            title: 'IChannel',
            description: 'channel object',

            type: 'object',
            additionalProperties: false,
            required: [
                'name',
                'count',
            ],
            properties: {
                name: {
                    // 频道名称
                    type: 'string',
                    description: 'channel name',
                },
                count: {
                    // 频道收听者数量
                    type: 'integer',
                    description: 'The count of broadcast channel listener',
                    minimum: 0,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannelInfo/response.schema.json",
    "$comment": "v2.10.2",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get the information of specified broadcast channel",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "response data",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "channel"
            ],
            "properties": {
                "channel": {
                    "$ref": "#/$defs/channel"
                }
            }
        },
        "channel": {
            "title": "IChannel",
            "description": "channel object",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "name",
                "count"
            ],
            "properties": {
                "name": {
                    "type": "string",
                    "description": "channel name"
                },
                "count": {
                    "type": "integer",
                    "description": "The count of broadcast channel listener",
                    "minimum": 0
                }
            }
        }
    }
}

getChannels

  • 🛠 获取当前所有消息通道的信息
  • /api/broadcast/getChannels

响应

ts
/**
 * Get all broadcast channels
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * response data
 */
export interface IData {
    /**
     * channels list
     */
    readonly channels: IChannel[];
}

/**
 * channel object
 */
export interface IChannel {
    /**
     * The count of broadcast channel listener
     */
    readonly count: number;
    /**
     * channel name
     */
    readonly name: string;
}
json5
/**
 * schemas/kernel/api/broadcast/getChannels/response.schema.json5
 * 获取当前所有广播频道
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.11.0/kernel/api/broadcast.go#L210-L226
 * @pathname: /api/broadcast/getChannels
 * @version: 2.11.0
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannels/response.schema.json5',
    $comment: 'v2.11.0',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Get all broadcast channels',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'response data',

            type: 'object',
            additionalProperties: false,
            required: [
                'channels',
            ],
            properties: {
                channels: {
                    title: 'IChannels',
                    description: 'channels list',
                    type: 'array',
                    items: {
                        $ref: '#/$defs/channel',
                    },
                },
            },
        },
        channel: {
            title: 'IChannel',
            description: 'channel object',

            type: 'object',
            additionalProperties: false,
            required: [
                'name',
                'count',
            ],
            properties: {
                name: {
                    // 名称
                    type: 'string',
                    description: 'channel name',
                },
                count: {
                    // 频道收听者数量
                    type: 'integer',
                    description: 'The count of broadcast channel listener',
                    minimum: 0,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/getChannels/response.schema.json",
    "$comment": "v2.11.0",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Get all broadcast channels",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "response data",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "channels"
            ],
            "properties": {
                "channels": {
                    "title": "IChannels",
                    "description": "channels list",
                    "type": "array",
                    "items": {
                        "$ref": "#/$defs/channel"
                    }
                }
            }
        },
        "channel": {
            "title": "IChannel",
            "description": "channel object",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "name",
                "count"
            ],
            "properties": {
                "name": {
                    "type": "string",
                    "description": "channel name"
                },
                "count": {
                    "type": "integer",
                    "description": "The count of broadcast channel listener",
                    "minimum": 0
                }
            }
        }
    }
}

postMessage

  • 🛠 向指定消息通道推送消息
  • /api/broadcast/postMessage

请求

ts
/**
 * Push broadcast messages to specified channel
 */
export interface IPayload {
    /**
     * broadcast channel name
     */
    readonly channel: string;
    /**
     * broadcast message
     */
    readonly message: string;
}
json5
/**
 * schemas/kernel/api/broadcast/postMessage/payload.schema.json5
 * 向指定频道推送广播消息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.2/kernel/api/broadcast.go#L119-L156
 * @pathname: /api/broadcast/postMessage
 * @version: 2.10.2
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/postMessage/payload.schema.json5',
    $comment: 'v2.10.2',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'payload body',
            description: 'Push broadcast messages to specified channel',

            type: 'object',
            additionalProperties: false,
            required: [
                'channel',
                'message',
            ],
            properties: {
                channel: {
                    // 广播通道名称
                    type: 'string',
                    description: 'broadcast channel name',
                },
                message: {
                    // 广播消息
                    type: 'string',
                    description: 'broadcast message',
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/postMessage/payload.schema.json",
    "$comment": "v2.10.2",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "payload body",
            "description": "Push broadcast messages to specified channel",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "channel",
                "message"
            ],
            "properties": {
                "channel": {
                    "type": "string",
                    "description": "broadcast channel name"
                },
                "message": {
                    "type": "string",
                    "description": "broadcast message"
                }
            }
        }
    }
}

响应

ts
/**
 * Push broadcast messages to specified channel
 */
export interface IResponse {
    /**
     * status code
     */
    readonly code: number;
    readonly data: IData;
    /**
     * status message
     */
    readonly msg: string;
}

/**
 * response data
 */
export interface IData {
    readonly channel: IChannel;
}

/**
 * channel object
 */
export interface IChannel {
    /**
     * The count of broadcast channel listener
     */
    readonly count: number;
    /**
     * channel name
     */
    readonly name: string;
}
json5
/**
 * schemas/kernel/api/broadcast/postMessage/response.schema.json5
 * 向指定频道推送广播消息
 * REF: https://github.com/siyuan-note/siyuan/blob/v2.10.2/kernel/api/broadcast.go#L119-L156
 * @pathname: /api/broadcast/postMessage
 * @version: 2.10.2
 */
{
    $schema: 'https://json-schema.org/draft/2020-12/schema',
    $id: 'https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/postMessage/response.schema.json5',
    $comment: 'v2.10.2',
    $ref: '#/$defs/root',
    $defs: {
        root: {
            title: 'response body',
            description: 'Push broadcast messages to specified channel',

            type: 'object',
            additionalProperties: false,
            required: [
                'code',
                'msg',
                'data',
            ],
            properties: {
                code: {
                    type: 'integer',
                    description: 'status code',
                },
                msg: {
                    type: 'string',
                    description: 'status message',
                },
                data: {
                    $ref: '#/$defs/data',
                },
            },
        },
        data: {
            title: 'IData',
            description: 'response data',

            type: 'object',
            additionalProperties: false,
            required: [
                'channel',
            ],
            properties: {
                channel: {
                    $ref: '#/$defs/channel',
                },
            },
        },
        channel: {
            title: 'IChannel',
            description: 'channel object',

            type: 'object',
            additionalProperties: false,
            required: [
                'name',
                'count',
            ],
            properties: {
                name: {
                    // 名称
                    type: 'string',
                    description: 'channel name',
                },
                count: {
                    // 频道收听者数量
                    type: 'integer',
                    description: 'The count of broadcast channel listener',
                    minimum: 0,
                },
            },
        },
    },
}
json
{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://github.com/siyuan-community/siyuan-sdk/raw/main/schemas/kernel/api/broadcast/postMessage/response.schema.json",
    "$comment": "v2.10.2",
    "$ref": "#/$defs/root",
    "$defs": {
        "root": {
            "title": "response body",
            "description": "Push broadcast messages to specified channel",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "code",
                "msg",
                "data"
            ],
            "properties": {
                "code": {
                    "type": "integer",
                    "description": "status code"
                },
                "msg": {
                    "type": "string",
                    "description": "status message"
                },
                "data": {
                    "$ref": "#/$defs/data"
                }
            }
        },
        "data": {
            "title": "IData",
            "description": "response data",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "channel"
            ],
            "properties": {
                "channel": {
                    "$ref": "#/$defs/channel"
                }
            }
        },
        "channel": {
            "title": "IChannel",
            "description": "channel object",
            "type": "object",
            "additionalProperties": false,
            "required": [
                "name",
                "count"
            ],
            "properties": {
                "name": {
                    "type": "string",
                    "description": "channel name"
                },
                "count": {
                    "type": "integer",
                    "description": "The count of broadcast channel listener",
                    "minimum": 0
                }
            }
        }
    }
}