API reference

更新时间:
复制 MD 格式

This topic describes the API operations about AUI Kits for voice chat rooms.

/login

You can implement this operation based on your business requirements. For example, you can specify the algorithm that is used to generate the token. In this case, make sure that the token is generated and verified by using the same algorithm.

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /login

  • Whether authorization is required: No

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

username

String

Yes

usernamexxx

The username.

password

String

Yes

passwordxxxx

The password.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

expire

String

2023-02-28T14:38:06+08:00

The time when the token expired. The time is displayed in UTC.

token

String

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9***

The authorization token. By default, the token is generated by using a JSON Web Token (JWT) application.

Examples

Sample requests

{
 "username":"usernamexxx",
 "password":"passwordxxxx"
}

Sample success responses

{
 "username":"usernamexxx",
 "password":"passwordxxxx"
}

/api/chatroom/token

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/token

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

user_id

String

Yes

useridxxxx

The user ID, which is a unique string within an application.

role

String

No

admin

The role of the user. By default, this parameter is empty. If you set this parameter to admin, the user can call management operations.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

aliyun_im

app_id

String

None

The application ID of the user.

app_sign

String

None

The encrypted string generated by the server, which contains information such as the domain name.

app_token

String

None

The authentication token for logon.

auth.user_id

String

None

The user ID.

auth.nonce

String

None

The nonce for authentication. The nonce is returned in the AK-String format and can be up to 64 bytes in length.

auth.timestamp

Long

None

The time when the token expired. This value is a UNIX timestamp representing the number of seconds that have elapsed since January 1, 1970, 00:00:00 UTC.

auth.role

String

None

The role of the user. If the value is admin, the user can call management operations.

Examples

Sample requests

{
 "user_id": "useridxxxx",
 "role":"admin"
}

Sample success responses

{
 "code": 200,
 "aliyun_im":{
    	"appid":"xxxx",
      "appsign":"xxxx",
   		"apptoken":"xxxxxxxxxxxxxxxxxx",
   		"auth":{
         "userid":"xxxx",
         "nonce":"xxxxx", // This parameter can be empty.
          "timestamp":xxxxx,
          "role":"admin"
    	}
  }
}

/api/chatroom/create

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/create

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

title

String

Yes

titlexxxx

The title of the chat room.

notice

String

No

noticexxx

The announcement about the chat room.

anchor

String

Yes

anchorxxxx

The streamer ID.

anchor_nick

String

No

anchornickxxxx

The nickname of the streamer.

extends

String

No

{"xx":"xxx"}

The extended fields. The value is a JSON string.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

id

String

ee487235-5f9b-4cb3-82ce-45c91c3xxxx

The ID of the chat room.

created_at

String

2023-02-27T17:34:00.592750182+08:00

The time when the chat room was created.

updated_at

String

2023-02-27T17:34:00.592750182+08:00

The time when the chat room was last modified.

title

String

titlexxx

The title of the chat room.

notice

String

noticexxx

The announcement about the chat room.

cover_url

String

None

The thumbnail of the chat room. This parameter is a reserved parameter.

anchor_id

String

anchor_idxxx

The streamer ID.

anchor_nick

String

anchor_nickxxx

The nickname of the streamer.

meetingInfo

String

{"xxx":"xxxx"}

The co-streaming information. The value is a JSON string.

show_code

Integer

65611075

The channel ID.

extends

String

{"xx":"xxx"}

The extended fields.

status

Integer

0

The state of the chat room. Valid values:

  • 1: The chat room is started.

  • 2: The chat room is dismissed.

chat_id

String

ee487235-5f9b-4cb3-82ce-45c91c3xxxx

The ID of the instant messaging (IM) group.

Examples

Sample requests

{
 "title": "titlexxx",
 "notice": "noticexxx",
 "anchor":"Streamer ID",
 "anchor_nick":"Streamer nickname",
 "extends":"{\"xx\":\"xxx\"}"
}

Sample success responses

