Create Channel
Old API endpoint Create Single Channel (Old Version)
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 do not affect already created channels. Changes to existing channel information are consistent with the old API.
- The live streaming scenario (scene) in the old API corresponds to the live streaming template (template) in this API. Since the old API does not have the concept of a scenario (newScene field), after upgrading from the old to the new version, channels created using the old API will display "undefined" for the scenario in the new live streaming backend, which has no impact on the data.
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
<a href="/req.html?api=http://api.polyv.net/live/v4/channel/create"" 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 webinar, live 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.
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 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 obtain 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) |
| smallClassSizeLimit | false | Integer | Small class size, optional values: 1, 6, 12 |
| isRecord | false | String | Small class recording toggle (Y/N, default: N) |
| newSessionEnabled | false | String | Series live stream toggle, Y: Series live stream, N: Normal live stream. Default: N |
| template | true | String | Live stream template ppt (Three-screen landscape) portrait_ppt (Three-screen portrait) alone (Pure video landscape) portrait_alone (Pure video portrait) topclass (Pure video fast landscape) portrait_topclass (Pure video fast portrait) seminar (Seminar) Field constraints: When the live stream scenario (newScene field) is topclass (Large class), supported fields: ppt (Three-screen landscape), portrait_ppt (Three-screen portrait), alone (Pure video landscape), portrait_alone (Pure video portrait), topclass (Pure video fast landscape), portrait_topclass (Pure video fast portrait) When the live stream scenario (newScene field) is train (Enterprise training) or alone (Event marketing), supported fields: ppt (Three-screen landscape), portrait_ppt (Three-screen portrait), alone (Pure video landscape), portrait_alone (Pure video portrait) When the live stream scenario (newScene field) is double (Dual-teacher class), supported fields: ppt (Three-screen landscape), alone (Pure video landscape) When the live stream scenario (newScene field) is seminar (Seminar), supported field: seminar (Seminar) When the live stream scenario (newScene field) is guide (Director mode), supported fields: alone (Pure video landscape), portrait_alone (Pure video 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 will generate one randomly. (The API allows setting pure numbers or pure letters; if editing in the live stream backend, it is recommended to include both numbers and letters) |
| seminarHostPassword | false | String | Seminar host password, only valid when the live stream scenario is a seminar, length 6-16 characters. If not provided, the system will generate one randomly. The seminar host password and attendee password must not be the same. (The API allows setting pure numbers or pure letters; if editing in the live stream backend, it is recommended to include both numbers and letters) |
| seminarAttendeePassword | false | String | Seminar attendee password, only valid when the live stream scenario is a seminar, length 6-16 characters. If not provided, the system will generate one randomly. The seminar host password and attendee password must not be the same. (The API allows setting pure numbers or pure letters; if 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 | Relay type: normal (not enabled), transmit (initiate relay), receive (receive relay) (requires activation). Some live stream scenarios do not support relay 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 live stream toggle: Y for on, N for off. When set to Y, it only takes effect when newScene is train/alone, template is alone, and pureRtcEnabled is N. |
| splashImg | false | String | Splash image URL. For images not under the Polyv domain, first call Upload all channel decoration image materials to upload. |
| linkMicLimit | false | Integer | Maximum number of participants in co-streaming, up to 16. A value of 0 disables co-streaming. If this field is empty, the account's maximum co-streaming number (modifiable by contacting sales) will be used by default. |
| 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 start operation.] |
| endTime | false | Long | End time, timestamp, e.g., 1629845600000 [Note: Only used for determining the live stream status display before it starts; does not affect the instructor's start operation.] |
| subAccount | false | String | Sub-account email. If filled, the channel will be created under this sub-account (the sub-account cannot be deleted or disabled). Currently, it cannot be retrieved via the API. |
| customTeacherId | false | String | Custom instructor ID, up to 32 visible ASCII characters. |
| labelData | false | Array | Array of label IDs. |
| clientAloneTemplateBackgroundUrl | false | String | Client template background image URL. |
| liveCdnBackgroundUrl | false | String | Video mixing background image URL. |
| h5LowLatencyFlvEnabled | false | String | Low latency toggle for mobile H5 viewing page, Y for enabled, N for disabled. |
Example
http://api.polyv.net/live/v4/channel/create?appId=frlr1zazn3&sign=E3F501CFEF5FCCF2DF9BFDCE9C91F48C×tamp=1629445373947
Request body JSON parameters:
{
"template": "ppt",
"doubleTeacherType": "normal",
"name": "polyv小课堂",
"startTime": "1779254040000",
"newScene": "topclass",
"newSessionEnabled": "Y",
"type": "normal",
"pureRtcEnabled": "Y",
"linkMicLimit": "6",
"labelData":[]
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by the business. Returns success on success, error on failure |
| success | Boolean | Whether the response was successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only for troubleshooting and debugging; should not be tied to business logic |
| data | Object | Channel response object [see data field description for details] |
| error | Object | Error information [see data field description for details] |
Data Parameter Description
| Parameter Name | Type | Description |
|---|---|---|
| channelId | Integer | Channel ID |
| userId | String | POLYV user ID, consistent with the one on the Polyv official website. Retrieval path: Official website -> Login -> Live Streaming (Development Settings) |
| channelPasswd | String | Lecturer login password. Not null when the live streaming scenario is not a seminar. Length: 6-16 characters |
| seminarHostPassword | String | Seminar host password. Not null only when the live streaming scenario is a seminar. Length: 6-16 characters |
| seminarAttendeePassword | String | Seminar attendee password. Not null 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.
/**
* 创建单个频道
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testBasicCreateV4() 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";
String name = "polyv小课堂";
String newScene = "topclass";
String template = "ppt";
String pureRtcEnabled = "Y";
String type = "normal";
String doubleTeacherType = "normal";
String cnAndEnLiveEnabled = "N";
String linkMicLimit = "5";
String categoryId = "";
Long startTime = new Date().getTime() + 30 * 60 * 1000l;
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, String> bodyMap = new HashMap<>();
bodyMap.put("name", name);
bodyMap.put("newScene", newScene);
bodyMap.put("template", template);
bodyMap.put("pureRtcEnabled", pureRtcEnabled);
bodyMap.put("type", type);
bodyMap.put("doubleTeacherType", doubleTeacherType);
bodyMap.put("cnAndEnLiveEnabled", cnAndEnLiveEnabled);
bodyMap.put("linkMicLimit", linkMicLimit);
// bodyMap.put("categoryId", categoryId);
bodyMap.put("channelPasswd", "Y2KRyUauSITWv");
// bodyMap.put("seminarHostPassword", "lLnAtoeNfAID3");
// bodyMap.put("seminarAttendeePassword", "cpoonjki9CRBh");
bodyMap.put("startTime", String.valueOf(startTime));
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String body = JSON.toJSONString(bodyMap);
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, see Global Error Description.
Successful Example
{
"code": 200,
"status": "success",
"requestId": "847f0716fa76461baf8979aaa4415dc3.67.16342672396023837",
"data": {
"channelId": 2614804,
"userId": "1b448be323",
"scene": null,
"channelPasswd": "jvO3RbFTKE61A",
"seminarHostPassword": null,
"seminarAttendeePassword": null
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
