Query User Level List
API Description
1、查询账号的用户等级列表,按等级顺序升序返回
2、用户等级为账号级配置,账号下所有频道共用同一套等级;直播模板和频道只控制是否展示等级
3、管理后台【用户】→【用户等级】和开放API读写同一份配置,任一入口保存成功后,另一入口查询到相同结果
4、账号从未配置过用户等级时,首次查询会初始化5个默认等级(青铜、白银、黄金、钻石、皇冠)并保存
5、接口支持https协议
API URL
http://api.polyv.net/live/v4/user/viewer-level/get
Request Method
GET
API Constraints
The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have frequency limits. See details
The API identifies the target account based on
appIdin the signature. User ID or channel number is not accepted.For details on user level functionality, see User Levels
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Account appId See details in Get Secret Key |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid for 3 minutes |
| sign | true | String | Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See details in Signature Generation Rules |
Example
http://api.polyv.net/live/v4/user/viewer-level/get?appId=frlr1zazn3&sign=49428741C1D7BEE8BE1EE545F066ECC7×tamp=1677167340447
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine the basic response status |
| status | String | Response result, determined by business logic. Returns success on success, error on failure |
| success | Boolean | Whether the response was successful |
| requestId | String | Request ID, a unique UUID generated for each request. Only used for troubleshooting and debugging, should not be tied to business logic |
| error | Object | Error information when status code is not 200 See details in Error Parameter Description |
| data | Array | User level list, sorted in ascending order by level See details in data Parameter Description |
Error Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Error code, used to identify the specific error cause |
| desc | String | Error description, corresponding to error.code |
data Parameter Description
| Parameter | Type | Description |
|---|---|---|
| levelId | String | Level identifier, unique within the account |
| levelName | String | Level name |
| levelIcon | String | Level icon URL, null if not set |
| levelBgColor | String | Level background color, format #RGB or #RRGGBB, null if not set |
| description | String | Level description, only used for backend identification and management, not displayed to viewers, null if not set |
| requiredPoints | Long | Points threshold, i.e., the minimum cumulative points a viewer must earn to obtain this level |
| sortOrder | Integer | Level order, incrementing from 1 |
Java Request Example
For quick integration of the base code, download the relevant dependency source code. Click to download source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java, both contained in the download file.
It is strongly recommended to use the Live Java SDK for API integration. The Live Java SDK provides unified encapsulation and optimization for API call logic, exception handling, data signing, and HTTP request thread pools.
private static final Logger log = LoggerFactory.getLogger(getClass());
/**
* 查询用户等级列表
* @throws IOException
* @throws NoSuchAlgorithmException
*/
@Test
public void testViewerLevelGet() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.appId;
String appSecret = super.appSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/user/viewer-level/get";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
String response = HttpUtil.get(url, requestMap);
log.info("测试查询用户等级列表,返回值:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success example (default levels returned on first query)
{
"code": 200,
"status": "success",
"requestId": "414afeb28f1c4f0ca17e1c3c1e39d247.71.16771673423081591",
"data": [
{
"levelId": "bronze",
"levelName": "青铜",
"levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/bronze.png",
"levelBgColor": "#FF6456",
"description": null,
"requiredPoints": 1,
"sortOrder": 1
},
{
"levelId": "silver",
"levelName": "白银",
"levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/silver.png",
"levelBgColor": "#5E81FF",
"description": null,
"requiredPoints": 1000,
"sortOrder": 2
},
{
"levelId": "gold",
"levelName": "黄金",
"levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/gold.png",
"levelBgColor": "#FF894E",
"description": null,
"requiredPoints": 3000,
"sortOrder": 3
},
{
"levelId": "diamond",
"levelName": "钻石",
"levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/diamond.png",
"levelBgColor": "#A361FF",
"description": null,
"requiredPoints": 5000,
"sortOrder": 4
},
{
"levelId": "crown",
"levelName": "皇冠",
"levelIcon": "https://s1.videocc.net/default-img/level-icon/v1/crown.png",
"levelBgColor": "#FB5C91",
"description": null,
"requiredPoints": 10000,
"sortOrder": 5
}
],
"success": true
}
Error example
{
"code": 400,
"status": "error",
"requestId": "d310b70bc329403f87f77f9203d50f89.128.16360831552223589",
"error": {
"code": 20001,
"desc": "application not found."
},
"success": false
}
