Create and Initialize a Channel
Old API Endpoint Create Single Channel (Old Version)
API Description
1、根据请求参数与默认模板创建频道
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/live/v4/channel/create-init
<a href="/req.html?api=http://api.polyv.net/live/v4/channel/create-init"" 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 latency is set to zero latency, 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 your own server as an intermediary to request response data from the POLYV server. See details in "Signature Generation Rules" |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| basicSetting | true | Object | Basic channel information See basicSetting field description |
| masterAuthSetting | false | Object | Primary viewing conditions See masterAuthSetting field description If this field is not provided, values will be set according to the default template. |
| playbackSetting | false | Object | Playback settings See playbackSetting field description If this field is not provided, values will be set according to the default template. |
| roles | false | Array | Role settings, including lecturer, teaching assistant, and guest. If this field is not provided, role information will be set according to the default template. If this field is provided but the lecturer is not set, the lecturer information will be set according to the default template. If this field is provided but teaching assistants and guests are not set, they will not be created. A maximum of 10 roles can be set See roles field description |
basicSetting Parameter Description
| Parameter Name | Required | Type | Description |
|---|---|---|---|
| name | true | String | Live stream name, maximum length 50 |
| newScene | true | String | Live stream scenario topclass (Large class) double (Dual-teacher class, requires activation) train (Enterprise training) alone (Event marketing) seminar (Seminar) 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 fast - landscape) portrait_topclass (Video only fast - portrait) seminar (Seminar) Field constraints: When the live scenario (newScene field) is topclass (Large class), the field supports ppt (Tri-screen - landscape), portrait_ppt (Tri-screen - portrait), alone (Video only - landscape), portrait_alone (Video only - portrait), topclass (Video only fast - landscape), portrait_topclass (Video only fast - portrait) When the live scenario (newScene field) is train (Enterprise training) or alone (Event marketing), the field supports ppt (Tri-screen - landscape), portrait_ppt (Tri-screen - portrait), alone (Video only - landscape), portrait_alone (Video only - portrait) When the live scenario (newScene field) is double (Dual-teacher class), the field supports ppt (Tri-screen - landscape), alone (Video only - landscape) When the live scenario (newScene field) is seminar (Seminar), the field supports seminar (Seminar) When the live scenario (newScene field) is guide (Director), the field supports alone (Video only - landscape), portrait_alone (Video only - portrait) |
| streamType | false | String | Live stream method client: Standard live stream (default value) disk: Pseudo live stream |
| channelPasswd | false | String | Instructor login password, valid when the live scenario is not a seminar, length 6-16 characters, must contain both letters and numbers. If not provided, the system will randomly generate one. |
| seminarHostPassword | false | String | Seminar host password, valid only when the live scenario is a seminar, length 6-16 characters, must contain both letters and numbers. If not provided, the system will randomly generate one. |
| seminarAttendeePassword | false | String | Seminar attendee password, valid only when the live scenario is a seminar, length 6-16 characters, must contain both letters and numbers. If not provided, the system will randomly generate one. |
| categoryId | false | Integer | Category ID |
| startTime | false | Long | Live stream start time, 13-digit millisecond timestamp [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, must be greater than the current time [Note: Only used for live stream status display when not started, does not affect the instructor's ability to start broadcasting] |
| pureRtcEnabled | false | String | No-delay live stream switch, Y: Enable, N: Disable |
| type | false | String | Channel type Initiate relay: transmit Receive relay: receive Standard channel: normal |
| createReceiveChannelCount | false | Integer | Number of receive relay channels to create (only valid when the channel type is initiate relay, i.e., type value is transmit; supports creating up to 100 relay channels simultaneously) |
| doubleTeacherType | false | String | Online dual-teacher room type: transmit (large room), receive (small room) |
| cnAndEnLiveEnabled | false | String | Bilingual live stream switch (Chinese and English): Y for On, N for Off |
| linkMicLimit | false | Integer | Maximum number of participants for co-streaming, up to 16. A value of 0 means co-streaming is disabled. If this value is empty, the account's default maximum co-streaming number will be used (can be modified by contacting sales) |
| description | false | String | Live stream introduction, maximum 1024 characters (does not support rich text; it is recommended to use menuDesc instead) |
| menuDesc | false | String | Menu management, live stream introduction (supports rich text, replaces description) |
| logoImg | false | String | Live room icon URL. If empty, the default template setting will be used. |
| splashImg | false | String | Splash page image URL. For images not under the Polyv domain, you must first call Upload all channel decoration image materials to upload. If empty, the default template setting will be used. |
| coverImg | false | String | Player cover image, displayed when there is no live stream or replay. If not provided, the default template setting will be used. |
| 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 API. |
| customTeacherId | false | String | Custom instructor ID, up to 32 ASCII visible characters |
| watchLangType | false | String | Viewing page language (zh_CN: Chinese / en: English / ja: Japanese / ko: Korean / zh_TW: Traditional Chinese / follow_browser: Follow browser) |
| allowSwitchLangEnabled | false | String | Allow viewers to switch language switch Y: Allow N: Not allowed |
| smallClassSizeLimit | false | Integer | Small class size, required only when the live scenario is a small class. Optional values: 1, 6, 12 |
| isRecord | false | String | Small class recording switch, valid only when the live scenario is a small class. Y: Enable, N: Disable. If not provided, defaults to disabled. |
| h5LowLatencyFlvEnabled | false | String | Low latency switch for mobile H5 viewing page, Y means enable, N means disable. |
masterAuthSetting Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| enabled | true | String | Whether to enable viewing conditions Y: Enabled N: Disabled |
| authType | false | String | Viewing condition type code: Verification code viewing pay: Paid viewing custom: Custom authorization viewing external: External authorization viewing direct: Independent authorization viewing |
| authCode | false | String | Required when authType is code. Viewing verification code, maximum length 8 characters |
| codeAuthTips | false | String | Optional when authType is code. Welcome title, maximum length 20 characters, default: Welcome to this live stream |
| qCodeTips | false | String | Optional when authType is code. Verification code prompt text, maximum length 30 characters, default: Scan QR code to get verification code |
| qCodeImg | false | String | Optional when authType is code. QR code image URL |
| payAuthTips | true | String | Required when authType is pay. Welcome title, maximum length 20 characters |
| price | true | Float | Required when authType is pay. Price, in yuan |
| watchEndTime | false | Long | Optional when authType is pay. Payment validity end date, 13-digit millisecond timestamp |
| validTimePeriod | false | Integer | Optional when authType is pay. Payment validity duration, in days. When both watchEndTime and validTimePeriod are empty, payment is valid indefinitely |
| customKey | true | String | Required when authType is custom. SecretKey, maximum length 10 characters |
| customUri | true | String | Required when authType is custom. Custom URL |
| externalKey | true | String | Required when authType is external. SecretKey, maximum length 10 characters |
| externalUri | true | String | Required when authType is external. Custom URL |
| externalRedirectUri | false | String | Optional when authType is external. Failure redirect URL |
| externalEntryText | false | String | Optional when authType is external. Entry text, default: Login to watch |
| directKey | true | String | Required when authType is direct. Independent authorization SecretKey, maximum length 10 characters |
playbackSetting Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| playbackEnabled | false | String | Playback switch Y: Enabled N: Disabled |
| sectionEnabled | false | String | Playback setting, chapter switch, Y: Enabled, N: Disabled |
| type | false | String | Playback mode single: Single playback list: List playback |
| origin | false | String | Playback source record: Temporary storage playback: Playback list vod: VOD list Note: When type is single, this value can only be record; when type is list, this value can only be playback or vod; |
roles Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| role | true | String | Role type Teacher: Lecturer Assistant: Teaching Assistant Guest: Guest |
| nickName | false | String | Role nickname, limited to 30 characters |
| actor | false | String | Role title, limited to 10 characters |
| passwd | false | String | Role password, length 6-16 characters, must contain both numbers and letters |
| avatar | false | String | Role avatar image URL, must include protocol |
Example
http://api.polyv.net/live/v4/channel/create-init?appId=frlr1zazn3&sign=4424EF1F6C767FC0E2FB4A912E566879×tamp=1653879013148
Request body JSON parameters:
{
"basicSetting": {
"template": "ppt",
"newScene": "topclass",
"type": "normal",
"cnAndEnLiveEnabled": "N",
"linkMicLimit": "5",
"doubleTeacherType": "normal",
"name": "polyv公开课",
"startTime": "1747718040000",
"pureRtcEnabled": "Y",
"description": "通过游戏的带入课程<br/>让课堂生动有趣",
"channelPasswd": "1a2b3c4d5e",
"logoImg": "https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg",
"splashImg": "https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg"
},
"masterAuthSetting": {
"enabled": "Y",
"authType": "code",
"authCode": "123456"
},
"playbackSetting":{
"playbackEnabled":"Y",
"sectionEnabled":"Y",
"type":"list",
"origin":"vod"
},
"roles": [
{
"role": "Teacher"
},
{
"role": "Assistant",
"actor": "助教",
"nickName": "勋助教"
},
{
"role": "Guest",
"passwd": "aSzqyd13qz",
"actor": "嘉宾",
"avatar": "https://s1.videocc.net/default-img/avatar/guest.png",
"nickName": "王嘉宾"
}
]
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, identical to HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by business logic; 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 |
| error | Object | Error information when the status code is not 200 [See Error Field Description for details] |
| data | Object | [See data Field Description for details] |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to determine the specific cause of the error |
| desc | String | Error description, corresponding to error.code |
Description of the data field
| Parameter | Type | Description |
|---|---|---|
| channelId | String | Channel ID |
| name | String | Channel name |
| 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, 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 |
| publisher | String | Host name |
| description | String | Live streaming description |
| newScene | String | Live streaming scenario (topclass - Large class, double - Dual-teacher class (requires activation), train - Enterprise training, seminar - Seminar, alone - Event marketing) |
| template | String | Live streaming template (ppt - Three-screen (landscape), portrait_ppt - Three-screen (portrait), alone - Pure video (landscape), portrait_alone - Pure video (portrait), topclass - Pure video - Express (landscape), portrait_topclass - Pure video - Express (portrait), seminar - Seminar) When the live streaming scenario is topclass, this field supports ppt, portrait_ppt, alone, portrait_alone, topclass, portrait_topclass When the live streaming scenario is train or alone, this field supports ppt, portrait_ppt, alone, portrait_alone When the live streaming scenario is double, this field supports ppt, alone When the live streaming scenario is seminar, this field supports seminar |
| linkMicLimit | Integer | Number of participants allowed for mic connection |
| pureRtcEnabled | String | Live streaming latency Y: No latency N: Normal latency |
| type | String | Channel type Initiate relay: transmit Receive relay: receive Normal channel: normal |
| currentTimeMillis | Long | Current 13-digit millisecond timestamp |
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 include HttpUtil.java and LiveSignUtil.java, both of which are contained 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 pooling.
private static final Logger log = LoggerFactory.getLogger(ChannelOperateTest.class);
/**
* 创建单个频道
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testCreateInit() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/channel/create-init";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String json = "{\"basicSetting\":{\"template\":\"ppt\",\"newScene\":\"topclass\",\"type\":\"normal\"," +
"\"cnAndEnLiveEnabled\":\"N\",\"linkMicLimit\":\"5\",\"doubleTeacherType\":\"normal\"," +
"\"name\":\"polyv公开课\",\"startTime\":\"1747718040000\",\"pureRtcEnabled\":\"Y\"," +
"\"description\":\"通过游戏的带入课程,让课堂生动有趣\",\"channelPasswd\":\"1a2b3c4d5e\"," +
"\"logoImg\":\"https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg\"," +
"\"splashImg\":\"https://liveimages.videocc.net/uploaded/images/2021/09/g2bta2pjbw.jpg\"}," +
"\"masterAuthSetting\":{\"enabled\":\"Y\",\"authType\":\"code\",\"authCode\":\"123456\"}," +
"\"roles\":[{\"role\":\"Teacher\"},{\"role\":\"Assistant\",\"actor\":\"助教\",\"nickName\":\"勋助教\"}," +
"{\"role\":\"Guest\",\"passwd\":\"aSzqyd13qz\",\"actor\":\"嘉宾\",\"avatar\":\"https://s1.videocc" +
".net/default-img/avatar/guest.png\",\"nickName\":\"王嘉宾\"}]}";
String response = HttpUtil.postJsonBody(url, json, 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 (Test example channel number has been hidden)
{
"code": 200,
"status": "success",
"requestId": "14138a5004b1412fbe109f854fec0b52.59.16538790171742883",
"data": {
"channelId": ******,
"name": "polyv公开课",
"userId": "1b448be323",
"channelPasswd": "t2IIefL6toqoBAA",
"seminarHostPassword": null,
"seminarAttendeePassword": null,
"publisher": null,
"description": "通过游戏的带入课程,让课堂生动有趣",
"newScene": "topclass",
"template": "ppt",
"linkMicLimit": 5,
"pureRtcEnabled": "Y",
"type": "normal",
"currentTimeMillis": 1653879017848
},
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"requestId": "4081dbac03e6441e8bdd301d8feee5a2.124.16360831818611581",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
