Query Channel Live View Details
API Description
1、获取频道观看日志
2、接口URL中的{channelId}为频道号
3、接口支持https协议
4、直播观看详情数据支持查询最近3年内的历史数据,建议将历史数据导出到本地储存,以便后续查询。
API URL
http://api.polyv.net/live/v1/statistics/{channelId}/viewlog
Request Method
GET
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
Data queries for deleted channels are not supported.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must not be stored 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 |
| currentDay | true | String | Query date, format: yyyy-MM-dd |
| userId | true | String | Live account ID |
| param1 | false | String | Viewer user ID |
Example
http://api.polyv.net/live/v1/statistics/1965681/viewlog?currentDay=2021-1-20&appId=frlr1zazn3&sign=B4A33B092F5E5B9283C9D8308E10B868&userId=1b448be323¶m1=1b448be323×tamp=1621842550515
Response Parameter Description
| Field | Type | Description |
|---|---|---|
| status | String | Status value |
| result | Array | Response result set See Result parameter description |
Result parameter description
| Field | Type | Description |
|---|---|---|
| playId | String | ID representing this playback action |
| userId | String | Live account ID |
| channelId | String | Channel number |
| playDuration | Integer | Playback duration, unit: seconds |
| stayDuration | Integer | Stay duration, unit: seconds |
| sessionId | String | Live session ID |
| param1 | String | Viewer ID from POLYV watch page |
| param2 | String | Viewer nickname from POLYV watch page |
| param3 | String | Watch log type, default is live vod: watch replay live: live stream |
| param4 | String | POLYV system parameter |
| param5 | String | POLYV system parameter |
| ipAddress | String | IP address |
| country | String | Country |
| province | String | Province |
| city | String | City |
| isp | String | ISP |
| referer | String | Video page URL |
| userAgent | String | User device |
| operatingSystem | String | Operating system |
| browser | String | Browser |
| isMobile | String | Whether it is mobile |
| currentDay | String | Query date, format: yyyy-MM-dd |
| ptype | Integer | 0 or not provided: normal live 1: ultra-low latency live rts (no longer in use) 2: PRTC live (no latency) |
| firstActiveTime | Long | Entry time, 13-digit millisecond timestamp |
| lastActiveTime | Long | Exit time, 13-digit millisecond timestamp |
| createdTime | Long | Data insertion time, 13-digit millisecond timestamp |
| lastModified | Long | Data last modified time, 13-digit millisecond timestamp |
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 LiveSignUtil.java in the downloaded file.
It is strongly recommended to use the Live Java SDK for API integration. The Live 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(ChannelViewDataTest.class);
/**
* 测试查询频道直播观看详情数据
* @throws IOException
*/
@Test
public void testViewlog() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String userId = super.userId;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = String.format("http://api.polyv.net/live/v1/statistics/%s/viewlog","1965681");
String currentDay = "2021-1-20";
String param1 = "1b448be323";
//http 调用逻辑
Map<String,String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp",timestamp);
requestMap.put("currentDay",currentDay);
requestMap.put("userId", userId);
requestMap.put("param1",param1);
requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询频道直播观看详情数据,返回值:{}",response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"status":"success",
"result":[
{
"playId":"1611137360114X1320926",
"userId":"1b448be323",
"channelId":1965681,
"playDuration":182,
"stayDuration":190,
"sessionId":"fv3ma84e63",
"param1":"1b448be323",
"param2":"管理员",
"param3":"live",
"param4":"",
"param5":"",
"ipAddress":"118.249.213.240",
"country":"中国",
"province":"湖南",
"city":"长沙",
"isp":"湖南电信",
"referer":"https://live.polyv.net/#/channel/1965681/monitoring",
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
"operatingSystem":"Windows",
"browser":"Firefox 8",
"isMobile":"N",
"currentDay":"2021-01-20",
"createdTime":1611137461000,
"lastModified":1611148800000,
"ptype":0
},
{
"playId":"1611127231433X1037457",
"userId":"1b448be323",
"channelId":1965681,
"playDuration":154,
"stayDuration":160,
"sessionId":"fv3hmq3qml",
"param1":"1b448be323",
"param2":"管理员",
"param3":"live",
"param4":"",
"param5":"",
"ipAddress":"118.249.213.240",
"country":"中国",
"province":"湖南",
"city":"长沙",
"isp":"湖南电信",
"referer":"https://live.polyv.net/#/channel/1965681/monitoring",
"userAgent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0",
"operatingSystem":"Windows",
"browser":"Firefox 8",
"isMobile":"N",
"currentDay":"2021-01-20",
"createdTime":1611127282000,
"lastModified":1611138733000,
"ptype":0
}
]
}
Error Example
{
"code":"invalid.request",
"msg":"signature error."
}
