logo
Video Call
Server API
Stream Mixing and Transcoding APIs
On this page

RTMPDispatchV2

GET

https://rtc-api.zego.im/

Call this API to initiate RTMP stream dispatching, supporting both "pull" and "push" dispatch modes.

When you need to perform RTMP stream publishing or playing from ZEGOCLOUD's video cloud service through the RTMP protocol, you can use this API to obtain the RTMP publishing or playing nodes. After the developer passes the Stream ID (StreamId), dispatch mode (Type), client IP (ClientIP), and sequence number (Sequence) from the client, the ZEGOCLOUD media server (RTC service) returns a dispatch result set for the client to publish or play streams.

For example, when performing RTMP stream publishing through third-party publishing tools such as OBS, you need to perform publishing dispatch; when you need a third-party player to pull RTMP streams for playback, you need to perform playing dispatch.

Warning

For first-time use of this API, please contact ZEGOCLOUD Technical Support for configuration.

Rate Limit
For the same AppID: 40 times/second

Legacy API Usage Instructions

Note

The difference between RTMPDispatchV2 (recommended) and RTMPDispatch is, when accessing the ZEGOCLOUD server:

  • Using RTMPDispatchV2, the ZEGOCLOUD server returns Data in URL format.
  • Using RTMPDispatch, the ZEGOCLOUD server returns Data in IP
    format.

Request URL: https://rtc-api.zego.im/?Action=RTMPDispatch

Response example:

{
    "Code":0,
    "Message":"ok",
    "RequestId":"5094436160208407316",
    "Data":[
        "81.69.49.115:1935"
    ]
}

Note

In the test environment (see the IsTest common parameter description for details), the Stream ID must be prefixed with "zegotest-AppId-". For example, if the Stream ID is "test" and the AppId is "123456789" in the test environment, the Stream ID should be "zegotest-123456789-test".

Request

Query Parameters

    Action stringrequired

    Possible values: [RTMPDispatchV2]

    API prototype parameters

    https://rtc-api.zego.im?Action=RTMPDispatchV2

    AppId uint32required

    💡Public parameter. Application ID, assigned by ZEGOCLOUD. Get it from the ZEGOCLOUD Admin Console.

    SignatureNonce stringrequired

    💡Common parameter. A 16-character hexadecimal random string (hex-encoded 8-byte random number). For the generation algorithm, refer to the signature example.

    Timestamp int64required

    💡Common parameter. Current Unix timestamp in seconds. For the generation algorithm, refer to the signature example. A maximum deviation of 10 minutes is allowed.

    Signature stringrequired

    💡Common parameter. Signature used to verify the legitimacy of the request. Please refer to the signature mechanism to generate it.

    SignatureVersion stringrequired

    Possible values: [2.0]

    Default value: 2.0

    💡Public parameter. Signature version number.

    StreamId stringrequired

    Stream ID, a string with a maximum length of 256 characters.

    • The Stream ID is defined by you.
    • When publishing streams, it must be globally unique within the entire AppID. If different users publish streams with the same stream name within the same AppID, the later publishing user will fail to publish.
    • Only supports numbers, English characters, '-', and '_'.
    Sequence Int64required

    Request sequence number; only used for request reconciliation. Using a timestamp (millisecond level) is recommended.

    Type stringrequired

    Dispatch mode:

    • pull: Get the RTMP playing node
    • push: Get the RTMP publishing node
    ClientIP string

    Optional. If provided, pass the client IP address, for example: 119.23.242.129.

    Note

    IPv6 format IP addresses are not currently supported.

Responses

Success
Schema
    Code number

    Return code. The following only lists some return codes related to the API business logic. For the complete return codes, please refer to Global Return Codes.

    Return CodeDescriptionSuggested Action
    1010, 30002API call rate too high.Please reduce the API request frequency.
    1001Dispatch failed.Please contact ZEGOCLOUD Technical Support.
    1002Publishing node is empty.Please contact ZEGOCLOUD Technical Support.
    1003Playing node is empty.Please contact ZEGOCLOUD Technical Support.
    1005App is not online.Please contact ZEGOCLOUD Technical Support.
    1006Invalid parameter.Please contact ZEGOCLOUD Technical Support.
    30003Internal error.Please contact ZEGOCLOUD Technical Support.
    30004Incorrect isTest parameter.Please check if the isTest common parameter is correct.
    30005Invalid AppId.Please check if the AppId is correct.
    30009Invalid StreamId, stream name does not conform to specifications.Please check if the StreamId conforms to the stream name encoding specifications.
    30010Invalid dispatch action.Please check if the Type is correct.
    30011Invalid client IP address.Please check if the ClientIP is correct.
    Message string

    Operation result description

    RequestId string

    Request ID

    Data object

    RTMP publishing or playing node.

    Note

    After obtaining this node, please initiate stream publishing or playing within 2 hours, otherwise the node may be occupied or taken offline. Therefore, it is recommended to call this API each time you perform RTMP stream publishing or playing to obtain the latest node.

Previous

ClearCDNTransferRule

Next

DescribeRTCStreamState

On this page

Back to top