Batch Create Relay Subchannel API
Updated: 2022-09-02 18:08:07
API URL
http://api.polyv.net/live/v3/channel/transmit/batch-create
API Description
1、批量创建转播子频道
2、一次性最大支持创建100个子频道,转播子频道上限500个
3、接口支持https
Supported Format
JSON
Request Method
POST
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | Yes | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored or used directly on the client. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See Signature Generation Rules for details. |
| channelId | Yes | int | The initiating relay channel ID |
Request Body Parameters
The request body parameters are a string array. The string values are the names of the relay receiving channels to be created. A maximum of 100 channels can be created in a single request. The request parameters above must be placed in the query string or form data. The request body parameters must be placed in the request body. They are not supported in query strings or form data.
[
"接收转播频道01",
"接收转播频道02",
"接收转播频道03",
"接收转播频道04"
]
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"channelId": 2041139,
"name": "接收转播频道01",
"channelPasswd": "xxxx",
"authType": "none",
"streamType": "client",
"debugEnabled": "N",
"playBackEnabled": "Y",
"stream": "ee7fe7fbda1607414643915af33",
"status": "客户端推流/直播结束",
"categoryId": 177474,
"categoryName": "默认分类",
"isSmallClass": "N",
"scene": "ppt",
"createdTime": 1607414644000,
"appId": null,
"coverImage": null,
"type": "receive",
"startTime": 1598630400000,
"publisher": "666666",
"channelLogo": null,
"splashImg": null,
"splashEnabled": "Y",
"pureRtcEnabled": "N",
"watchTimes": null,
"roomIds": null
},
{
"channelId": 2041140,
"name": "接收转播频道02",
"channelPasswd": "xxxx",
"authType": "none",
"streamType": "client",
"debugEnabled": "N",
"playBackEnabled": "Y",
"stream": "ee7fe7fbda160741464391432a6",
"status": "客户端推流/直播结束",
"categoryId": 177474,
"categoryName": "默认分类",
"isSmallClass": "N",
"scene": "ppt",
"createdTime": 1607414644000,
"appId": null,
"coverImage": null,
"type": "receive",
"startTime": 1598630400000,
"publisher": "666666",
"channelLogo": null,
"splashImg": null,
"splashEnabled": "Y",
"pureRtcEnabled": "N",
"watchTimes": null,
"roomIds": null
}
]
}
Failed Response JSON Examples:
No appId provided
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
Incorrect appId
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
Timestamp error
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
Signature error
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Invalid channel
{
"code": 403,
"status": "error",
"message": "illegal channel id: 1779742",
"data": ""
}
No parameters in request body
{
"code": 400,
"status": "error",
"message": "request body is not empty or lost params",
"data": ""
}
Request body array exceeds 100
{
"code": 400,
"status": "error",
"message": "param length is incorrect:body array size",
"data": ""
}
Relay subchannels exceed 500
{
"code": 400,
"status": "error",
"message": "transmit channel number limit: 500",
"data": ""
}
Relay not enabled
{
"code": 400,
"status": "error",
"message": "access forbidden",
"data": ""
}
Channel count exceeds limit
{
"code": 400,
"status": "error",
"message": "channel count reached the limit",
"data": ""
}
Field Description
| Parameter | Type | Description |
|---|---|---|
| code | int | Response code: 200 for success, 400 for failure, 401 for signature error, 500 for server error |
| status | string | "success" for success, "error" for failure |
| message | string | Error message when applicable |
| data | array | Response result set |
| data[0].channelId | int | Channel ID |
| data[0].name | string | Channel name |
| data[0].channelPasswd | string | Channel password |
| data[0].authType | string | Channel authentication type |
| data[0].playBackEnabled | string | Whether playback is enabled: Y (enabled), N (disabled) |
| data[0].streamType | string | Channel streaming method |
| data[0].debugEnabled | string | Whether debug mode is enabled: Y (enabled), N (disabled) |
| data[0].stream | string | Channel stream name |
| data[0].status | string | Channel status |
| data[0].categoryId | int | Channel category ID |
| data[0].categoryName | string | Channel category name |
| data[0].isSmallClass | string | Whether it is a small class: Y (enabled), N (disabled) |
| data[0].scene | string | Channel scene: ppt (three-screen), alone (live event), topclass (large class), seminar |
| data[0].createdTime | long | Channel creation time |
| data[0].appId | string | Temporarily not returned: null |
| data[0].coverImage | string | Channel cover image |
| data[0].type | string | Channel type: transmit (initiating relay), normal (regular channel), receive (receiving relay) |
| data[0].startTime | long | Channel start time |
| data[0].publisher | string | Channel host |
| data[0].channelLogo | string | Temporarily not returned: null |
| data[0].splashImg | string | Channel splash screen image URL |
| data[0].splashEnabled | string | Splash screen toggle: Y (enabled), N (disabled) |
| data[0].pureRtcEnabled | string | No-delay live streaming toggle: Y (enabled), N (disabled) |
| data[0].watchTimes | string | Temporarily not returned: null |
| data[0].roomIds | string | Channel sub-room information, null if none |
Java Request Example
public static void main(String[] args) {
String url = "http://api.polyv.net/live/v3/channel/transmit/batch-create";
// 用户对应的appId和加密串
String appId = "xxxxxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
Map<String, String> params = new HashMap<>();
params.put("channelId", "0000000");
PolyvTool.setLiveSign(params, appId, appSecret);
// 调用Polyv的httpClient工具类发送请求
String body = "[\"接收转播频道01\",\"接收转播频道02\"]";
// 调用Polyv的httpClient工具类发送请求
String content = HttpClientUtil.getInstance()
.sendHttpPostJson(url + "?" + PolyvTool.mapJoinNotEncode(params), body, null);
System.out.println(content);
}
