Batch Create Channels
Legacy API Endpoint Batch Create Channels (Legacy)
Notes on Upgrading from Legacy API to New API
- When creating a channel using the old API, you can directly set the channel's basic information, viewing conditions, replay settings, instructor settings, and role settings.
- When creating a channel using the new API, you can only set the channel's basic information. Viewing conditions, replay settings, instructor settings, and role settings are derived from the default template settings. The default template must be configured before creating a channel.
- Modifications to the default template will not affect already created channels. Changes to the information of existing channels are consistent with the old API.
Interface Description
1、批量创建频道
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/live/v4/channel/create-batch
<a href="/req.html?api=http://api.polyv.net/live/v4/channel/create-batch"" target="_blank">Online API Call
Request Method
POST
Interface Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. Interface calls are subject to frequency limits. For details, please refer to.
When the live streaming scenario is a dual-teacher class or seminar, the relay type setting is not supported; when the live streaming delay is set to no delay, the relay type setting is not supported.
When the live streaming scenario is a seminar, live streaming delay, rebroadcasting, and the number of co-hosts settings are not supported.
In the seminar scenario, the host password and participant password must not be the same.
Create up to 30 channels at a time;
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details in "Get Secret Key" |
| timestamp | true | Long | Current 13-digit millisecond-level timestamp, valid within 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved or used directly on the client side. All APIs must be called through the customer's own server as an intermediary to request response data from the POLYV server. See details in "Signature Generation Rules" |
Request Body Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| name | true | String | Live stream name, maximum length 100 |
| newScene | true | String | Live stream scenario topclass (Large class) double (Dual-teacher class, requires activation) train (Enterprise training) alone (Event marketing) seminar (Seminar) guide (Director mode, requires activation) smallclass (Small class) |
| template | true | String | Live stream template ppt (Tri-screen landscape) portrait_ppt (Tri-screen portrait) alone (Video only landscape) portrait_alone (Video only portrait) topclass (Video only express landscape) portrait_topclass (Video only express portrait) seminar (Seminar) Field constraints: When the live stream scenario (newScene field) is topclass (Large class), supported values: ppt (Tri-screen landscape), portrait_ppt (Tri-screen portrait), alone (Video only landscape), portrait_alone (Video only portrait), topclass (Video only express landscape), portrait_topclass (Video only express portrait) When the live stream scenario (newScene field) is train (Enterprise training) or alone (Event marketing), supported values: ppt (Tri-screen landscape), portrait_ppt (Tri-screen portrait), alone (Video only landscape), portrait_alone (Video only portrait) When the live stream scenario (newScene field) is double (Dual-teacher class), supported values: ppt (Tri-screen landscape), alone (Video only landscape) When the live stream scenario (newScene field) is seminar (Seminar), supported value: seminar (Seminar) When the live stream scenario (newScene field) is guide (Director mode), supported values: alone (Video only landscape), portrait_alone (Video only portrait) |
| channelPasswd | false | String | Instructor login password, valid when the live stream scenario is not a seminar. Length 6-16 characters. If not provided, the system generates a random one. (The API allows setting pure numbers or pure letters. For editing in the live stream backend, it is recommended to include both numbers and letters.) |
| seminarHostPassword | false | String | Seminar host password, valid only when the live stream scenario is a seminar. Length 6-16 characters. If not provided, the system generates a random one. The host password and attendee password must be different. (The API allows setting pure numbers or pure letters. For editing in the live stream backend, it is recommended to include both numbers and letters.) |
| seminarAttendeePassword | false | String | Seminar attendee password, valid only when the live stream scenario is a seminar. Length 6-16 characters. If not provided, the system generates a random one. The host password and attendee password must be different. (The API allows setting pure numbers or pure letters. For editing in the live stream backend, it is recommended to include both numbers and letters.) |
| pureRtcEnabled | false | String | Live stream latency: Y for no latency, N for normal latency |
| type | false | String | Rebroadcast type: normal (disabled), transmit (initiate rebroadcast), receive (receive rebroadcast, requires activation). Some live stream scenarios do not support rebroadcast settings. Please refer to the interface constraints for details. |
| doubleTeacherType | false | String | Online dual-teacher: transmit (large room), receive (small room) |
| cnAndEnLiveEnabled | false | String | Bilingual (Chinese/English) live stream switch: Y for on, N for off |
| splashImg | false | String | Splash page image URL. For images not hosted on the Polyv domain, upload them first via Upload all channel decoration image materials. |
| linkMicLimit | false | Integer | Maximum number of participants for co-streaming, up to 16. Set to 0 to disable co-streaming. If empty, defaults to the account's maximum co-streaming limit (modifiable by contacting business support). |
| categoryId | false | Integer | Category ID, obtainable via the "Query live stream categories" interface. |
| startTime | false | Long | Start time, timestamp, e.g., 1629734400000 [Note: Only used for countdown display before the live stream; does not affect the instructor's ability to start broadcasting.] |
| endTime | false | Long | End time, timestamp, e.g., 1629845600000 [Note: Only used for displaying the live stream status before it starts; does not affect the instructor's ability to start broadcasting.] |
| subAccount | false | String | Sub-account email. If filled, the channel will be created under this sub-account (the sub-account must not be deleted or disabled). Currently, it cannot be retrieved via the API. |
| customTeacherId | false | String | Custom instructor ID, up to 32 visible ASCII characters. |
| smallClassSizeLimit | false | Integer | Small class size limit. Required only when the live stream scenario is a small class. Optional values: 1, 6, 12. |
| isRecord | false | String | Small class recording switch. Valid only when the live stream scenario is a small class. Y: Enable, N: Disable. Defaults to disabled if not provided. |
Example
http://api.polyv.net/live/v4/channel/create-batch?appId=frlr1zazn3&sign=FD701BFA3DCE2C7DCC362A904DBF48B0×tamp=1636536555144
Request body JSON parameters:
[
{
"name": "研讨会",
"newScene": "seminar",
"pureRtcEnabled": "Y",
"categoryId": 391352,
"seminarHostPassword": "",
"seminarAttendeePassword": ""
},
{
"name": "我的频道-子账号",
"newScene": "topclass",
"template": "ppt",
"pureRtcEnabled": "Y",
"subAccount": "sdk-demo@polyv.net",
"channelPasswd": "",
"categoryId": 391352
}
]
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | |
| status | String | |
| requestId | String | |
| error | Error | |
| data | List |
See data field description |
data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| element | ChannelVO | See element field description |
element parameter description
| Parameter | Type | Description |
|---|---|---|
| channelId | Integer | Channel ID |
| userId | String | Verification information |
| scene | String | Live streaming scenario |
| channelPasswd | String | Instructor login password, used in non-seminar scenarios, length 6-16 characters |
| seminarHostPassword | String | Seminar host password, returned only when the live streaming scenario is a seminar, length 6-16 characters |
| seminarAttendeePassword | String | Seminar attendee password, returned only when the live streaming scenario is a seminar, length 6-16 characters |
Java Request Example
For quick integration of the basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source code project. The test cases HttpUtil.java and LiveSignUtil.java are both included in the downloaded file.
It is strongly recommended that you use the Live Java SDK to complete the API functionality integration. The Live Java SDK provides a unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(getClass());
@Test
public void testCreateBatchV4() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/create-batch";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String body = "[{\"name\":\"研讨会\",\"newScene\":\"seminar\",\"pureRtcEnabled\":\"Y\",\"categoryId\":391352," +
"\"seminarHostPassword\":\"aaaaaa\",\"seminarAttendeePassword\":\"bbbbbb\"},{\"name\":\"我的频道-子账号\"," +
"\"newScene\":\"topclass\",\"template\":\"ppt\",\"pureRtcEnabled\":\"Y\",\"subAccount\":\"sdk-demo@polyv" +
".net\",\"channelPasswd\":\"123fds\",\"categoryId\":391352}]";
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url,body,null);
log.info("测试批量创建频道,返回值:{}", response);
//do somethings
}
Response Example
For a detailed explanation of system-wide errors, please refer to the Global Error Description.
Successful Example
{
"code": 200,
"status": "success",
"requestId": "62af5d29-a836-4bfb-8c4d-cbd6a84ea7e9",
"data": [
{
"channelId": 2665205,
"userId": "1b448be323",
"scene": null,
"channelPasswd": null,
"seminarHostPassword": "aaaaaa",
"seminarAttendeePassword": "bbbbbb"
},
{
"channelId": 2665206,
"userId": "1b448be323",
"scene": null,
"channelPasswd": "123fds",
"seminarHostPassword": null,
"seminarAttendeePassword": null
}
],
"success": true
}
Exception Example
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
