Polyv Help Center

Help Center

Batch Add Distribution Addresses

Updated: 2023-04-04 09:31:23

API Description

1、批量添加分发地址
2、接口支持https协议

API URL

http://api.polyv.net/live/v4/channel/distribute/create-batch

Online API Call

Request Method

POST

API Constraints

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

  2. Only channels using the pure video or pure video-express (formerly large class) live streaming templates support cloud distribution.

  3. The account must have the cloud distribution feature enabled.

  4. Maximum number of cloud distribution addresses: 50

Request Parameter Description

Parameter Required Type Description
appId true String Account appId See details in Get Secret Key
timestamp true Long Current 13-digit millisecond timestamp, valid within 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 not be stored 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 for response data. See details in Signature Generation Rules
channelId true String Channel ID

Request Body Parameter Description

Type Required Description
Array true List of distribution address request objects See details in contents field description

contents Parameter Description

Parameter Required Type Description
name true String Distribution address name, length cannot exceed 20 characters
distributeUrl true String Push stream address (duplicate push stream addresses are not allowed), e.g., rtmp://polyv.net, must start with rtmp://, http://、https://
distributeLiveCode false String Live stream code
status false String Distribution live push stream switch. Default is off if not provided.
Y: On
N: Off

Example

http://api.polyv.net/live/v4/channel/distribute/create-batch?appId=frlr1zazn3&sign=5207B665940EBF63050816F6354E4E9C&channelId=2272655&timestamp=1639731659206

Request body JSON parameters:

[
    {
        "distributeUrl": "rtmp://xxx.xxxx.xxx",
        "distributeLiveCode": "test",
        "name": "测试添加云分发",
        "status": "Y"
    }
]

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 Boolean Returns true on success
error Object Error information when status code is non-200 See details in Error field 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 identify the specific error cause
desc String Error description, corresponding to error.code

Java Request Example

For quick integration of 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 HttpUtil.java and LiveSignUtil.java in the test cases are included 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 pools.

private static final Logger log = LoggerFactory.getLogger(getClass());
/**
 * 批量添加分发地址
 * @throws IOException
 */
@Test
public void createBatch() 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/v4/channel/distribute/create-batch";
    String channelId = "2272655";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("channelId", channelId);
    
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    url = HttpUtil.appendUrl(url, requestMap);
    
    List<Map<String, String>> bodyList = new ArrayList<>();
    Map<String, String> bodyMap = new HashMap<>();
    bodyMap.put("name", "测试添加云分发");
    bodyMap.put("distributeUrl", "rtmp://xxx.xxxx.xxx");
    bodyMap.put("distributeLiveCode", "test");
    bodyMap.put("status", "Y");
    bodyList.add(bodyMap);
    
    String body = JSON.toJSONString(bodyList);
    
    String response = HttpUtil.postJsonBody(url, body, null);
    log.info("测试批量添加分发地址,返回值:{}", response);
    //do somethings
    
}

Response Example

For global system error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "a3623143b746448a805248f51d79f3d3.1887.16397316623890641",
    "data": true,
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "requestId": "e2e23029f14a46098842dde4d8f097b4.1945.16397317588520117",
    "error": {
        "code": 10001,
        "desc": "推流地址不能为空"
    },
    "data": null,
    "success": false
}
联系客服,在线咨询