> For the complete documentation index, see [llms.txt](https://polyv.gitbook.io/document/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polyv.gitbook.io/document/docs/unclassified/2020/d7e2215676ba3ccd14894f9b2c34b720.md).

# 获取多个频道下(聚合查询结果)的地域分布信息

### 接口URL

```
https://api.polyv.net/live/v3/channel/statistics/geo-summary-mc
```

### 接口说明

```
1、接口用于获取多个频道下(聚合查询结果)的地域分布信息
2、接口支持https
```

### 支持格式

```
JSON
```

### 请求方式

```
GET
```

### 请求数限制

```
TRUE
```

### 请求参数

| 参数名        | 必选 | 类型     | 说明                                                                                                                                                                                                        |
| ---------- | -- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| appId      | 是  | string | 从API设置中获取，在直播系统登记的appId                                                                                                                                                                                   |
| timestamp  | 是  | long   | 当前13位毫秒级时间戳，3分钟内有效                                                                                                                                                                                        |
| sign       | 是  | String | 签名，为32位大写的MD5值,`生成签名的appSecret密钥作为通信数据安全的关键信息，严禁保存在客户端直接使用，所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据`【详见[签名生成规则](https://git.polyv.net/help-center/document-center/-/blob/master/live/api/buildSign/README.md)】 |
| channelIds | 是  | string | 频道号，多个频道以,隔开                                                                                                                                                                                              |
| startDate  | 是  | string | 开始日期格式，yyyy-MM-dd                                                                                                                                                                                         |
| endDate    | 是  | string | 结束日期格式，yyyy-MM-dd                                                                                                                                                                                         |
| global     | 否  | string | 是否查询按国家统计,Y 按国家统计，N 按国内省份统计，默认是N                                                                                                                                                                          |
| city       | 否  | string | 是否按城市统计, Y:按城市统计，N:按省份统计，在global=N 时才生效，默认是N                                                                                                                                                              |

### 响应成功JSON示例：

```json
{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "province": "广东",
            "city": "广州",
            "viewer": 1,
            "percent": 100.0
        }
    ]
}
```

### 响应失败JSON示例：

未输入appId

```json
{
    "code": 400,
    "status": "error",
    "message": "appId is required.",
    "data": ""
}
```

appId不正确

```json
{
    "code": 400,
    "status": "error",
    "message": "application not found.",
    "data": ""
}
```

时间戳错误

```json
{
    "code": 400,
    "status": "error",
    "message": "invalid timestamp.",
    "data": ""
}
```

签名错误

```json
{
    "code": 403,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
```

频道号非法

```json
{
  "code": 403, 
  "status": "error", 
  "message": "illegal channel id: 1234567", 
  "data": ""
}
```

频道号格式错误

```json
{
  "code": 400, 
  "status": "error", 
  "message": "param is not digit: dsadasd", 
  "data": ""
}
```

日期范围错误

```json
{
  "code": 400, 
  "status": "error", 
  "message": "startDate can not great endDater", 
  "data": ""
}
```

### 字段说明

| 参数名               | 说明                                  |
| ----------------- | ----------------------------------- |
| code              | 响应代码，成功为200，失败为400，签名错误为401，异常错误500 |
| status            | 成功为success，失败为error                 |
| message           | 错误时为错误提示消息                          |
| data              | 多个频道下(聚合查询结果)的地域分布信息                |
| data\[0].province | 省份                                  |
| data\[0].city     | 城市，如果按省份统计，则该字段为空                   |
| data\[0].viewer   | 人数                                  |
| data\[0].percent  | 百分比                                 |

### Java请求示例

```java
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);
    }
```
