Query Video Analytics
Updated: 2025-01-14 16:23:30
API Description
1、通过视频id查询视频分析
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/advance/video/{userid}
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
- For advanced analytics features, see: Video Advanced Analytics
- Due to data volume and computation load, analytics results are available for query the next day.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| ptime | true | Long | Current time in milliseconds, valid for 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 and must never be stored or used directly on the client. All APIs must be relayed through the customer's own server to call the POLYV server for response data. See signature generation rules |
| vid | true | String | Video ID |
Example
http://api.polyv.net/v2/advance/video/1b448be323?vid=1b448be323fb327a42539cbb788913b4_1&sign=0FF2C07D900C3ABC777A39A210B6CAF118537C06&ptime=1617789916637
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 | Video analytics details returned on success. See data field description |
Data Field Description
| Parameter | Type | Description |
|---|---|---|
| videoId | String | Video ID |
| videoName | String | Video name |
| duration | Integer | Video duration, in seconds |
| playTimes | Integer | Number of plays |
| uniqueViewerCount | Integer | Number of unique viewers |
| avgCompletionRate | Double | Average completion rate |
| viewHeatmap | String | View heatmap, e.g., ["0-20:662","21-100:665"] indicates 662 views for seconds 0-20 and 665 views for seconds 21-100 |
| uniqueViewHeatmap | String | Unique view heatmap, e.g., ["0-20:614","21-100:615"] indicates 614 unique viewers for seconds 0-20 and 615 for seconds 21-100 |
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. | ptime exceeds current time by 3 minutes |
| 400 | Could not find user by userid. | User ID not found |
| 400 | the sign is not right. | Incorrect signature |
| 401 | vid is blank. | Video ID is empty |
| 402/403 | cannot find this video data. | Video analytics data not found |
| 404 | get video analytics detail failed. | Backend failed to retrieve data |
| 500 | get play list failed. please check the backend log. | Backend exception |
Java Request Example
For quick integration, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API 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(VodBigdataTest.class);
/**
* 查询视频分析
*/
@Test
public void testGetVideoAnalysis() 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/advance/video/%s", userId);
String vid = "1b448be323fb327a42539cbb788913b4_1";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid", vid);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询视频分析,{}", response);
//do somethings
}
Response Example
For global error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": {
"videoId": "1b448be323fb327a42539cbb788913b4_1",
"videoName": "防爆演习2",
"duration": 13,
"playTimes": 19,
"uniqueViewerCount": 4,
"avgCompletionRate": 0.96,
"viewHeatmap": "[\"0-2:1\"]",
"uniqueViewHeatmap": "[\"0-2:1\"]"
}
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
