Category Statistics
API Description
1、查询分类下视频播放情况及消耗流量汇总数据
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、从播放行为产生到数据可查询的间隔时间为1~2小时,流量消耗(flowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
4、分类统计功能需开通使用
5、接口支持https协议
API URL
http://api.polyv.net/v2/cata/{userid}/stats-info
Request Method
GET
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The request parameters
startDateandendDatemust be provided together; passing only one parameter will not take effect.If both
dr(time period) andstartDate/endDateare provided, onlystartDateandendDateare effective. If none are provided,drdefaults to7days.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| 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. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules |
| cataid | true | String | Category ID |
| dr | false | String | Time period. Possible values (default: 7days): today: Today yesterday: Yesterday this_week: This week last_week: Last week 7days: Last 7 days this_month: This month last_month: Last month this_year: This year last_year: Last year |
| startDate | false | String | Start date, format: yyyy-MM-dd, e.g., 2021-04-07 |
| endDate | false | String | End date, format: yyyy-MM-dd, e.g., 2021-04-10 |
| containSubCategory | false | String | Whether to include subcategory data Y: Yes N: No |
Example
http://api.polyv.net/v2/cata/1b448be323/stats-info?endDate=2021-09-07&containSubCategory=Y&sign=E83FE698438024F0A1AA81D589DB5690952C9AAC&cataid=1&ptime=1631242976511&startDate=2021-09-02
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 category statistics data on success. See data field description |
Data Field Description
| Parameter | Type | Description |
|---|---|---|
| current | String | Date, format: yyyy-MM-dd |
| pcVideoView | Integer | PC play count |
| mobileVideoView | Integer | Mobile play count |
| pcFlowSize | Long | PC traffic consumed, unit: bytes |
| mobileFlowSize | Long | Mobile traffic consumed, unit: bytes |
| pcPlayDuration | Integer | PC play duration, unit: seconds |
| mobilePlayDuration | Integer | Mobile play duration, unit: seconds |
| pcUniqueViewer | Integer | PC unique viewers |
| mobileUniqueViewer | Integer | Mobile unique viewers |
Java Request Example
For quick integration of basic code, please 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);
/**
* 分类统计接口
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetStatsInfo() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/cata/" + userId + "/stats-info";
String dr = "this_month";
String startDate = "2021-09-02";
String endDate = "2021-09-07";
String cataid = "1";
String containSubCategory = "Y";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("startDate", startDate);
requestMap.put("endDate", endDate);
requestMap.put("cataid", cataid);
requestMap.put("containSubCategory", containSubCategory);
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": "",
"data": [
{
"current": "2021-09-02",
"pcFlowSize": 0,
"pcVideoView": 1,
"pcPlayDuration": 117,
"mobileFlowSize": 56787796,
"mobileVideoView": 3,
"mobilePlayDuration": 223,
"pcUniqueViewer": 1,
"mobileUniqueViewer": 2
},
{
"current": "2021-09-03",
"pcFlowSize": 4113247,
"pcVideoView": 1,
"pcPlayDuration": 17,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 1,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-04",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-05",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-06",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
},
{
"current": "2021-09-07",
"pcFlowSize": 0,
"pcVideoView": 0,
"pcPlayDuration": 0,
"mobileFlowSize": 12627,
"mobileVideoView": 0,
"mobilePlayDuration": 0,
"pcUniqueViewer": 0,
"mobileUniqueViewer": 0
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
