分類統計
更新時間:2025-01-14 16:22:15
介面描述
1、查询分类下视频播放情况及消耗流量汇总数据
2、接口URL中的{userid}为点播账号userid,具体参考菜单【使用须知】->【获取密钥】
3、从播放行为产生到数据可查询的间隔时间为1~2小时,流量消耗(flowSize字段)的计算依赖于CDN日志,为了保证数据完整性,流量数据需要间隔一个自然日才会生成
4、分类统计功能需开通使用
5、接口支持https协议
介面URL
http://api.polyv.net/v2/cata/{userid}/stats-info
請求方式
GET
介面限制
1、介面同時支援HTTP、HTTPS,建議使用HTTPS確保介面安全,介面呼叫有頻率限制,詳細請查看
2、請求參數中startDate(開始日期)與endDate(結束日期)需要同時傳入,僅傳一個參數不生效
3、同時傳入dr(時間段)與startDate、endDate的情況下,僅startDate、endDate有效;都不傳則dr為預設值7days
請求參數描述
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| ptime | true | Long | 當前時間的毫秒級時間戳,3分鐘內有效 |
| sign | true | String | 簽名,為40位大寫的SHA1值,產生簽名的secretkey金鑰作為通訊資料安全的關鍵資訊,嚴禁儲存在客戶端直接使用,所有API都必須透過客戶自己伺服器中轉呼叫POLYV伺服器獲取回應資料【詳見簽名產生規則】 |
| cataid | true | String | 分類id |
| dr | false | String | 時間段,具體值為以下幾個,預設值為7days today:今天 yesterday:昨天 this_week:本週 last_week:上週 7days:最近7天 this_month:本月 last_month:上個月 this_year:今年 last_year:去年 |
| startDate | false | String | 開始日期,格式為:yyyy-MM-dd,例如:2021-04-07 |
| endDate | false | String | 結束日期,格式為:yyyy-MM-dd,例如:2021-04-10 |
| containSubCategory | false | String | 是否包含子分類的資料 Y:是 N:否 |
範例
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
回應參數描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| code | Integer | 回應狀態碼,200為成功返回,非200為失敗【詳見全域錯誤說明】 |
| status | String | 回應狀態文字資訊 |
| message | String | 回應描述資訊,當code為400或者500的時候,輔助描述錯誤原因 |
| data | Array | 回應成功時返回分類統計資料【詳見data欄位描述】 |
data欄位描述
| 參數名 | 類型 | 說明 |
|---|---|---|
| current | String | 日期,格式為:yyyy-MM-dd |
| pcVideoView | Integer | PC端播放量 |
| mobileVideoView | Integer | 行動端播放量 |
| pcFlowSize | Long | PC端消耗流量,單位:位元組 |
| mobileFlowSize | Long | 行動端消耗流量,單位:位元組 |
| pcPlayDuration | Integer | PC端播放時長,單位:秒 |
| mobilePlayDuration | Integer | 行動端播放時長,單位:秒 |
| pcUniqueViewer | Integer | PC端唯一觀眾數 |
| mobileUniqueViewer | Integer | 行動端唯一觀眾數 |
Java請求範例
快速接入基礎程式碼請下載相關依賴原始碼, 點擊下載原始碼 ,下載後加入到自己的原始碼工程中即可。測試案例中的HttpUtil.java 和 VodSignUtil.java 都包含在下載檔案中。
強烈建議您使用點播Java SDK完成API的功能對接,點播Java SDK 對API呼叫邏輯、異常處理、資料簽名、HTTP請求執行緒池進行了統一封裝和最佳化。
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
}
回應範例
系統全域錯誤說明詳見全域錯誤說明
成功範例
{
"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
}
]
}
異常範例
{
"code": 400,
"status": "error",
"message": "invalid signature.",
"data": ""
}
