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

接口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值
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);
    }

签名规则(PolyvTool.java文件代码查看)

https://dev.polyv.net/2020/liveproduct/l-api/rule/live-api-java-detail/

以上内容是否对您有帮助?根本没有帮助文档较差文档一般文档不错文档很好
Loading...