{
    "code": 200,
    "anchor_id": "Streamer ID",
    "show_code": 65611075,
    "extends": "{\"xx\":\"xxx\"}",
    "updated_at": "2024-03-14T20:42:59",
    "created_at": "2024-03-14T20:42:59",
    "meetingInfo": "{\"members\":[{\"index\":1,\"joined\":false,\"user_id\":\"\"},{\"index\":2,\"joined\":false,\"user_id\":\"\"},{\"index\":3,\"joined\":false,\"user_id\":\"\"},{\"index\":4,\"joined\":false,\"user_id\":\"\"},{\"index\":5,\"joined\":false,\"user_id\":\"\"},{\"index\":6,\"joined\":false,\"user_id\":\"\"},{\"index\":7,\"joined\":false,\"user_id\":\"\"},{\"index\":8,\"joined\":false,\"user_id\":\"\"}]}",
    "id": "cfa4a59e90ab42cbaf708f218ad1****",
    "anchor_nick": "Streamer nickname",
    "title": "Test of interactive chat",
    "chat_id": "cfa4a59e90ab42cbaf708f218ad1****",
    "notice": "23232",
    "status": 1
}

/api/chatroom/list

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/list

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

user_id

String

No

useridxxx

The user ID.

page_num

Integer

Yes

1

The page number. Default value: 1.

page_size

Integer

Yes

10

The number of entries per page. Default value: 10.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

id

String

ee487235-5f9b-4cb3-82ce-45c91c3xxxx

The ID of the chat room.

created_at

String

2023-02-27T17:34:00.592750182+08:00

The time when the chat room was created.

updated_at

String

2023-02-27T17:34:00.592750182+08:00

The time when the chat room was last modified.

started_at

String

2023-02-27T18:54:37+08:00

The time when the chat room was started.

stopped_at

String

2023-02-27T19:25:37+08:00

The time when the chat room was dismissed.

title

String

titlexxx

The title of the chat room.

notice

String

noticexxx

The announcement about the chat room.

cover_url

String

None

The thumbnail of the chat room. This parameter is a reserved parameter.

anchor_id

String

anchor_idxxx

The streamer ID.

anchor_nick

String

anchor_nickxxx

The nickname of the streamer.

meetingInfo

String

{"xxx":"xxxx"}

The co-streaming information. The value is a JSON string.

show_code

Integer

65611075

The channel ID.

metrics

jsonObject

None

The related statistics.

metrics.online_count

Long

20

The number of online users in the chat room.

extends

String

{"xx":"xxx"}

The extended fields.

status

Integer

0

The state of the chat room. Valid values:

  • 1: The chat room is normal.

  • 2: The chat room is dismissed.

chat_id

String

ee487235-5f9b-4cb3-82ce-45c91c3xxxx

The ID of the IM group.

Examples

Sample requests

{
 "page_size": 10,
 "page_num":1,
 "user_id": "useridxxxx"
}

Sample success responses

