Get Geographic Distribution Information for Multiple Channels (Aggregated Query Results)
Updated: 2022-09-02 18:08:07
Interface URL
https://api.polyv.net/live/v3/channel/statistics/geo-summary-mc
Interface Description
1、接口用于获取多个频道下(聚合查询结果)的地域分布信息
2、接口支持https
Supported Format
JSON
Request Method
GET
Request Limit
TRUE
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | Yes | string | Obtained from API settings, the appId registered in the live streaming system |
| timestamp | Yes | long | Current 13-digit millisecond timestamp, valid within 3 minutes |
| sign | Yes | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be saved 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 and obtain response data. See Signature Generation Rules |
| channelIds | Yes | string | Channel IDs, multiple channels separated by commas |
| startDate | Yes | string | Start date format, yyyy-MM-dd |
| endDate | Yes | string | End date format, yyyy-MM-dd |
| global | No | string | Whether to query by country statistics, Y: by country, N: by domestic province, default is N |
| city | No | string | Whether to query by city statistics, Y: by city, N: by province, only effective when global=N, default is N |
Successful Response JSON Example:
{
"code": 200,
"status": "success",
"message": "",
"data": [
{
"province": "广东",
"city": "广州",
"viewer": 1,
"percent": 100.0
}
]
}
Failed Response JSON Examples:
No appId provided
{
"code": 400,
"status": "error",
"message": "appId is required.",
"data": ""
}
Incorrect appId
{
"code": 400,
"status": "error",
"message": "application not found.",
"data": ""
}
Timestamp error
{
"code": 400,
"status": "error",
"message": "invalid timestamp.",
"data": ""
}
Signature error
{
"code": 403,
"status": "error",
"message": "invalid signature.",
"data": ""
}
Invalid channel ID
{
"code": 403,
"status": "error",
"message": "illegal channel id: 1234567",
"data": ""
}
Incorrect channel ID format
{
"code": 400,
"status": "error",
"message": "param is not digit: dsadasd",
"data": ""
}
Date range error
{
"code": 400,
"status": "error",
"message": "startDate can not great endDater",
"data": ""
}
Field Description
| Parameter | Description |
|---|---|
| code | Response code, 200 for success, 400 for failure, 401 for signature error, 500 for server error |
| status | success for success, error for failure |
| message | Error message when status is error |
| data | Geographic distribution information for multiple channels (aggregated query results) |
| data[0].province | Province |
| data[0].city | City, empty if querying by province |
| data[0].viewer | Number of viewers |
| data[0].percent | Percentage |
Java Request Example
public static void main(String[] args) {
String url = "http://api.polyv.net/live/v3/channel/statistics/geo-summary-mc;
// 用户对应的appId和加密串
String appId = "xxxxxxxxx";
String appSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
Map<String, String> params = new HashMap<>();
int channelId = 1234567;
String startDate = "2020-08-01";
String endDate = "2020-08-18";
params.put("channelIds", String.valueOf(channelId));
params.put("startDate", startDate);
params.put("endDate", endDate);
PolyvTool.setLiveSign(params, appId, appSecret);
// 调用Polyv的httpClient工具类发送请求
String content = HttpClientUtil.getInstance()
.sendHttpGet(url + "?" + PolyvTool.mapJoinNotEncode(params));
System.out.println(content);
}
