logo

Obtain a game start code


Description

To start a live comment-based game on the PC side, this interface must be called before the game starts. Enter the anchor, room, and game information and receive a unique game activation code.

The game activation code is time-sensitive and will become invalid after it expires. It is recommended that the host obtains the game activation code via this interface each time before starting the game. ZEGOCLOUD guarantees that the received game activation code can be used at least once within 2 hours.

Warning

Once the game has started, do not call this interface again to get a new start code, otherwise the current game may be forcibly terminated. Whether the game is forcibly terminated depends on the game. It is recommended that this only be called when starting to play or switching between games.

Request method and endpoint

  • Request method: POST
  • Request URL: https://mini-game-api.zego.im/?Action=DescribeGameLaunchCode
  • Transfer protocol: HTTPS
  • Call frequency limit: 20 times/second (taking the room as the dimension)

Request parameters

The following request parameter list only lists interface request parameters. Please refer to Make API requests for the public parameter list.

ParameterTypeIs it required?Description
RoomIdStringYesRoom ID, defined by you, with a maximum length of 64 characters.
MiniGameIdStringYesGame ID, please contact the ZEGOCLOUD technical support team to obtain relevant content.
AnchorIdStringYesAnchor ID, defined by you, with a maximum length of 48 characters, only allowing numbers and English letters.
NicknameStringYesAnchor nickname, defined by you, with a maximum length of 32 characters.
AvatarStringYesThe address of the anchor's avatar must be a valid HTTP/HTTPS address and have a length of no more than 1024 bytes.
SexintNoAnchor gender.
  • 1:Male.
  • 2:Female.

Request example

  • Request URL

    Untitled
    https://mini-game-api.zego.im/?Action=DescribeGameLaunchCode
    &<Common request parameters>
    
    1
    Copied!
  • Request message body

    Untitled
    {
        "RoomId": "room_123",
        "MiniGameId": "TinyLoveWar",
        "AnchorId": "anchor1",
        "Nickname": "anchor",
        "Avatar": "http://xxx",
        "Sex": 1
    }
    
    1
    Copied!

Response parameters

ParameterTypeDescription
CodeNumberError code.
MessageStringDescription of the request result.
RequestIdStringRequest ID.
DataObjectResponse object.
GameLaunchCodeStringGame activation code.

Response example

Untitled
{
    "Code": 0,
    "Message": "succeed",
    "RequestId": "abcd123",
    "Data": {
        "GameLaunchCode":1011001,
    }
}
1
Copied!

Return code

Only the return codes related to the interface business logic are listed below. For complete return codes, please refer to Global return codes.

Return codeDescriptionHandling suggestions
7202001The game was not found. Possible reasons include:
  • MiniGameId input error.
  • The permissions for this game are not activated.
  • Please check if the MiniGameId is correct.
  • Please contact ZEGOCLOUD business personnel to activate permission for this game.
7202002MiniGameId wrong format.Please confirm whether the format is String.
7206004The room is already occupied by another host.Please confirm whether the AnchorId passed in is consistent with the room owner.
7206005Obtaining game codes too frequently.Please try again later.

Previous

Making API requests

Next

Send likes