{
    "rooms": [
        {
            "id": "08a5d321d5f74d72bcbd87c5e41a57f4",
            "title": "hhh chat room",
            "status": 1,
            "created_at": "2024-03-14T21:06:52",
            "updated_at": "2024-03-14T21:06:52",
            "extends": "{\n  \"anchor_avatar\" : \"https:\/\/img.alicdn.com\/imgextra\/i2\/O1CN01VYKjf81Z1savmhLOr_!!6000000003135-0-tps-174-174.jpg\"\n}",
            "chat_id": "08a5d321d5f74d72bcbd87c5e41a****",
            "anchor_id": "hhh",
            "anchor_nick": "hhh",
            "show_code": 32611075,
            "metrics": {
                "online_count": 0
            }
        },
        {
            "id": "cfa4a59e90ab42cbaf708f218ad1****",
            "title": "Test of interactive chat",
            "status": 1,
            "notice": "23232",
            "meetingInfo": "{\"members\":[{\"index\":1,\"join_time\":1710420349667,\"joined\":true,\"user_id\":\"assd\"},{\"index\":2,\"join_time\":1710420408513,\"joined\":true,\"user_id\":\"33334\"},{\"extends\":\"{\\\"nick\\\":\\\"xx33xx\\\",\\\"ava\\\":\\\"bb333bb\\\"}\",\"index\":3,\"join_time\":1710421936486,\"joined\":true,\"user_id\":\"333310\"},{\"index\":4,\"join_time\":1710420417941,\"joined\":true,\"user_id\":\"33335\"},{\"index\":5,\"join_time\":1710420423408,\"joined\":true,\"user_id\":\"33336\"},{\"index\":6,\"join_time\":1710420428932,\"joined\":true,\"user_id\":\"33337\"},{\"index\":7,\"join_time\":1710420436877,\"joined\":true,\"user_id\":\"33338\"},{\"index\":8,\"join_time\":1710420441424,\"joined\":true,\"user_id\":\"33339\"}]}",
            "created_at": "2024-03-14T20:42:59",
            "updated_at": "2024-03-14T20:42:59",
            "extends": "{\"xx\":\"xxx\"}",
            "chat_id": "cfa4a59e90ab42cbaf708f218ad1****",
            "anchor_id": "Streamer ID",
            "anchor_nick": "Streamer nickname",
            "metrics": {
                "online_count": 0
            }
        },
        {
            "id": "cd6a4f31f3ad4593924c4081ddb9****",
            "title": "admin chat room",
            "status": 1,
            "created_at": "2024-03-14T19:24:29",
            "updated_at": "2024-03-14T19:24:29",
            "chat_id": "cd6a4f31f3ad4593924c4081ddb9****",
            "anchor_id": "admin",
            "anchor_nick": "admin",
            "show_code": 1612375,
            "metrics": {
                "online_count": 0
            }
        },
        {
            "id": "25f5346e1e1342289ebdf6c1ff92****",
            "title": "admin chat room",
            "status": 1,
            "created_at": "2024-03-13T16:10:50",
            "updated_at": "2024-03-13T16:10:50",
            "chat_id": "25f5346e1e1342289ebdf6c1ff92****",
            "anchor_id": "admin",
            "anchor_nick": "admin",
            "show_code": 1112375,
            "metrics": {
                "online_count": 0
            }
        }
    ],
    "code": 200
}

/api/chatroom/get

This operation is implemented in the same way as the /api/chatroom/list operation. This operation also returns the information about a chat room that has been dismissed.

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/get

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The ID of the chat room.

user_id

String

No

useridxxx

The user ID.

Response parameters

This operation is implemented in the same way as the /api/chatroom/list operation. This operation returns the information about a single chat room.

Examples

Sample requests

{
 "id": "675e6783-0bac-4990-b6da-5aa89053****",
 "user_id": "Cedric8"
}

Sample success responses

{
    "code": 200,
    "anchor_id": "Streamer ID",
    "created_at": "2024-03-14T20:42:59",
    "title": "Test of interactive chat",
    "chat_id": "cfa4a59e90ab42cbaf708f218ad1****",
    "extends": "{\"xx\":\"xxx\"}",
    "updated_at": "2024-03-14T20:42:59",
    "meetingInfo": "{\"members\":[{\"index\":1,\"join_time\":1710420349667,\"joined\":true,\"user_id\":\"assd\"},{\"index\":2,\"join_time\":1710420408513,\"joined\":true,\"user_id\":\"33334\"},{\"extends\":\"{\\\"nick\\\":\\\"xx33xx\\\",\\\"ava\\\":\\\"bb333bb\\\"}\",\"index\":3,\"join_time\":1710421936486,\"joined\":true,\"user_id\":\"333310\"},{\"index\":4,\"join_time\":1710420417941,\"joined\":true,\"user_id\":\"33335\"},{\"index\":5,\"join_time\":1710420423408,\"joined\":true,\"user_id\":\"33336\"},{\"index\":6,\"join_time\":1710420428932,\"joined\":true,\"user_id\":\"33337\"},{\"index\":7,\"join_time\":1710420436877,\"joined\":true,\"user_id\":\"33338\"},{\"index\":8,\"join_time\":1710420441424,\"joined\":true,\"user_id\":\"33339\"}]}",
    "id": "cfa4a59e90ab42cbaf708f218ad1****",
    "show_code": 232275,
    "metrics": {
        "online_count": 0
    },
    "anchor_nick": "Streamer nickname",
    "notice": "23232",
    "status": 1
}

