Polyv Help Center

Help Center

Query Channel Real-Time Concurrent Data

Updated: 2025-09-01 14:19:25

API Description

1、在直播中,查询频道实时在线人数
2、接口URL中的{channelId}为频道号
3、接口支持https协议

API URL

http://api.polyv.net/live/v1/statistics/{channelId}/realtime

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. Each channel returns real-time online viewer data for the last 2.5 minutes (one data point every 10 seconds, 15 data points). The result list for each channel is sorted in descending order by time.

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 used directly on the client side. All APIs must be called through your own server to relay requests to the POLYV server for response data. See Signature Generation Rules
userId true String Live streaming account ID

Example

http://api.polyv.net/live/v1/statistics/1965681/realtime?appId=frlr1zazn3&sign=CA1500965A0589D8DC65713B33F63B2D&userId=1b448be323&timestamp=1621842236528

Response Parameter Description

Parameter Type Description
status String Status value
result Array Corresponding result See Result Parameter Description
Result Parameter Description
Parameter Type Description
time String Statistics time, format: HH:mm:ss
count String Real-time viewer count at a given time

Java Request Example

For quick integration of the basic code, please download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded 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 pooling.

private static final Logger log = LoggerFactory.getLogger(ChannelViewDataTest.class);
/**
 * 查询频道实时并发数据
 * @throws IOException
 */
@Test
public void testRealtime() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.appId;
    String appSecret = super.appSecret;
    String userId = super.userId;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = String.format("http://api.polyv.net/live/v1/statistics/%s/realtime","1965681");

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

}

Response Example

For global system error descriptions, see Global Error Description

Successful request example:

{
    "code": 200,
    "status":"success",
    "result":[
        {
            "count":"0",
            "time":"09:55:50"
        },
        {
            "count":"0",
            "time":"09:55:40"
        },
        {
            "count":"0",
            "time":"09:55:30"
        },
        {
            "count":"0",
            "time":"09:55:20"
        },
        {
            "count":"0",
            "time":"09:55:10"
        },
        {
            "count":"0",
            "time":"09:55:00"
        },
        {
            "count":"0",
            "time":"09:54:50"
        },
        {
            "count":"0",
            "time":"09:54:40"
        },
        {
            "count":"0",
            "time":"09:54:30"
        },
        {
            "count":"0",
            "time":"09:54:20"
        },
        {
            "count":"0",
            "time":"09:54:10"
        },
        {
            "count":"0",
            "time":"09:54:00"
        },
        {
            "count":"0",
            "time":"09:53:50"
        },
        {
            "count":"0",
            "time":"09:53:40"
        },
        {
            "count":"0",
            "time":"09:53:30"
        }
    ]
}

Failed request example:

{
    "code":"invalid.request",
    "msg":"signature error."
}
联系客服,在线咨询