Polyv Help Center

Help Center

channelDistribute

Updated: 2025-09-11 15:18:09

1. Query Distribution Address Information

Description

查询分发地址信息
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/list

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testListChannelDistribute() throws IOException, NoSuchAlgorithmException {
        LiveChannelDistributeListRequest liveChannelDistributeListRequest = new LiveChannelDistributeListRequest();
        LiveChannelDistributeListResponse liveChannelDistributeListResponse;
        try {
            liveChannelDistributeListRequest.setChannelId(super.getAloneChannelId());
            liveChannelDistributeListResponse = new LiveChannelDistributeServiceImpl().listChannelDistribute(
                    liveChannelDistributeListRequest);
            Assert.assertNotNull(liveChannelDistributeListResponse);
            if (liveChannelDistributeListResponse != null) {
                //to do something ......
                log.debug("测试查询分发地址信息成功 {}", JSON.toJSONString(liveChannelDistributeListResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a LiveChannelDistributeListResponse object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
distributeIds false String Distribution IDs, separated by commas. If not passed, all distribution addresses under the channel are queried by default.
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).

Return Object Description

Parameter Name Type Description
distributeEnable String Channel distribution live broadcast master switch. Y: Enabled, N: Disabled.
result Array List of distribution address response objects [See ChannelDistribute Parameter Description for details].
ChannelDistribute Parameter Description
Parameter Name Type Description
id Integer Cloud distribution ID
channelId String Channel ID
name String Distribution address name
distributeUrl String Push stream URL
distributeLiveCode String Live stream code
status String Distribution live switch. Y: On, N: Off.
connectionStatus String Connection status. completed: Ended, processing: Transcoding, waiting: Waiting for connection, error: Transcoding failed.






2. Batch Add Distribution Addresses

Description

批量添加分发地址
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/create-batch

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

  2. Only channels with the "Video Only" or "Video Only - Express (formerly Large Class)" live template support cloud distribution.

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

  4. Maximum number of cloud distribution addresses: 15.

Unit Test

    @Test
    public void testCreateChannelDistribute() throws IOException, NoSuchAlgorithmException {
        LiveChannelDistributeCreateRequest liveChannelDistributeCreateRequest =
                new LiveChannelDistributeCreateRequest();
        Boolean liveChannelDistributeCreateResponse;
        try {
            String channelId = super.getAloneNewChannelId();
            LiveChannelDistributeCreateRequest.CreateDistribute createDistribute =
                    new LiveChannelDistributeCreateRequest.CreateDistribute();
            createDistribute.setName("SDK测试云分发")
                    .setDistributeUrl("rtmp://xx.xxx")
                    .setDistributeLiveCode(super.getRandomString(6))
                    .setStatus(LiveConstant.Flag.YES.getFlag());
            liveChannelDistributeCreateRequest.setChannelId(channelId).setContents(Arrays.asList(createDistribute));
            liveChannelDistributeCreateResponse = new LiveChannelDistributeServiceImpl().createChannelDistribute(
                    liveChannelDistributeCreateRequest);
            Assert.assertTrue(liveChannelDistributeCreateResponse);
            if (liveChannelDistributeCreateResponse) {
                //to do something ......
                log.debug("测试批量添加分发地址成功");
                //TODO 此处创建完成后删除了分发地址,正式使用需删除该语句
                super.deleteChannelDistribute(channelId, getChannelDistributeId(channelId));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
contents true Array List of distribution address request objects [See CreateDistribute Parameter Description for details].
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
CreateDistribute Parameter Description
Parameter Name Required Type Description
name true String Distribution address name, maximum length 20 characters.
distributeUrl true String Push stream URL (duplicate URLs are not allowed). Example: rtmp://polyv.net. Must match regex: (^([rR][tT][mM][pP]://)([\w-]+.)+[\w-]+(/[\w-./?%#&=]*)?$)
distributeLiveCode false String Live stream code
status false String Distribution live push switch. Default is off if not passed. Y: On, N: Off.

Return Object Description

Entity returned for batch adding distribution addresses.




3. Batch Modify Distribution Addresses

Description

修改分发地址
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/update-batch

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

  2. The push stream URL cannot be modified while distribution is actively pushing.

Unit Test

    @Test
    public void testUpdateChannelDistribute() throws IOException, NoSuchAlgorithmException {
        LiveChannelDistributeUpdateRequest liveChannelDistributeUpdateRequest =
                new LiveChannelDistributeUpdateRequest();
        Boolean liveChannelDistributeUpdateResponse;
        try {
            String channelId = super.getAloneNewChannelId();
            LiveChannelDistributeUpdateRequest.UpdateDistribute updateDistribute =
                    new LiveChannelDistributeUpdateRequest.UpdateDistribute();
            updateDistribute.setId(super.getChannelDistributeId(channelId))
                    .setName("SDK测试修改云分发")
                    .setDistributeUrl("rtmp://xxxx.xxx")
                    .setDistributeLiveCode(super.getRandomString(6));
            liveChannelDistributeUpdateRequest.setChannelId(channelId).setContents(Arrays.asList(updateDistribute));
            liveChannelDistributeUpdateResponse = new LiveChannelDistributeServiceImpl().updateChannelDistribute(
                    liveChannelDistributeUpdateRequest);
            Assert.assertTrue(liveChannelDistributeUpdateResponse);
            if (liveChannelDistributeUpdateResponse) {
                //to do something ......
                log.debug("测试批量修改分分发地址成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
contents true Array List of distribution address request objects [See UpdateDistribute Parameter Description for details].
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
UpdateDistribute Parameter Description
Parameter Name Required Type Description
id true Integer Cloud distribution ID
name false String Distribution address name, maximum length 20 characters.
distributeUrl false String Push stream URL. Example: rtmp://polyv.net. Must match regex: (^([rR][tT][mM][pP]://)([\w-]+.)+[\w-]+(/[\w-./?%#&=]*)?$)
distributeLiveCode false String Live stream code

Return Object Description

Entity returned for batch modifying distribution addresses.




4. Batch Delete Distribution Addresses

Description

批量删除分发地址
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/delete-batch

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

  2. Distribution addresses cannot be deleted while distribution is actively pushing.

Unit Test

    @Test
    public void testDeleteChannelDistribute() throws IOException, NoSuchAlgorithmException {
        LiveChannelDistributeDeleteRequest liveChannelDistributeDeleteRequest =
                new LiveChannelDistributeDeleteRequest();
        Boolean liveChannelDistributeDeleteResponse;
        try {
            String channelId = super.getAloneNewChannelId();
            liveChannelDistributeDeleteRequest.setChannelId(channelId).setDistributeIds("3884,3885");
            liveChannelDistributeDeleteResponse = new LiveChannelDistributeServiceImpl().deleteChannelDistribute(
                    liveChannelDistributeDeleteRequest);
            Assert.assertTrue(liveChannelDistributeDeleteResponse);
            if (liveChannelDistributeDeleteResponse) {
                //to do something ......
                log.debug("测试批量删除分发地址成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
distributeIds true String Distribution IDs, separated by commas.
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).

Return Object Description

Entity returned for batch deleting distribution addresses.




5. Modify Cloud Distribution Channel Master Switch

Description

修改单个频道云分发总开关,该功能需要超管开通才生效
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/update-master-switch

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateMasterSwitch() throws IOException, NoSuchAlgorithmException {
        LiveDistributeUpdateMasterSwitchRequest liveDistributeUpdateMasterSwitchRequest =
                new LiveDistributeUpdateMasterSwitchRequest();
        Boolean liveDistributeUpdateMasterSwitchResponse;
        try {
            String channelId = super.createChannel();
            liveDistributeUpdateMasterSwitchRequest.setChannelId(channelId)
                    .setDistributeEnabled(LiveConstant.Flag.YES.getFlag());
            liveDistributeUpdateMasterSwitchResponse = new LiveChannelDistributeServiceImpl().updateMasterSwitch(
                    liveDistributeUpdateMasterSwitchRequest);
            Assert.assertTrue(liveDistributeUpdateMasterSwitchResponse);
            if (liveDistributeUpdateMasterSwitchResponse) {
                //to do something ......
                log.debug("测试修改云分发频道总开关成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
distributeEnabled false String Channel cloud distribution master switch. Y: Enable, N: Disable. Default is Y.
enforce false String Whether to force disable. Y: Force disable, N: Non-force disable. Default is N. When non-force disable is used, the API will throw an exception if the channel is actively live streaming.
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).

Return Object Description

Entity returned for modifying the cloud distribution channel master switch.




6. Batch Modify Channel Cloud Distribution Switches

Description

批量修改频道云分发开关,该功能需要超管开通才生效
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/update-switch

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateSwitch() throws IOException, NoSuchAlgorithmException {
        LiveDistributeUpdateSwitchRequest liveDistributeUpdateSwitchRequest = new LiveDistributeUpdateSwitchRequest();
        Boolean liveDistributeUpdateSwitchResponse;
        try {
            String channelId = super.getAloneNewChannelId();
            liveDistributeUpdateSwitchRequest.setChannelId(channelId)
                    .setDistributeIds(String.valueOf(super.getChannelDistributeId(channelId)))
                    .setDistributeEnabled(LiveConstant.Flag.YES.getFlag());
            liveDistributeUpdateSwitchResponse = new LiveChannelDistributeServiceImpl().updateSwitch(
                    liveDistributeUpdateSwitchRequest);
            Assert.assertTrue(liveDistributeUpdateSwitchResponse);
            if (liveDistributeUpdateSwitchResponse) {
                //to do something ......
                log.debug("测试批量修改频道云分发开关成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. If the request is correct, a Boolean object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
distributeIds true String Cloud distribution list IDs, separated by commas.
distributeEnabled false String Cloud distribution switch. Y: Enable, N: Disable. Default is N.
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).

Return Object Description

Entity returned for batch modifying channel cloud distribution switches.




7. Query Cloud Distribution Data Information

Description

查询频道云分发数据信息
接口地址(仅做说明使用):https://api.polyv.net/live/v4/channel/distribute/get/statistic

Call Constraints

  1. API calls are rate-limited. Click here for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetDistributeStatistic() throws IOException, NoSuchAlgorithmException {
        LiveChannelDistributeStatisticRequest liveChannelDistributeStatisticRequest =
                new LiveChannelDistributeStatisticRequest();
        List<LiveChannelDistributeStatisticResponse> liveChannelDistributeStatisticResponse;
        try {
            String channelId = super.getAloneNewChannelId();
            liveChannelDistributeStatisticRequest.setChannelId(channelId)
                    .setSessionIds("g57pg85h1x")
                    .setStartTime(super.getDate(1639668105000L))
                    .setEndTime(super.getDate(1639679787000L));
            liveChannelDistributeStatisticResponse = new LiveChannelDistributeServiceImpl().getDistributeStatistic(
                    liveChannelDistributeStatisticRequest);
            Assert.assertNotNull(liveChannelDistributeStatisticResponse);
            if (liveChannelDistributeStatisticResponse != null) {
                //to do something ......
                log.debug("测试查询云分发数据信息成功 {}", JSON.toJSONString(liveChannelDistributeStatisticResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }
}

Unit Test Description

  1. If the request is correct, a LiveChannelDistributeStatisticResponse object is returned, and the B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Input parameter [xxx.chat.LivexxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty]].

  3. If the server encounters an error, a PloyvSdkException is thrown. The error message can be found in PloyvSdkException.getMessage(), e.g., [Polyv request returned data error, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature.]

Request Parameter Description

Parameter Name Required Type Description
channelId true String Channel ID
sessionIds false String Channel session IDs, separated by commas. Session IDs and live start/end times cannot both be empty.
startTime false Date Live start time. Session IDs and live start/end times cannot both be empty.
endTime false Date Live end time. Session IDs and live start/end times cannot both be empty.
appId false String POLYV user APP_ID. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official website: Official Website -> Login -> Live (Development Settings).
appSecret false String POLYV user APP_SECRET. Required for multi-account calls (i.e., when initMultiAccount() is called). Obtain from the Polyv official
联系客服,在线咨询