API reference

更新时间:
复制 MD 格式

The AUI Kits Interactive Streaming AppServer provides backend services, such as logon and live channel management. You can use the AppServer with the AUI Kits Interactive Streaming scenario-based SDK to quickly build interactive streaming applications. This helps you launch innovative services quickly.

Function of the AppServer

image

When you use the AUI Kits frame to quickly build services such as interactive streaming or E-commerce streaming, the scenario-based SDK needs to integrate with products such as ApsaraVideo Live for standard streaming and co-streaming, ApsaraVideo VOD for live recording (optional), and an Instant Messaging (IM) service for interactive messages. The AppServer encapsulates the features of these three products and provides a set of standard HTTP API operations for the scenario-based SDK. This reduces your development costs.

Note

You are responsible for deploying and maintaining the AppServer.

In addition to encapsulating the features of the products, the AppServer also implements a live channel management service. This service includes common features such as creating, modifying, and deleting live channels, and starting and stopping streams.

The AppServer does not directly depend on the API operations provided by ApsaraVideo Live. Instead, it generates ingest and stream pulling URLs by assembling addresses according to the ApsaraVideo Live stream ingest and pulling protocols. The AppServer also listens for stream ingest status callbacks from ApsaraVideo Live. This resolves issues where the live channel status is incorrect after the streamer's client exits unexpectedly.

Note

The IM service is available in two versions: new and old. The new IM service provides more powerful and stable IM capabilities. The old IM service will be gradually unpublished and replaced by the new version. If you are a new customer, we recommend that you use the new IM service. If you have already integrated the old IM service, a migration plan will be provided to help you migrate to the new IM service.

AppServer implementation

The AppServer uses a database (DB) table to manage live channels. The table is designed as follows:

