Query Danmaku List
Updated: 2025-01-14 15:59:20
API Description
1、分页查询用户下所有的弹幕信息
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/danmu/{userid}
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. API calls have frequency limits. See details
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, valid within 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must not be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server to obtain response data. See signature generation rules |
| vid | false | String | Video ID. If provided, queries all danmaku under this video; if not, queries all danmaku for the user |
| numPerPage | false | Integer | Number of records per page |
| pageNum | false | Integer | Page number to query |
Example
http://api.polyv.net/v2/danmu/1b448be323?vid=1b448be323b68b2999802799a98dba54_1&sign=F6254A68BF8AC6570848D86CDB7F57BB3989638A&numPerPage=1&ptime=1617241038467&pageNum=1
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See global error description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, provides additional error details |
| data | Object | Returns detailed danmaku information on success. See data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| pageNumber | Integer | Current page number |
| totalItems | Integer | Total number of records |
| totalPages | Integer | Total number of pages |
| endRow | Integer | Position of the last record on the current page within the total records |
| startRow | Integer | Position of the first record on the current page within the total records |
| activePageNum | Integer | Actual page number |
| firstPage | Boolean | Whether it is the first page, values: true/false |
| lastPage | Boolean | Whether it is the last page, values: true/false |
| nextPageNumber | Integer | Next page number |
| prePageNumber | Integer | Previous page number |
| limit | Integer | Number of records on the current page |
| offset | Integer | Pagination starting record |
| contents | Object | Uploader information. See contents field description |
contents Field Description
| Parameter | Type | Description |
|---|---|---|
| id | Integer | Unique identifier for the danmaku |
| vid | String | Video ID |
| userid | String | POLYV VOD account ID |
| msg | String | Danmaku content |
| time | String | Time point when the danmaku appears, format: HH:mm:ss, e.g., 00:00:10 |
| fontsize | String | Font size of the danmaku content |
| fontmode | String | Scrolling mode of the danmaku content roll: scrolling top: top bottom: bottom |
| fontcolor | String | Font color of the danmaku content |
| timestamp | Long | Time when the danmaku content appears, 13-digit millisecond timestamp |
| sessionid | String | Custom parameter (max 64 characters), custom parameter passed when adding danmaku (e.g., customer's own user ID data) |
| param2 | String | Custom parameter (max 64 characters), custom parameter passed when adding danmaku (e.g., customer's own user ID data) |
| msgtype | String | When live replay is saved to VOD, chat records are converted to VOD danmaku. Live chat room message type speak: speech chatImg: image |
| user | String | Data from live replay saved to VOD, user information from live chat login. Data format: JSON object. See user parameter description |
| origin | String | Danmaku source vod: VOD playback: live replay chat data chat: live chat data |
| viewerId | String | Custom parameter (max 64 characters), custom parameter passed when adding danmaku (e.g., customer's own user ID data) |
user Parameter Description
| Field | Type | Description |
|---|---|---|
| actor | String | Title |
| banned | Boolean | Whether muted, true/false |
| channelId | String | Channel ID |
| clientIp | String | User IP |
| nick | String | User nickname |
| pic | String | User avatar |
| roomId | String | Room number |
| sessionId | String | Live session ID |
| uid | String | Chat room socket ID |
| userId | String | POLYV user ID, consistent with the POLYV official website. Retrieval path: Official website -> Login -> VOD (API) |
| userType | String | User type, default is student. In the three-screen scenario, students should set it to slice student: regular student slice: cloud classroom student teacher: instructor manager: administrator assistant: teaching assistant guest: guest |
Error Code List
| Error Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Signature is empty |
| 400 | ptime is too old. | Timestamp expired |
| 400 | ptime is illegal. | Timestamp parameter format is incorrect or exceeds current time by 3 minutes |
| 400 | Could not find user by userid. | User ID does not exist |
| 400 | the sign is not right. | Signature is incorrect |
| 500 | query failed. | Backend program threw an exception |
Java Request Example
For quick integration of 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. HttpUtil.java and VodSignUtil.java in the test cases are included in the download file.
It is strongly recommended to use the VOD Java SDK for API functionality integration. The VOD Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(VodVideoManagementTest.class);
/**
* 查询弹幕
*/
@Test
public void testGetDanmu() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/v2/danmu/%s", userId);
String vid = "1b448be323b68b2999802799a98dba54_1";
String numPerPage = "1";
String pageNum = "1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("numPerPage", numPerPage);
requestMap.put("pageNum", pageNum);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询弹幕,{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"pageNumber": 1,
"totalItems": 7,
"contents": [{
"id": 17252332,
"vid": "1b448be323b68b2999802799a98dba54_1",
"userid": "1b448be323",
"msg": "测试获取弹幕信息",
"time": "00:00:01",
"fontsize": "24",
"fontmode": "roll",
"fontcolor": "0xFFFFFF",
"timestamp": 1617176768000,
"sessionid": null,
"param2": null,
"msgtype": "speak",
"user": "",
"origin": "vod",
"viewerId": null
}],
"totalPages": 1,
"endRow": 7,
"startRow": 1,
"nextPageNumber": 1,
"prePageNumber": 1,
"activePageNum": 1,
"firstPage": true,
"lastPage": true,
"limit": 1,
"offset": 0
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
