Query Video Statistics Summary Data
API Description
1、批量查询视频播放统计汇总数据
2、从播放行为产生到数据可查询的间隔时间为1~2小时,流量消耗(flowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
3、接口支持https协议
API URL
http://api.polyv.net/v2/summary/video
<a href="/req.html?api=http://api.polyv.net/v2/summary/video"" target="_blank">Online API Call
Request Method
GET
API Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The request parameters
startDateandendDatemust be passed together; passing only one parameter will not take effect.If
dris passed together withstartDateandendDate, onlystartDateandendDateare valid. If none are passed,drdefaults to7days.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| userid | true | String | POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface) |
| ptime | true | Long | Current time in milliseconds timestamp, 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. It must not be stored or used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server. See Signature Generation Rules |
| vids | false | String | Video IDs, separated by commas for multiple videos. Example: a2dc4f25179499d6586362672838cc2d_a,a2dc4f25179499d6586362672838cc2d_a. Maximum of 100 video IDs per request. If not passed, data for the entire account is queried. |
| dr | false | String | Time period, default is 7days (includes today). Options:today: Todayyesterday: Yesterdaythis_week: This weeklast_week: Last week7days: Last 7 daysthis_month: This monthlast_month: Last monththis_year: This yearlast_year: Last year |
| startDate | false | String | Start date, format: yyyy-MM-dd, e.g., 2021-03-01 |
| endDate | false | String | End date, format: yyyy-MM-dd, e.g., 2021-03-30. Maximum span is one year, cross-year queries are supported. |
Example
http://api.polyv.net/v2/summary/video?vids=1b448be323251079dabeb2066d70fd44_1%2Cabc&sign=8631D872371A8D3BB37C03D261EA5B4AC70AA1D0&ptime=1631245812623&userid=1b448be323&dr=this_year
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 | Array | Returns video statistics summary data on success. See data field description |
data Field Description
| Parameter | Type | Description |
|---|---|---|
| videoId | String | Video ID |
| pcVideoView | String | PC playback count |
| mobileVideoView | String | Mobile playback count |
| pcUniqueViewer | String | PC unique viewers |
| mobileUniqueViewer | String | Mobile unique viewers |
| pcFlowSize | Long | PC traffic consumption, unit: bytes |
| mobileFlowSize | Long | Mobile traffic consumption, unit: bytes |
Java Request Example
For quick integration of basic code, 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(VodStatisticsTest.class);
/**
* 查询视频统计汇总数据
*/
@Test
public void videoSummaryData() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/summary/video";
String vids = "1b448be323251079dabeb2066d70fd44_1,abc";
String dr = "this_year";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", timestamp);
requestMap.put("dr", dr);
requestMap.put("vids", vids);
requestMap.put("userid", userId);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询视频统计汇总数据:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"message": "success",
"data": [
{
"videoId": "1b448be323251079dabeb2066d70fd44_1",
"pcVideoView": "8",
"mobileVideoView": "0",
"pcUniqueViewer": "8",
"mobileUniqueViewer": "0",
"pcFlowSize": 61335157,
"mobileFlowSize": 0
},
{
"videoId": "abc_a",
"pcVideoView": "invalid vid",
"mobileVideoView": "invalid vid",
"pcUniqueViewer": "invalid vid",
"mobileUniqueViewer": "invalid vid"
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
When passing video IDs in batch, valid video IDs will return normal data, while invalid video IDs will return 'invalid vid'.
{
"code": 200,
"status": "success",
"message": "success",
"data": [
{
"videoId": "1b448be323251079dabeb2066d70fd44_1",
"pcVideoView": "2",
"mobileVideoView": "0",
"pcUniqueViewer": "2",
"mobileUniqueViewer": "0",
"pcFlowSize": 11827449,
"mobileFlowSize": 0
},
{
"videoId": "aaabbb",
"pcVideoView": "invalid vid",
"mobileVideoView": "invalid vid",
"pcUniqueViewer": "invalid vid",
"mobileUniqueViewer": "invalid vid"
}
]
}