CREATE TABLE `room_infos` (
  `id` varchar(256) NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `title` varchar(256) DEFAULT NULL,
  `anchor` varchar(256) DEFAULT NULL,
  `extends` mediumtext,
  `status` bigint DEFAULT NULL,
  `mode` bigint DEFAULT NULL,
  `chat_id` varchar(256) DEFAULT NULL,
  `pk_id` varchar(256) DEFAULT NULL,
  `notice` varchar(256) DEFAULT NULL,
  `meeting_id` varchar(256) DEFAULT NULL,
  `cover_url` varchar(256) DEFAULT NULL,
  `anchor_id` varchar(256) DEFAULT NULL,
  `anchor_nick` varchar(256) DEFAULT NULL,
  `vod_id` varchar(256) DEFAULT NULL,
  `meeting_info` mediumtext,
  `started_at` datetime DEFAULT NULL,
  `stopped_at` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_create_at` (`created_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Notes

Cross-domain issues: This service may be used by web clients. Therefore, you must configure Cross-Origin Resource Sharing (CORS).

References

AppServer API reference

API overview

API

Authentication required

Required

Description

/api/v1/live/login

No

No

Log on

A successful logon returns a token. You must include this token to access authorized API operations.

/api/v1/live/token

Yes

Yes

Get a token for an IM persistent connection.

/api/v1/live/create

Yes

Yes

Create a live channel.

/api/v1/live/list

Yes

Yes

Get a paginated list of live channels.

/api/v1/live/get

Yes

Yes

Get a single live channel.

/api/v1/live/start

Yes

Yes

Start a stream.

/api/v1/live/stop

Yes

Yes

Stop a stream.

/api/v1/live/update

Yes

No

Update live channel information, such as the notice.

/api/v1/live/getMeetingInfo

Yes

No

Used only in co-streaming scenarios.

Get co-streaming information.

/api/v1/live/updateMeetingInfo

Yes

No

Used only in co-streaming scenarios.

Update co-streaming information.

/api/v2/live/token

Yes

Yes

V2. Gets a token for an IM persistent connection. Used for compatibility between the new and old IM services.

/api/v2/live/create

Yes

Yes

V2. Creates a live channel. Used for compatibility between the new and old IM services.

Authentication method

The authentication implementation in the demo is for reference only. You can adjust the authentication policy as needed.

First, call the /login operation to obtain an authentication token. Then, add the token to the request header when you call other API operations.

image

Detailed API definitions

Log on

You can implement this API operation as needed. You can also customize the token generation algorithm, but make sure to use the same algorithm for both token generation and verification.

Usage notes

  • Request protocol: http/https

  • Request path: /login

  • Authorization required: No

  • Request method: POST

  • Request Content-Type: application/json

Request parameters

Name

Type

Required

Example

Description

username

String

Yes

usernamexxx

The username.

password

String

Yes

passwordxxxx

The password.

Returned data

Name

Type

Example

Description

code

Integer

200

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

expire

String

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

The expiration time. The time is in UTC format.

token

String

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9***

The authorization credential. By default, it is generated using JSON Web Token (JWT).

Examples

Request example

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

Successful response example

{
 "code": 200,
 "expire": "2023-02-28T14:38:06+08:00",
 "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2Nzc1NjYyODYsImlkIjoieXl5eSIsIm9yaWdfaWF0IjoxNjc3NDc5ODg2fQ.xxxxxx"
}

Get a token for an IM persistent connection

This operation essentially calls the GetMessageToken operation of the IM Server. For more information.

image

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/token

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example value

Description

user_id

String

Yes

useridxxxx

The user ID. This is a custom ID that must be unique within the AppId.

device_id

String

Yes

deviceidxxx

The device ID. This is a custom ID that uniquely identifies a user's device.

device_type

String

Yes

The device type. Valid values:

  • ios

  • android

  • web

  • pc

Response parameters

Name

Type

Example

Description

code

Integer

200

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

access_token

String

oauth_cloud_key:***-b0YY5Gy6Q

The token for establishing a persistent connection.

refresh_token

String

oauth_cloud_key:***-b0YY5Gy6Q

The refresh token. If the access token expires, you can use the refresh token to get a new one.

Examples

Request example

{
 "user_id": "useridxxxx",
 "device_id": "deviceidxxxxx",
 "device_type":"android"
}

Successful response example

{
 "code": 200,
 "access_token": "yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOxxxxxxx",
 "refresh_token": "yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOxxxxxxx"
}

Create a live channel

Implementation

image

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/create

  • Authorization required: Yes

  • Request method: POST

  • The request content type is JSON.

Request parameters

Name

Type

Required

Example

Description

title

String

Yes

titlexxxx

The title of the live stream.

notice

String

No

noticexxx

The notice for the live stream.

anchor

String

Yes

anchorxxxx

The streamer's user ID.

anchor_nick

String

No

anchornickxxxx

The streamer's nickname.

mode

Integer

No

0

The streaming mode. The default value is 0.

  • 0: Standard stream

  • 1: Co-stream

extends

String

No

{"xx":"xxx"}

The extended field. A JSON-formatted string.

Returned Data

Name

Type

Example

Description

code

Integer

200

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

id

String

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

The live channel ID.

created_at

String

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

The creation time.

updated_at

String

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

The modification time.

title

String

titlexxx

The title of the live stream.

notice

String

noticexxx

The notice for the live stream.

cover_url

String

The thumbnail. This is a reserved field.

anchor_id

String

anchor_idxxx

The streamer's user ID.

anchor_nick

String

anchor_nickxxx

The streamer's nickname.

extends

String

{"xx":"xxx"}

The extended field.

status

Integer

0

The live channel status:

0: Preparing

1: Live

2: Stopped

mode

Integer

0

The streaming mode.

  • 0: Standard stream

  • 1: Co-stream

chat_id

String

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

The IM group ID.

meeting_id

String

0a7656c4-c01b-424d-9882-xxxxxx

The co-streaming ID.

meeting_info

String

{"members":[{"user_id":"xxx","user_nick":"xxx","user_avatar":"http://xxx"}]}

A JSON string. Information about co-streaming viewers.

push_url_info

JSON

A collection of ingest URLs.

push_url_info.rtmp_url

String

rtmp://pushxxxx

RTMP stream ingest.

push_url_info.rts_url

String

artc://pushxxxx

RTS stream ingest.

push_url_info.srt_url

String

srt://pushxxxx

SRT stream ingest.

pull_url_info

JSON

A collection of stream pulling URLs.

pull_url_info.rtmp_url

String

rtmp://pullxxxx

RTMP stream pulling.

pull_url_info.rts_url

String

artc://pullxxxx

RTS stream pulling.

pull_url_info.hls_url

String

http://pullxxxx.m3u8?xxxx

HLS stream pulling.

pull_url_info.flv_url

String

http://pullxxxx.flv?xxxx

FLV stream pulling.

link_info

JSON

A collection of co-streaming URLs.

link_info.rtc_push_url

String

artc://live.aliyun.com/push/xxxx

The RTC ingest URL.

link_info.rtc_pull_url

String

artc://live.aliyun.com/play/xxxx

The RTC stream pulling URL.

link_info.cdn_pull_info

JSON

A collection of stream pulling URLs for regular viewers.

link_info.cdn_pull_info.rtmp_url

String

rtmp://pullxxxx

RTMP stream pulling.

link_info.cdn_pull_info.rts_url

String

artc://pullxxxx

RTS stream pulling.

link_info.cdn_pull_info.hls_url

String

http://pullxxxx.m3u8?xxxx

HLS stream pulling.

link_info.cdn_pull_info.flv_url

String

http://pullxxxx.flv?xxxx

FLV stream pulling.

Examples

Request example

{
 "title": "titlexxx",
 "notice": "noticexxx",
 "anchor":"streamer_user_id",
 "anchor_nick":"streamer_nick",
 "mode":0,
 "extends":"{\"xx\":\"xxx\"}"
}

Successful response example

{
 "id": "ee487235-5f9b-4cb3-82ce-45c91c365d06",
 "created_at": "2023-02-27T17:34:00.592750182+08:00",
 "updated_at": "2023-02-27T17:34:00.592750314+08:00",
 "title": "Live Stream Title",
 "notice": "23232",
 "anchor_id": "streamer_user_id",
 "anchor_nick": "",
 "extends": "{\"xx\":\"xxx\"}",
 "status": 0,
 "mode": 0,
 "chat_id": "ee487235-5f9b-4cb3-82ce-45c91c365d06",
 "meeting_id": "0a7656c4-c01b-424d-9882-a8bf44bd3a4b",
 "meeting_info": "",
 "push_url_info": {
 "rtmp_url": "rtmp://push.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06?auth_key=167809x",
 "rts_url": "artc://push.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06?auth_key=1678095xc",
 "srt_url": "srt://push.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06?auth_key=167809524x"
 },
 "pull_url_info": {
 "rtmp_url": "rtmp://pull.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06?auth_key=167809524x",
 "rts_url": "artc://pull.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06?auth_key=167809524x",
 "flv_url": "http://pull.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06.flv?auth_key=167809524x",
 "hls_url": "http://pull.h5video.vip/live/ee487235-5f9b-4cb3-82ce-45c91c365d06.m3u8?auth_key=167809524x"
 },
 "link_info": {
 "rtc_push_url": "artc://live.aliyun.com/push/0a7656c4-c01b-424d-9882-a8bf44bd3a4b?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f5b53&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b449e9a5f3f854c32fd4x",
 "rtc_pull_url": "artc://live.aliyun.com/play/0a7656c4-c01b-424d-9882-a8bf44bd3a4b?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f5b53&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b449ex",
 "cdn_pull_info": {
 "rtmp_url": "rtmp://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_0a7656c4-c01b-424d-9882-a8bf44bd3a4b_streamer_user_id_camera?auth_key=167757684x",
 "rts_url": "artc://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_0a7656c4-c01b-424d-9882-a8bf44bd3a4b_streamer_user_id_camera?auth_key=16775768x",
 "flv_url": "http://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_0a7656c4-c01b-424d-9882-a8bf44bd3a4b_streamer_user_id_camera.flv?auth_key=167757684x",
 "hls_url": "http://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_0a7656c4-c01b-424d-9882-a8bf44bd3a4b_streamer_user_id_camera.m3u8?auth_key=167757684x"
 }
 }
}

Get a paginated list of live channels

Implementation

image

Important

Ingest URLs are returned only if the requested user ID is the group owner.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/list

  • Authorization required: Yes

  • Request method: POST

  • The request content type is JSON.

Request parameters

Name

Type

Required

Example

Description

user_id

String

Yes

useridxxx

User ID

page_num

Integer

Yes

1

The page number. Default value: 1.

page_size

Integer

Yes

10

The number of entries to show on a single page. Default value: 10.

im_server

JSON array

Yes

["aliyun_old","aliyun_new"]

Specifies which IM services to use. You can select multiple services. If you do not specify this parameter, aliyun_old is used by default.

  • aliyun_old

  • aliyun_new

Returned Data

Name

Type

Example

Description

code

Integer

200

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

id

String

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

The live channel ID.

created_at

String

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

The creation time.

updated_at

String

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

The modification time.

started_at

String

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

The start time of the live stream.

stopped_at

String

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

The end time of the live stream.

title

String

titlexxx

The title of the live stream.

notice

String

noticexxx

The notice for the live stream.

cover_url

String

The thumbnail. This is a reserved field.

anchor_id

String

anchor_idxxx

The streamer's user ID.

anchor_nick

String

anchor_nickxxx

The streamer's nickname.

extends

String

{"xx":"xxx"}

The extended field.

status

Integer

0

The live channel status:

0: Preparing

1: Live

2: Stopped

mode

Integer

0

The streaming mode.

  • 0: Standard stream

  • 1: Co-stream

chat_id

String

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

The IM group ID.

meeting_id

String

0a7656c4-c01b-424d-9882-xxxxxx

The co-streaming ID.

meeting_info

String

{"members":[{"user_id":"xxx","user_nick":"xxx","user_avatar":"http://xxx"}]}

A JSON string. Information about co-streaming viewers.

metrics

JSON

Statistics.

metrics.online_count

Long

20

The number of online users.

metrics.like_count

Long

0

The number of likes.

metrics.pv

Long

30

The number of page views (PVs) for the IM group.

metrics.uv

Long

20

The number of unique visitors (UVs) for the IM group.

vod_info

JSON

Information about the live recording.

vod_info.status

Integer

1

The status of the recorded video.

  • 0: Preparing

  • 1: Success

  • 2: Failed

vod_info.playlist

Array

Information about the recorded video.

vod_info.playlist[].bit_rate

String

858.198

The bitrate of the media stream.

vod_info.playlist[].creation_time

String

2017-06-26T06:38:48Z

The time the audio or video was created. The format is yyyy-MM-ddTHH:mm:ssZ (UTC).

vod_info.playlist[].definition

String

OD

The definition of the video stream.

  • FD: Low definition.

  • LD: Standard definition.

  • HD: High Definition.

  • HD: Ultra-high definition

  • OD: Original quality.

  • 2K: 2K.

  • 4K: 4K.

  • SQ: Standard quality.

  • HQ: High quality.

  • AUTO: Adaptive bitrate.

vod_info.playlist[].duration

String

67.685

The duration of the media stream, in seconds.

vod_info.playlist[].format

String

m3u8

The format of the media stream.

  • If the media file is a video, valid values are mp4 and m3u8.

  • If the media file is audio-only, the value is mp3.

vod_info.playlist[].fps

String

90000.0

The frame rate of the media stream.

vod_info.playlist[].height

Long

720

The height of the media stream, in pixels.

vod_info.playlist[].width

Long

1280

The width of the media stream, in pixels.

vod_info.playlist[].play_url

String

https://vod.h5vxxx/Record/VOD_NO_TRANSCODE/live/b92ed0ce-e29f-4df3-984a-dbxxxx.m3u8

The playback URL of the video stream.

vod_info.playlist[].size

Long

3034884

The size of the media stream, in bytes.

vod_info.playlist[].status

String

Normal

The status of the media stream. Valid values:

  • Normal: The stream is normal. This status marks the latest transcoded stream for each definition and format.

  • Invisible: The stream is not visible. If there are multiple transcoded streams for the same definition and format, only the latest stream is marked as Normal. The others are marked as Invisible.

vod_info.playlist[].stream_type

String

The type of the media stream. If the media stream is a video, the value is video. If it is audio-only, the value is audio.

user_status

JSON

The user's mute status.

user_status.mute

Boolean

false

Indicates whether the user is muted. Valid values:

  • true: Muted.

  • false: Not muted.

user_status.mute_source

String

To be determined. This parameter is not currently returned.

link_info

JSON

A collection of co-streaming URLs.

link_info.rtc_push_url

String

artc://live.aliyun.com/push/xxxx

The RTC ingest URL.

link_info.rtc_pull_url

String

artc://live.aliyun.com/play/xxxx

The RTC stream pulling URL.

link_info.cdn_pull_info

JSON

A collection of stream pulling URLs for regular viewers.

link_info.cdn_pull_info.rtmp_url

String

rtmp://pullxxxx

RTMP stream pulling.

link_info.cdn_pull_info.rts_url

String

artc://pullxxxx

RTS stream pulling.

link_info.cdn_pull_info.hls_url

String

http://pullxxxx.m3u8?xxxx

HLS stream pulling.

link_info.cdn_pull_info.flv_url

String

http://pullxxxx.flv?xxxx

FLV stream pulling.

Examples

Request example

{
 "page_size": 10,
 "page_num":1,
 "user_id": "useridxxxx"
  "im_server":["aliyun_old","aliyun_new"]
}

Successful response example

[
 {
 "id": "c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3",
 "created_at": "2023-02-27T20:45:28+08:00",
 "updated_at": "2023-02-27T20:45:28+08:00",
 "started_at": "2023-02-27T20:52:01+08:00",
 "stopped_at": "0001-01-01T00:00:00Z",
 "title": "Live Stream Title",
 "notice": "Live Stream Notice",
 "cover_url": "",
 "anchor_id": "AUILivePusher",
 "anchor_nick": "",
 "extends": "",
 "status": 1,
 "mode": 0,
 "chat_id": "c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3",
 "meeting_id": "",
 "vod_id": "",
 "meeting_info": "",
 "metrics": {
 "online_count": 2,
 "like_count": 0,
 "pv": 12,
 "uv": 2
 },
 "vod_info": {
 "status": 1,
 "playlist": [
 {
 "bit_rate": "858.198",
 "creation_time": "2023-02-27T11:28:39Z",
 "definition": "OD",
 "duration": "67.685",
 "format": "m3u8",
 "fps": "90000.0",
 "height": 720,
 "width": 1280,
 "play_url": "https://vod.h5video.vip/liveRecord/VOD_NO_TRANSCODE/live/b92ed0ce-e29f-4df3-984a-dbdb314d7e4e/2023-02-27-19-24-38_2023-02-27-19-25-36.m3u8",
 "size": 3034884,
 "status": "Normal",
 "stream_type": "video"
 }
 ]
 },
 "user_status": {
 "mute": false,
 "mute_source": null
 },
 "pull_url_info": {
 "rtmp_url": "rtmp://pull.h5video.vip/live/c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3?auth_key=167810730x",
 "rts_url": "artc://pull.h5video.vip/live/c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3?auth_key=167810730x",
 "flv_url": "http://pull.h5video.vip/live/c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3.flv?auth_key=167810730x",
 "hls_url": "http://pull.h5video.vip/live/c8d619e2-e7ec-445d-b8a1-e1ebf967d6c3.m3u8?auth_key=167810730x"
 }
 }
]

Get a single live channel

Implementation: See the implementation of /api/v1/live/list.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/get

  • Authorization required: Yes

  • Request method: POST

  • The content type of the request is JSON.

Request parameters

Name

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The live channel ID.

user_id

String

Yes

useridxxx

The user ID.

im_server

JSON array

Yes

["aliyun_old","aliyun_new"]

Specifies which IM services to use. You can select multiple services. If you do not specify this parameter, aliyun_old is used by default.

  • aliyun_old

  • aliyun_new

Returned data

See /api/v1/live/list. The response is a single object instead of a list.

Examples

Request example

{
 "id": "675e6783-0bac-4990-b6da-5aa890535029",
 "user_id": "Cedric8",
  "im_server":["aliyun_old","aliyun_new"]
}

Successful response example

{
 "id": "675e6783-0bac-4990-b6da-5aa890535029",
 "created_at": "2023-02-14T14:34:14+08:00",
 "updated_at": "2023-02-14T14:34:19+08:00",
 "started_at": "2023-02-14T14:34:19+08:00",
 "stopped_at": "2023-02-14T14:34:26+08:00",
 "title": "Drink up",
 "notice": "fgg",
 "cover_url": "",
 "anchor_id": "Cedric8",
 "anchor_nick": "",
 "extends": "{\"userNick\":\"Cedric8\",\"userAvatar\":\"https:\/\/img.alicdn.com\/imgextra\/i1\/O1CN01chynzk1uKkiHiQIvE_!!6000000006019-2-tps-80-80.png\"}",
 "status": 2,
 "mode": 1,
 "chat_id": "675e6783-0bac-4990-b6da-5aa890535029",
 "meeting_id": "66584c06-347f-47c6-8a18-fa2860c563ba",
 "vod_id": "",
 "meeting_info":"{\"members\":[{\"user_id\":\"Cedric8\",\"user_nick\":\"Cedric8\",\"user_avatar\":\"\",\"camera_opened\":true,\"mic_opened\":true,\"rtc_pull_url\":\"artc://live.aliyun.com/play/66584c06-347f-47c6-8a18-fa2860c563ba?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f5b53\&userId=Cedric8\&timestamp=1676442853\&token=079116a1c721ac219814d513190be48fcb324800b0b482467ddd04a178e9bf2c\"}]}",
 "metrics": {
 "online_count": 0,
 "like_count": 0,
 "pv": 18,
 "uv": 6
 },
 "vod_info": {
 "status": 0
 },
 "user_status": {
 "mute": false,
 "mute_source": []
 },
 "push_url_info": {
 "rtmp_url": "rtmp://push.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029?auth_key=1678109226-0-0-fed270f2c9d79d3216ba7cfb842b811c",
 "rts_url": "artc://push.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029?auth_key=1678109226-0-0-fed270f2c9d79d3216ba7cfb842b811c",
 "srt_url": "srt://push.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029?auth_key=1678109226-0-0-fed270f2c9d79d3216ba7cfb842b811c"
 },
 "pull_url_info": {
 "rtmp_url": "rtmp://pull.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029?auth_key=1678109226-0-0-f935f515baa272bb83c5bcc44597a3fa",
 "rts_url": "artc://pull.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029?auth_key=1678109226-0-0-f935f515baa272bb83c5bcc44597a3fa",
 "flv_url": "http://pull.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029.flv?auth_key=1678109226-0-0-059cf974a2dc12919f92b3be70a99fef",
 "hls_url": "http://pull.h5video.vip/live/675e6783-0bac-4990-b6da-5aa890535029.m3u8?auth_key=1678109226-0-0-b31e749bbead2fa86d061c3767e31401",
 },
 "link_info": {
 "rtc_push_url": "artc://live.aliyun.com/push/66584c06-347f-47c6-8a18-fa2860c563ba?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f5b53&userId=Cedric8&timestamp=1677590826&token=3833146f33fa914e3b4c25373d780f54fb3a81371fec0884ee062f25d9522566",
 "rtc_pull_url": "artc://live.aliyun.com/play/66584c06-347f-47c6-8a18-fa2860c563ba?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f5b53&userId=Cedric8&timestamp=1677590826&token=3833146f33fa914e3b4c25373d780f54fb3a81371fec0884ee062f25d9522566",
 "cdn_pull_info": {
 "rtmp_url": "rtmp://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_66584c06-347f-47c6-8a18-fa2860c563ba_Cedric8_camera?auth_key=1677590826-0-0-22af27f1cc1c9ea2362d6bb8d49dd077",
 "rts_url": "artc://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_66584c06-347f-47c6-8a18-fa2860c563ba_Cedric8_camera?auth_key=1677590826-0-0-22af27f1cc1c9ea2362d6bb8d49dd077",
 "flv_url": "http://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_66584c06-347f-47c6-8a18-fa2860c563ba_Cedric8_camera.flv?auth_key=1677590826-0-0-384a33ab3857a556d576af0f5d7563e5",
 "hls_url": "http://pull.h5video.vip/live/7c61616e-480b-4de6-b3fc-95cef48f5b53_66584c06-347f-47c6-8a18-fa2860c563ba_Cedric8_camera.m3u8?auth_key=1677590826-0-0-3ab7aeede3dcd589252c2282428f1a22"
 }
 }
}

Start a stream

Implementation: Modifies the value of the status field for the live channel in the DB. Ensure cache consistency.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/start

  • Authorization required: Yes

  • Request method: POST

  • The request content type is JSON.

Request parameters

Name

Type

Required

Example value

Description

user_id

String

Yes

useridxxxx

The user ID. This is a custom ID that must be unique within the AppId.

id

String

Yes

liveIdxxxx

The live channel ID.

Returned data

See the response parameters for retrieving a single live channel in /api/v1/live/get.

Examples

Request example

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

Successful response example

See the example response for retrieving a single live channel in /api/v1/live/get.

Stop a stream

Implementation: Modifies the value of the status field for the live channel in the DB. Ensure cache consistency.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/stop

  • Authorization required: Yes

  • Request method: POST

  • Request content type: JSON

Request parameters

Name

Type

Required

Example

Description

user_id

String

Yes

useridxxxx

The user ID. This is a custom ID that must be unique within the AppId.

id

String

Yes

liveIdxxxx

The live channel ID.

Return data

See the response parameters for retrieving a single live channel in /api/v1/live/get.

Examples

Request example

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

Successful response example

See the example response for retrieving a single live channel in /api/v1/live/get.

Update live channel information, such as the notice

Implementation: Modifies the live channel information in the DB.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/update

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example

Description

user_id

String

Yes

useridxxxx

The user ID. This is a custom ID that must be unique within the AppId.

id

String

Yes

liveIdxxxx

The live channel ID.

title

String

No

titlexxx

The title of the live stream.

Response parameters

See the response parameters for retrieving a single live channel in /api/v1/live/get.

Examples

Request example

{
    "id": "675e6783-0bac-4990-b6da-5aa890535029",
    "user_id": "useridxxx",
    "title": "Test update title",
    "notice":"Test update live notice",
    "extends":"{}"
}

Successful response example

See the example response for retrieving a single live channel in /api/v1/live/get.

Get co-streaming information

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/getMeetingInfo

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The live channel ID.

Returned data

See the response parameters for retrieving a single live channel in /api/v1/live/get.

Examples

Request example

{
    "id": "675e6783-0bac-4990-b6da-5aa890535029"
}

Successful response example

See the example response for retrieving a single live channel in /api/v1/live/get.

Update co-streaming information

Modifies the online co-streaming information. This is usually triggered by the streamer.

Usage notes

  • Request protocol: http/https

  • Request path: /api/v1/live/updateMeetingInfo

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example

Description

id

String

Yes

liveIdxxxx

The live channel ID.

members

Array

Yes

The co-streaming members.

members[].user_id

String

Yes

useridxxx

The user ID.

members[].user_nick

String

Yes

usernickxxx

The user's nickname.

members[].user_avatar

String

Yes

http://xxx.jpg

The user's profile picture.

members[].camera_opened

Boolean

Yes

true

The camera status.

members[].mic_opened

Boolean

Yes

true

The microphone status.

members[].rtc_pull_url

String

Yes

The co-streaming pulling URL.

Response parameters

See the response parameters for retrieving a single live channel in /api/v1/live/get.

Examples

Request example

{
  "id": "675e6783-0bac-4990-b6da-5aa890535029",
  "members": [
    {
      "user_id": "user_idxxx",
      "user_nick": "user_idxxx",
      "user_avatar": "user_idxxx",
      "camera_opened": true,
      "mic_opened": true,
      "rtc_pull_url": "artc://live.alixxx"
    }
  ]
}

Successful response example

See the example response for retrieving a single live channel in /api/v1/live/get.

Generate a launch URL for Live Streaming Assistant

This URL is used with the desktop client Live Streaming Assistant. It allows the streamer to enter the live channel and start streaming.

Usage notes

  • Request path: /api/v1/live/getLiveJumpUrl

  • Request method: POST

  • Authorization required: Yes

  • Request Content-Type: application/json; charset=utf-8

Request parameters

Name

Type

Required

Example

Description

user_name

String

No

test***

The nickname.

user_id

String

Yes

a494caec-***-695ef345db77

The user ID.

live_id

String

Yes

de1**a0,hu**9

The live stream ID.

Returned data

Name

Type

Example Value

Description

code

int

200

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

live_jump_url

String

auipusher://page/live-room?app_server=http%3A%2F%2Flive-example.live.1569899459811379.cn-hangzhou.fc.devsapp.net&token=fdasdasafdfadasd&user_id=131312414&user_name=%E7%BE%8E%E5%A5%B3%E4%B8%BB%E6%92%AD&live_id=e3141312312321

The returned live stream launch URL. The parameters are as follows:

  • user_name: The nickname.

  • user_id: userId.

  • live_id: The live stream ID.

  • token: The signature verification parameter.

  • app_server: The service endpoint.

image

Verify a signature

Usage notes

  • Request path: /api/v1/live/verifyAuthToken

  • Request method: POST

  • Content-Type: application/json; charset=utf-8

Request parameters

Name

Type

Required

Example

Description

user_name

String

No

BatchGetOnlineUsers

The nickname. It must be UTF-8 encoded.

user_id

String

Yes

a494caec-***-695ef345db77

The user ID.

live_id

String

Yes

de1**a0

The live stream ID.

app_server

String

Yes

http://xxx

The service endpoint.

token

String

Yes

7da3c10e-ce85-498a-a0ca-03d6e2297955

The signature verification parameter.

Returned data

Name

Type

Example

Description

code

int

200

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

loginToken

String

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.xxxxxxxxxxxxx.jIsjbRRO1B0xV2iVkshcrykz2Lj-6WcloZ9o0HkT3O0

The logon token. It is used to call the service at serverUrl.

Get a token for an IM persistent connection

Usage notes

  • Request protocol: http/https

  • Request path: /api/v2/live/token

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example

Description

user_id

String

Yes

useridxxxx

The user ID. This is a custom ID that must be unique within the AppId.

device_id

String

Yes

deviceidxxx

The device ID. This is a custom ID that uniquely identifies a user's device.

Note

This parameter takes effect only for the aliyun_old service.

device_type

String

Yes

android

The device type. Valid values:

  • ios

  • android

  • web

  • pc

Note

This parameter takes effect only for the aliyun_old service.

im_server

Json array

Yes

["aliyun_old","aliyun_new"]

Specifies which IM services to use. You can select multiple services.

  • aliyun_old

  • aliyun_new

role

String

No

admin

The role. The default value is empty. If you set this to admin, the user can call management API operations.

Note

This parameter takes effect only for the aliyun_old service.

Returned Data

Name

Type

Example

Description

code

Integer

200

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

aliyun_old_im

access_token

String

yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKO*******

The token for the old IM service.

refresh_token

String

yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKO*******

The refresh token for the old IM service.

aliyun_new_im

app_id

String

exampleapp

The user's AppID.

app_sign

String

examplesign

An encrypted string generated by the server, which includes information such as the access domain name.

app_token

String

exampletoken

The logon authentication.

auth.user_id

String

123

The ID of the user to log on.

auth.nonce

String

exampleAK

Format: "RandomString-AK". The maximum length is 64 bytes.

auth.timestamp

Long

1677576840

The expiration time. The number of seconds from 1970 to the expiration time.

auth.role

String

admin

The role. If you set this to admin, the user can call management API operations.

Examples

Request example

{
 "user_id": "useridxxxx",
 "device_id": "deviceidxxxxx",
 "device_type":"android",
 "im_server":["aliyun_old","aliyun_new"],
 "role":"admin"
}

Successful response example

{
 "code": 200,
  "aliyun_old_im":{
     "access_token": "yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOxxxxxxx",
	 	"refresh_token": "yJlbmRwb2ludHMiOlsid3NzOi8vbWV0YXBhdGguYWxpeXVuY3MuY29tL3dzIl0sImFwcElkIjoiVFkzSTJZWDAiLCJ0b2tlbiI6Im1wLmV5SjBlWEFpT2lKS1YxUWlMQ0poYkdjaU9pSklVekkxTmlKOxxxxxxx"
  },
  "aliyun_new_im":{
    	"appid":"exampleapp",
      "appsign":"examplesign",
   		"apptoken":"exampletoken",
   		"auth":{
         "userid":"123",
         "nonce":"exampleAK", 
          "timestamp":1677576840,
          "role":"admin"
    	}
  }
}

Create a live channel

Description

  • Request protocol: http/https

  • Request path: /api/v2/live/create

  • Authorization required: Yes

  • Request method: POST

  • Request body format: JSON

Request parameters

Name

Type

Required

Example

Description

title

String

Yes

title****

The title of the live stream. The length must be less than 64 characters.

notice

String

No

notice****

The notice for the live stream.

Note

This parameter takes effect only for the aliyun_old service.

anchor

String

Yes

anchor****

The streamer's UserID.

anchor_nick

String

No

anchornick****

The streamer's nickname.

Note

This parameter takes effect only for the aliyun_old service.

mode

Integer

No

0

The streaming mode. The default value is 0.

  • 0: Standard stream

  • 1: Co-stream

extends

String

No

{"xx":"xxx"}

The extended field. A JSON-formatted string with a length of less than 512 characters.

im_server

JSON array

Yes

["aliyun_old","aliyun_new"]

Specifies which IM services to use. You can select multiple services.

  • aliyun_old

  • aliyun_new

Returned Data

Name

Type

Example

Description

code

Integer

200

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

id

String

ee487235-5f9b-4cb3-82ce-45c91c365****

The live channel ID.

created_at

String

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

The creation time.

updated_at

String

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

The modification time.

title

String

title****

The title of the live stream.

notice

String

notice****

The notice for the live stream.

cover_url

String

The thumbnail. This is a reserved field.

anchor_id

String

anchor_id****

The streamer's UserID.

anchor_nick

String

anchor_nick****

The streamer's nickname.

extends

String

{"xx":"xxx"}

The extended field.

status

Integer

0

The live channel status:

0: Preparing

1: Live

2: Stopped

mode

Integer

0

The streaming mode.

  • 0: Standard stream

  • 1: Co-stream

chat_id

String

ee487235-5f9b-4cb3-82ce-45c91c36****

The IM group ID.

meeting_id

String

0a7656c4-c01b-424d-9882-a8bf44bd****

The co-streaming ID.

meeting_info

String

{"members":[{"user_id":"xxx","user_nick":"xxx","user_avatar":"http://xxx"}]}

A JSON string. Information about co-streaming viewers.

push_url_info

JSON

A collection of ingest URLs.

push_url_info.rtmp_url

String

rtmp://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167****

RTMP stream ingest.

push_url_info.rts_url

String

artc://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=16780****

RTS stream ingest.

push_url_info.srt_url

String

srt://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****

SRT stream ingest.

pull_url_info

JSON

A collection of stream pulling URLs.

pull_url_info.rtmp_url

String

rtmp://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****

RTMP stream pulling.

pull_url_info.rts_url

String

artc://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****

RTS stream pulling.

pull_url_info.hls_url

String

http://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****.flv?auth_key=167809****

HLS stream pulling.

pull_url_info.flv_url

String

http://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****.m3u8?auth_key=167809****

FLV stream pulling.

link_info

JSON

A collection of co-streaming URLs.

link_info.rtc_push_url

String

artc://live****.aliyun.com/push/0a7656c4-c01b-424d-9882-a8bf44bd****?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f****&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b449e9a5f3f854c32****

The RTC ingest URL.

link_info.rtc_pull_url

String

artc://live****.aliyun.com/play/0a7656c4-c01b-424d-9882-a8bf44bd****?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f*****&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b****

The RTC stream pulling URL.

link_info.cdn_pull_info

JSON

A collection of stream pulling URLs for regular viewers.

link_info.cdn_pull_info.rtmp_url

String

rtmp://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera?auth_key=167757****

RTMP stream pulling.

link_info.cdn_pull_info.rts_url

String

artc://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera?auth_key=16775****

RTS stream pulling.

link_info.cdn_pull_info.hls_url

String

http://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera.flv?auth_key=167757****

HLS stream pulling.

link_info.cdn_pull_info.flv_url

String

http://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamerUserId_camera.m3u8?auth_key=167757****

FLV stream pulling.

Examples

Request example

{
 "title": "title****",
 "notice": "notice****",
 "anchor":"anchor****",
 "anchor_nick":"anchornick****",
 "mode":0,
 "extends":"{\"xx\":\"xxx\"}",
 "im_server":["aliyun_old","aliyun_new"]
}

Response example

{
 "id": "ee487235-5f9b-4cb3-82ce-45c91c36****",
 "created_at": "2023-02-27T17:34:00.592750182+08:00",
 "updated_at": "2023-02-27T17:34:00.592750314+08:00",
 "title": "title****",
 "notice": "notice****",
 "anchor_id": "anchor_id****",
 "anchor_nick": "anchor_nick****",
 "extends": "{\"xx\":\"xxx\"}",
 "status": 0,
 "mode": 0,
 "chat_id": "ee487235-5f9b-4cb3-82ce-45c91c36****",
 "meeting_id": "0a7656c4-c01b-424d-9882-a8bf44bd****",
 "meeting_info": "",
 "push_url_info": {
 "rtmp_url": "rtmp://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167****",
 "rts_url": "artc://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=16780****",
 "srt_url": "srt://push.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****"
 },
 "pull_url_info": {
 "rtmp_url": "rtmp://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****",
 "rts_url": "artc://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****?auth_key=167809****",
 "flv_url": "http://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****.flv?auth_key=167809****",
 "hls_url": "http://pull.h5v****.vip/live/ee487235-5f9b-4cb3-82ce-45c91c36****.m3u8?auth_key=167809****"
 },
 "link_info": {
 "rtc_push_url": "artc://live****.aliyun.com/push/0a7656c4-c01b-424d-9882-a8bf44bd****?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f****&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b449e9a5f3f854c32anchor****",
 "rtc_pull_url": "artc://live****.aliyun.com/play/0a7656c4-c01b-424d-9882-a8bf44bd****?sdkAppId=7c61616e-480b-4de6-b3fc-95cef48f****&userId=streamer_user_id&timestamp=1677576840&token=95e014264c0b937b4anchor****",
 "cdn_pull_info": {
 "rtmp_url": "rtmp://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera?auth_key=167757****",
 "rts_url": "artc://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera?auth_key=16775****",
 "flv_url": "http://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera.flv?auth_key=167757****",
 "hls_url": "http://pull.h5v****.vip/live/7c61616e-480b-4de6-b3fc-95cef48f****_0a7656c4-c01b-424d-9882-a8bf44bd****_streamer_user_id_camera.m3u8?auth_key=167757****"
 }
 }
}