Polyv Help Center

Help Center

Query Channel Historical Concurrency Data

Updated: 2022-09-02 18:08:07

API Description

1、获取频道在某个日期区间并发人数
2、接口支持https协议

API URL

http://api.polyv.net/live/v3/channel/statistics/concurrence

Online API Call

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details

  2. The time span between start date and end date: maximum of two months of data

  3. Sorted by time in ascending order

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See Get Secret Key
timestamp true Long Current 13-digit millisecond timestamp, valid for 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 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
channelId true String Channel ID
startDate true String Start date, format: yyyy-MM-dd
endDate true String End date, format: yyyy-MM-dd

Example

http://api.polyv.net/live/v3/channel/statistics/concurrence?endDate=2021-3-10&appId=frlr1zazn3&sign=8AAC3157EBB79FF42FA07A72335864A0&userId=1b448be323&channelId=1965681&startDate=2021-3-9&timestamp=1621842387331

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure See Global Error Description
status String Response status text
message String Response description, when code is 400 or 500, provides auxiliary error reason
data Array On success, concurrency data within the date range See Data Parameter Description; on failure, empty
Data Parameter Description
Parameter Type Description
day String Concurrency date, format: yyyy-MM-dd
minute String Concurrency time point, format: HH:mm
viewers Integer Number of concurrent viewers

Java Request Example

For quick integration of basic code, please download the relevant dependency source code. Click here to download source code. After downloading, add it to your own source code project. The HttpUtil.java and LiveSignUtil.java in the test cases are included in the download 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 testConcurrence() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v3/channel/statistics/concurrence";
    String channelId = "1965681";
    String startDate = "2021-3-9";
    String endDate = "2021-3-10";

    //http 调用逻辑
    Map<String,String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp",timestamp);
    requestMap.put("userId",userId);
    requestMap.put("channelId",channelId);
    requestMap.put("startDate",startDate);
    requestMap.put("endDate",endDate);
    requestMap.put("sign",LiveSignUtil.getSign(requestMap, appSecret));
    String response = HttpUtil.get(url, requestMap);
    log.info("测试查询频道历史并发数据,返回值:{}",response);
    //do somethings

}

Response Example

For global error descriptions, see Global Error Description

Success Example

{
    "code":200,
    "status":"success",
    "message":"",
    "data":[
        {
            "day":"2021-03-09",
            "minute":"00:00",
            "viewers":0
        },
        {
            "day":"2021-03-10",
            "minute":"00:00",
            "viewers":0
        }
    ]
}

Error Example

{
    "code": 400,
    "status": "error",
    "message": "invalid signature.",
    "data": ""
}
联系客服,在线咨询