Query Viewing Hotspot Statistics for a Single Video
API Description
1、通过日期区间查询单个视频的观看热点统计数据,从播放行为产生到数据可查询的间隔时间为1~2小时
2、接口URL中的{userid}为点播账号userid,具体参考【获取密钥】
3、接口支持https协议
API URL
http://api.polyv.net/v2/videohot/{userid}
Request Method
GET
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls are subject to rate limits. See details
The request parameters
start(start date) andend(end date) must be provided together; passing only one parameter will not take effect.If
dr(time period) is provided together withstartandend, onlystartandendare valid. If none are provided,drdefaults to7days.
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 for response data. See signature generation rules |
| vid | true | String | Video ID |
| dr | false | String | Time period. Default value is 7days. Possible values:today: Todayyesterday: Yesterdaythis_week: This weeklast_week: Last week7days: Last 7 daysthis_month: This monthlast_month: Last monththis_year: This yearlast_year: Last year |
| start | false | String | Start date, format: yyyy-MM-dd, e.g., 2021-03-31 |
| end | false | String | End date, format: yyyy-MM-dd, e.g., 2021-04-08 |
Example
https://api.polyv.net/v2/videohot/1b448be323?vid=1b448be323a146649ad0cc89d0faed9c_1&start=2021-01-31&sign=7AC8B4D6D1D8056F62B6BEE43384C372B2FFC318&end=2021-04-8&ptime=1620801920583&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 viewing hotspot statistics on success. See Data field description. Returns empty on failure. |
Data Parameter Description
| Field | Type | Description |
|---|---|---|
| second | Integer | Statistical time point, in seconds. Statistics are recorded every 6 seconds. |
| viewcount | Integer | Number of views |
Error Code List
| Error Code | message | Description |
|---|---|---|
| 400 | sign can not be empty. | Signature string is empty |
| 400 | vid invalid. | Invalid video vid |
| 400 | ptime is too old. | Timestamp expired |
| 400 | ptime is illegal. | Timestamp 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. | Incorrect signature string |
| 401 | start and end illegal. | Start date is greater than end date |
| 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 code project. The test case files HttpUtil.java and VodSignUtil.java are included in the download package.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD Java SDK provides a unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pooling.
private static final Logger log = LoggerFactory.getLogger(VodStatisticsTest.class);
/**
* 查询单个视频的观看热点统计
*/
@Test
public void testGetHotspotStat() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("https://api.polyv.net/v2/videohot/%s", userId);
String vid = "1b448be323a146649ad0cc89d0faed9c_1";
String dr = "this_year";
String start = "2021-01-31";
String end = "2021-04-8";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("vid",vid);
requestMap.put("start", start);
requestMap.put("end", end);
requestMap.put("dr",dr);
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": [{
"second": 1,
"viewcount": 1
}, {
"second": 7,
"viewcount": 1
}, {
"second": 13,
"viewcount": 1
}, {
"second": 19,
"viewcount": 1
}, {
"second": 25,
"viewcount": 1
}, {
"second": 31,
"viewcount": 1
}, {
"second": 37,
"viewcount": 2
}, {
"second": 43,
"viewcount": 1
}, {
"second": 49,
"viewcount": 1
}, {
"second": 55,
"viewcount": 1
}, {
"second": 61,
"viewcount": 1
}, {
"second": 67,
"viewcount": 1
}, {
"second": 73,
"viewcount": 1
}, {
"second": 79,
"viewcount": 2
}, {
"second": 85,
"viewcount": 1
}, {
"second": 91,
"viewcount": 1
}, {
"second": 97,
"viewcount": 1
}, {
"second": 103,
"viewcount": 1
}, {
"second": 109,
"viewcount": 2
}]
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
