Query Play Count Statistics
API Description
1、查询视频播放量在不同终端的统计数据,从播放行为产生到数据可查询的间隔时间为1~2小时
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/videoview/{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
The value of the request parameter
period(display cycle) is constrained by the value ofdr. Whendristoday,yesterday,this_week,last_week, or7days,periodcan only bedaily. Whendristhis_monthorlast_month,periodcan only bedailyorweekly.
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 side. 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 |
| vid | false | String | Video ID. If not provided, play count statistics for all videos will be queried. |
| dr | false | String | Time range. Default is 7days.today: Todayyesterday: Yesterdaythis_week: This weeklast_week: Last week7days: Last 7 daysthis_month: This monthlast_month: Last monththis_year: This yearlast_year: Last year |
| period | false | String | Display cycle. Default is daily.daily: Display by dayweekly: Display by weekmonthly: Display by month |
Example
http://api.polyv.net/v2/videoview/1b448be323?vid=1b448be32395861bacc794ca59e8f306_1&sign=AD7527B17D2F2BE5E740F9D3357B7F80231837CE&ptime=1618215907432
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 auxiliary error reason. |
| data | Array | Array of video play statistics data returned on success. See Data Field Description |
Data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| currentTime | String | Current date, format: yyyy-MM-dd |
| pcVideoView | Integer | PC play count |
| mobileVideoView | Integer | Mobile play count |
Error Code List
| Error Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Signature string is empty |
| 400 | ptime is too old. | Timestamp has 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 string is incorrect |
| 401 | illegal vid. | Video ID format is incorrect. The correct format starts with the user ID. |
| 402 | illegal period. | Period value is invalid. Refer to the period constraints in the request parameters. |
| 500 | query failed. | Backend program threw an exception |
Java Request Example
For quick integration, please download the relevant dependency source code. Click here to download the 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 testGetPlaytimes() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/videoview/" + userId;
String vid = "1b448be32395861bacc794ca59e8f306_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 system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"success",
"data":[
{
"currentTime":"2021-04-06",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-07",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-08",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-09",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-10",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-11",
"pcVideoView":0,
"mobileVideoView":0
},
{
"currentTime":"2021-04-12",
"pcVideoView":0,
"mobileVideoView":0
}
]
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
