頻道彙總統計
更新時間:2022-05-23 19:02:59
介面URL
https://api.polyv.net/live/v3/user/statistics/channels-summary
介面說明
1、介面用於查詢多個頻道的直播觀看數據彙總統計
2、介面支援https
支援格式
JSON
請求方式
GET
請求數限制
TRUE
請求參數
| 參數名 | 必選 | 類型 | 說明 |
|---|---|---|---|
| appId | 是 | string | 從API設定中取得,在直播系統登記的appId |
| timestamp | 是 | long | 13位當前毫秒級時間戳 |
| sign | 是 | string | 簽名值 |
| startDate | 是 | string | 開始時間,格式 yyyy-MM-dd |
| endDate | 是 | string | 結束時間,格式 yyyy-MM-dd |
| channelIds | 是 | string | 頻道ID,多個頻道使用','分隔 |
響應成功JSON範例:
{
"code": 200,
"status": "success",
"message": "",
"data": {
"list": [
{
"channelId": 1938990,
"pcPlayDuration": 3,
"pcFlowSize": 0,
"pcVideoView": 2,
"pcUniqueViewer": 1,
"mobilePlayDuration": 0,
"mobileFlowSize": 0,
"mobileVideoView": 0,
"concurrenceCount": 2,
"mobileUniqueViewer": 0
},
{
"channelId": 1947328,
"pcPlayDuration": 320,
"pcFlowSize": 0,
"pcVideoView": 183,
"pcUniqueViewer": 58,
"mobilePlayDuration": 16,
"mobileFlowSize": 0,
"mobileVideoView": 12,
"concurrenceCount": 5,
"mobileUniqueViewer": 5
}
]
}
}
響應欄位說明
| 參數名 | 說明 |
|---|---|
| code | 狀態碼,成功為200,簽名失敗為403,參數錯誤為400,服務端錯誤為500 |
| status | 成功為success,錯誤時為error |
| message | 成功為"",錯誤時為錯誤描述資訊 |
| data | 響應數據 |
| data.list.channelId | 頻道ID |
| data.list.pcPlayDuration | PC端播放時長,單位:分鐘 |
| data.list.pcFlowSize | PC端消耗流量,單位:bytes |
| data.list.pcVideoView | PC端總播放量,類似PV |
| data.list.pcUniqueViewer | PC端唯一觀眾數,類似UV |
| data.list.mobilePlayDuration | 行動端播放時長,單位:分鐘 |
| data.list.mobileFlowSize | 行動端消耗流量,單位:bytes |
| data.list.mobileVideoView | 行動端總播放量,類似PV |
| data.list.mobileUniqueViewer | 行動端唯一觀眾數,類似UV |
| data.list.concurrenceCount | 最高並發人數 |
響應失敗JSON範例:
參數錯誤
{
"code": 400,
"status": "error",
"message": "param validate error",
"data": ""
}
未輸入appId
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
appId不正確
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
時間戳錯誤
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
簽名錯誤
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
非法頻道號
{
"code": 403,
"status": "error",
"message": "illegal channel id: %s",
"data": ""
}
java請求範例
public void testAddRecordTask() {
String url = "https://api.polyv.net/live/v3/user/statistics/channels-summary";
// appId和加密串
String appId = "xxxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxx";
Map params = new HashMap<>();
params.put("channelIds", "2232850");
params.put("startDate", "2020-12-01");
params.put("endDate", "2021-01-11");
// 調用Polyv的工具類方法設定sign
PolyvTool.setLiveSign(params, appId, appSecret);
String content = HttpClientUtil.getInstance()
.sendHttpPost(url, params);
System.out.println(content);
}