/api/chatroom/getRtcAuthToken

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/getRtcAuthToken

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

room_id

String

Yes

chatroomIdxxxx

The ID of the chat room.

user_id

String

Yes

useridxxxx

The user ID, which is a unique string within an application.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

authToken

String

ee487235-5f9b-4cb3-82ce-45c91c3xxxx

The Real-Time Communication (RTC) token.

timestamp

Long

None

The time when the token expired. Unit: seconds. By default, the token is valid within 24 hours.

Examples

Sample requests

{
 "room_id": "675e6783-0bac-4990-b6da-5aa89053****",
 "user_id": "useridxxxx"
}

Sample success responses

{
 "code": 200,
 "authToken": "xxxxx",
 "timestamp": 12323XXXX
}

/api/chatroom/dismiss

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/dismiss

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The ID of the chat room.

user_id

String

Yes

useridxxxx

The user ID, which is a unique string within an application.

Response parameters

Parameter

Type

Example

Description

success

bool

true

Indicates whether the request was successful.

Examples

Sample requests

{
 "id": "675e6783-0bac-4990-b6da-5aa89053****",
 "user_id": "useridxxxx"
}

Sample success responses

{
    "code": 200,
    "success": true
}

/api/chatroom/joinMic

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/joinMic

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The ID of the chat room.

user_id

String

Yes

useridxxxx

The user ID, which is a unique string within an application.

index

Integer

No

3

The specified member seat. You can leave this parameter empty. If the member seat is specified, the specified member seat is used to start the co-streaming. If the specified member seat has been used by another user, another available member seat is used to start the co-streaming.

extends

String

No

{"user_avatrar":"xxxx"}

The extended information. You can specify custom content.

Response parameters

Parameter

Type

Example

Description

code

Integer

200

The response code. For more information, see HTTP status codes.

members

Array

None

The co-streaming information.

[]members.user_id

String

None

N/A

[]members.joined

Boolean

true

  • true: The co-streaming starts.

  • false: The co-streaming is not performed.

[]members.index

Integer

3

The member seat.

[]members.extends

String

{"user_avatrar":"xxxx"}

The extended information. The value is a JSON string. Custom content can be returned.

[]members.join_time

Long

1710420349667

The time when the co-streaming started.

Examples

Sample requests

{
    "id": "d34e834e029f44eb92db5868ee93****",
    "user_id": "bbb",
    "extends":"{\"aaa\":\"bbb\"}"
}

Sample success responses

{
    "code": 200,
    "members": [
        {
            "user_id": "assd",
            "joined": true,
            "index": 1,
            "join_time": 1710420349667
        },
        {
            "user_id": "33334",
            "joined": true,
            "index": 2,
            "join_time": 1710420408513
        },
        {
            "extends": "{\"user_nick\":\"xx33xx\",\"user_avatrar\":\"bb333bb\"}",
            "user_id": "333310",
            "joined": true,
            "index": 3,
            "join_time": 1710421224316
        },
        {
            "user_id": "33335",
            "joined": true,
            "index": 4,
            "join_time": 1710420417941
        },
        {
            "user_id": "33336",
            "joined": true,
            "index": 5,
            "join_time": 1710420423408
        },
        {
            "user_id": "33337",
            "joined": true,
            "index": 6,
            "join_time": 1710420428932
        },
        {
            "user_id": "33338",
            "joined": true,
            "index": 7,
            "join_time": 1710420436877
        },
        {
            "user_id": "33339",
            "joined": true,
            "index": 8,
            "join_time": 1710420441424
        }
    ]
}

Exceptions

