Polyv Help Center

Help Center

Query Cloud Distribution Data Information

Updated: 2022-09-15 09:50:53

API Description

1、查询频道云分发数据信息
2、接口支持https协议

API URL

http://api.polyv.net/live/v4/channel/distribute/get/statistic

Online API Call

Request Method

GET

API Constraints

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

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
sessionIds false String Channel session IDs, separated by commas. Session IDs and the live broadcast start/end time cannot both be empty.
startTime false Long Live broadcast start time, timestamp. Session IDs and the live broadcast start/end time cannot both be empty.
endTime false Long Live broadcast end time, timestamp. Session IDs and the live broadcast start/end time cannot both be empty.

Example

http://api.polyv.net/live/v4/channel/distribute/get/statistic?channelId=2272655&sessionIds=g56jkqt1de&sign=D6CD205D3B028B08F7o7CC3D9709CCFA&appId=frlr1zazn3&timestamp=1639731851000

Response Parameter Description

Parameter Type Description
code Integer Response status code, 200 for success, non-200 for failure
status String Response result, determined by business logic. Returns success on success, error on failure
success Boolean Response result, determined by business logic. Returns true on success, false on failure
data Array Data information returned on successful response See Data Parameter Description
error Object Error information when status code is non-200 See Error Parameter Description
requestId String Request ID, a unique UUID generated for each request. Only used for troubleshooting and debugging, should not be tied to business logic

Error Parameter Description

Parameter Type Description
code Integer Error code, used to determine the specific error cause
desc String Error description, corresponding to error.code

Data Parameter Description

Parameter Type Description
channelId Integer Channel ID
sessionId String Session ID
liveStartTime Long Live broadcast start time, timestamp
liveEndTime Long Live broadcast end time, timestamp
distributeUrl String Cloud distribution push URL
distributeStartTime Long Push start time, timestamp
distributeEndTime Long Push end time, timestamp
duration Integer Cloud distribution duration, in seconds
desc String Error description, corresponding to error.code

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, both contained in the download file.

It is strongly recommended to use the Live Java SDK for API functionality 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(getClass());

/**
 * 查询云分发数据信息
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void testGetStatistic() throws IOException, NoSuchAlgorithmException {
    String appId = super.appId;
    String appSecret = super.appSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());
    //业务参数
    String url = "http://api.polyv.net/live/v4/channel/distribute/get/statistic";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("channelId", "2272655");
    requestMap.put("sessionIds", "g56jkqt1de");
    
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    url = HttpUtil.appendUrl(url,requestMap);
    String response = HttpUtil.postFormBody(url,null);
    
    log.info("测试查询云分发数据信息,返回值:{}", response);
}

Response Example

For system-wide error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "192d744e4afe46f69fbbdc5919974664.71.16397337099116719",
    "data": [
        {
            "channelId": 2272655,
            "sessionId": "g56jkqt1de",
            "liveStartTime": 1639577654000,
            "liveEndTime": 1639577794000,
            "name": null,
            "distributeLiveCode": null,
            "distributeUrl": "rtmp://tx.direct.huya.com/huyalive/304817310-304817310-7039957867407750754-609758076-10057-A-1639400551-1?seq=1639117923922&type=simple",
            "distributeStartTime": 1639577684000,
            "distributeEndTime": 1639577784000,
            "duration": 99
        }
    ],
    "success": true
}

Error Example

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