Allocate Sub-Account Resources
Interface Description
1、分配分帐号资源
2、(timestamp, appId)参与sign签名,并和sign一起通过url传递,请求体参数不参与签名,通过post请求体传递【请设置请求头contentType:application/json】
3、接口支持https协议
Interface URL
http://api.polyv.net/live/v4/group/user/package/update
Request Method
POST
Interface Constraints
The interface supports both HTTP and HTTPS. HTTPS is recommended to ensure interface security. API calls have frequency limits. See details
For group account interfaces, use the appId and appSecret of the primary group account for signature calculation.
Sub-account resource usage plans follow the primary group account. Minute-based billing can only allocate minutes, and concurrent billing can only allocate concurrency.
Request Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| appId | true | String | Primary group account appId See Group Account 2.0 Key Retrieval |
| timestamp | true | Long | Current 13-digit millisecond timestamp, valid within 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 your own server to relay requests to the POLYV server for response data. See Signature Generation Rules |
Request Body Parameter Description
| Parameter | Required | Type | Description |
|---|---|---|---|
| true | String | Sub-account email | |
| accumulateResource | false | String | Whether to accumulate resources. Options: Y: Accumulate resources on top of existing ones N: Do not accumulate, directly set/replace to target value Default is N if not provided. Note: Some resources only support replacement and do not support accumulation. See field descriptions below. |
| balance | false | Float | Amount (yuan), cannot be less than 0, up to two decimal places, e.g., 1.23 |
| concurrent | false | Integer | Live streaming concurrency |
| minutes | false | Integer | Available live streaming minutes (minutes) |
| linkMicMinutes | false | Integer | Live streaming co-host minutes (minutes) |
| guideMinutes | false | Integer | Live streaming director console minutes (minutes) |
| maxChannels | false | Integer | Maximum number of creatable live channels |
| remainFlow | false | Integer | Video-on-demand traffic (GB) |
| remainSpace | false | Integer | Video-on-demand storage (GB) |
| linkMicLimit | false | Integer | Co-host participant limit, maximum 16 people. Note: This resource does not support accumulation, i.e., the accumulateResource=Y parameter is invalid for this field. |
| aiPptVideoDuration | false | Integer | Allocate video creation minutes. A value less than 0 indicates resource recovery. Note: This resource only supports accumulation, i.e., the accumulateResource=N parameter is invalid for this field. |
| aiPptVideoWithDigitalHumanDuration | false | Integer | Allocate video creation (including digital human). A value less than 0 indicates resource recovery. Note: This resource only supports accumulation, i.e., the accumulateResource=N parameter is invalid for this field. |
Example
http://api.polyv.net/live/v4/group/user/package/update?appId=g8dtv537aq×tamp=1653485584000&sign=C84658AB04C262A71AA1417168828719
Request Body Parameters
{
"email": "********@polyv.net",
"minutes": 500,
"maxChannels":10
}
Response Parameter Description
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Status code, same as HTTP status code, used to determine 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, not for business logic |
| error | Object | Error information when status code is not 200 See Error Field Description |
| data | Boolean | Returns true on successful request, returns empty on failure |
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 |
Java Request Example
For quick integration of basic code, download the relevant dependency source code. Click here to download the source code. After downloading, add it to your own source project. The test cases include HttpUtil.java and LiveSignUtil.java in the downloaded 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(ChannelOperateTest.class);
/**
* 分配分帐号资源
*/
@Test
public void groupUserPackageTest() throws IOException, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String appId = super.groupAppId;
String appSecret = super.groupAppSecret;
String timestamp = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/live/v4/group/user/package/update";
String email = "polyvtest123456@polyv.net";
String balance = "10";
String concurrent = "101";
String remainFlow = "20";
String remainSpace = "20";
//http 调用逻辑
Map<String, String> requestMap = new HashMap<>();
requestMap.put("appId", appId);
requestMap.put("timestamp", timestamp);
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("email", email);
jsonMap.put("balance", balance);
jsonMap.put("concurrent", concurrent);
jsonMap.put("remainFlow", remainFlow);
jsonMap.put("remainSpace", remainSpace);
requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
url = HttpUtil.appendUrl(url, requestMap);
String response = HttpUtil.postJsonBody(url, JSON.toJSONString(jsonMap), null);
log.info("测试分配分帐号资源成功:{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code": 200,
"status": "success",
"requestId": "71c487ed89a94ca0b29e8779ea96f84b.63.16529473248590749",
"data": true,
"success": true
}
Error Example
{
"code": 400,
"status": "error",
"error": {
"code": 10003,
"desc": "时间戳过期"
},
"success": false
}