If the returned data contains a reason, business exceptions occurred. In this case, you can handle this issue based on the returned reason.

  • If the value of the reason parameter is 1, no member seat is available.

{
    "reason": 1,
    "code": 200,
    "desc": "No member seat is available."
}
  • If the value of the reason parameter is 2, the specified member seat has been used by another user.

{
    "reason": 2,
    "code": 200,
    "desc": "The specified member seat has been used by another user."
}

/api/chatroom/leaveMic

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/leaveMic

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The ID of the chat room.

user_id

String

Yes

useridxxxx

The user ID, which is a unique string within an application.

index

Integer

Yes

3

The member seat.

Response parameters

Parameter

Type

Example

Description

success

Boolean

true

Indicates whether the request was successful.

members

Array

None

The co-streaming information.

[]members.user_id

String

None

N/A

[]members.joined

Boolean

true

  • true: The co-streaming starts.

  • false: The co-streaming is not performed.

[]members.index

Integer

3

The member seat.

[]members.join_time

Long

1710420349667

The time when the co-streaming started.

Examples

Sample requests

{
    "id": "cfa4a59e90ab42cbaf708f218ad1****",
    "user_id": "333310",
    "index":3
}

Sample success responses

{
    "code": 200,
    "members": [
        {
            "user_id": "assd",
            "joined": true,
            "index": 1,
            "join_time": 1710420349667
        },
        {
            "user_id": "33334",
            "joined": true,
            "index": 2,
            "join_time": 1710420408513
        },
        {
            "extends": "",
            "user_id": "",
            "joined": false,
            "index": 3
        },
        {
            "user_id": "33335",
            "joined": true,
            "index": 4,
            "join_time": 1710420417941
        },
        {
            "user_id": "33336",
            "joined": true,
            "index": 5,
            "join_time": 1710420423408
        },
        {
            "user_id": "33337",
            "joined": true,
            "index": 6,
            "join_time": 1710420428932
        },
        {
            "user_id": "33338",
            "joined": true,
            "index": 7,
            "join_time": 1710420436877
        },
        {
            "user_id": "33339",
            "joined": true,
            "index": 8,
            "join_time": 1710420441424
        }
    ]
}

/api/chatroom/getMeetingInfo

Usage notes

  • Request protocol: HTTP or HTTPS

  • Request path: /api/chatroom/getMeetingInfo

  • Whether authorization is required: Yes

  • Request method: POST

  • Request format: JSON

Request parameters

Parameter

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The ID of the chat room.

Response parameters

Parameter

Type

Example

Description

success

Boolean

true

Indicates whether the request was successful.

members

Array

None

The co-streaming information.

[]members.user_id

String

None

N/A

[]members.joined

Boolean

true

  • true: The co-streaming starts.

  • false: The co-streaming is not performed.

[]members.index

Integer

3

The member seat.

[]members.join_time

Long

1710420349667

The time when the co-streaming started.

Examples

Sample requests

{
    "id": "cfa4a59e90ab42cbaf708f218ad1****"
}

Sample success responses

{
    "code": 200,
    "members": [
        {
            "user_id": "assd",
            "joined": true,
            "index": 1,
            "join_time": 1710420349667
        },
        {
            "user_id": "33334",
            "joined": true,
            "index": 2,
            "join_time": 1710420408513
        },
        {
            "extends": "",
            "user_id": "",
            "joined": false,
            "index": 3
        },
        {
            "user_id": "33335",
            "joined": true,
            "index": 4,
            "join_time": 1710420417941
        },
        {
            "user_id": "33336",
            "joined": true,
            "index": 5,
            "join_time": 1710420423408
        },
        {
            "user_id": "33337",
            "joined": true,
            "index": 6,
            "join_time": 1710420428932
        },
        {
            "user_id": "33338",
            "joined": true,
            "index": 7,
            "join_time": 1710420436877
        },
        {
            "user_id": "33339",
            "joined": true,
            "index": 8,
            "join_time": 1710420441424
        }
    ]
}