获取多个频道下的历史并发记录(聚合数据)

接口URL

https://api.polyv.net/live/v3/channel/statistics/concurrence-mc

接口说明

1、接口用于获取多个频道下的历史并发记录(聚合数据,按照时间升序排序)
2、日期参数跨天则天为粒度,一天之内则以分钟为粒度返回
3、接口支持https

支持格式

JSON

请求方式

GET

请求数限制

TRUE

请求参数

参数名必选类型说明

appId

string

从API设置中获取,在直播系统登记的appId

timestamp

long

当前13位毫秒级时间戳,3分钟内有效

sign

String

签名,为32位大写的MD5值,生成签名的appSecret密钥作为通信数据安全的关键信息,严禁保存在客户端直接使用,所有API都必须通过客户自己服务器中转调用POLYV服务器获取响应数据【详见签名生成规则

channelIds

string

频道号,多个频道以,隔开

startDate

string

开始日期格式,yyyy-MM-dd,时间跨度不得超过31天

endDate

string

结束日期格式,yyyy-MM-dd,时间跨度不得超过31天

响应成功JSON示例:

{
    "code": 200,
    "status": "success",
    "message": "",
    "data": [
        {
            "day": "2020-08-16",
            "minute": "00:00",
            "viewers": 0
        },
        {
            "day": "2020-08-17",
            "minute": "00:00",
            "viewers": 2
        },
        {
            "day": "2020-08-18",
            "minute": "00:00",
            "viewers": 0
        }
    ]
}

响应失败JSON示例:

未输入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: 1234567", 
  "data": ""
}

频道号格式错误

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

日期范围错误

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

字段说明

参数名说明

code

响应代码,成功为200,失败为400,签名错误为401,异常错误500

status

成功为success,失败为error

message

错误时为错误提示消息

data

获取多个频道下的历史并发记录(聚合数据)

Java请求示例

public static void main(String[] args) {
        String url = "http://api.polyv.net/live/v3/channel/statistics/concurrence-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("channelId", 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);
    }

Last updated