Query Space Usage of a Category
Updated: 2022-09-02 18:08:07
API Description
1、通过分类id查询分类目录的空间占用情况
2、接口支持https协议
API URL
http://api.polyv.net/v2/cata/size
<a href="/req.html?api=http://api.polyv.net/v2/cata/size"" target="_blank">Online API Call
Request Method
GET
API Constraints
- The API supports both HTTP and HTTPS. HTTPS is recommended for security. API calls have a frequency limit. See details
Request Parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| userid | true | String | POLYV VOD account ID. Refer to Get Secret Key for acquisition. Path: Official Website -> Login -> VOD (API Interface) |
| ptime | true | Long | Current time in milliseconds, valid for 3 minutes |
| sign | true | String | Signature, a 40-character uppercase SHA1 value. The secretkey used to generate the signature is critical for communication data security. It must not be stored or 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 Signature Generation Rules |
| cataid | true | String | Category ID. Default is 1, representing the default category |
Example
http://api.polyv.net/v2/cata/size?sign=75FA8B9593C80D848A645680C2464E3181C379B9&cataid=1&userId=1b448be323&ptime=1617849301530&userid=1b448be323
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | Integer | Response status code. 200 indicates success, non-200 indicates failure. See Global Error Description |
| status | String | Response status text |
| message | String | Response description. When code is 400 or 500, it provides additional error details |
| data | Long | On success, returns the space usage of the category in bytes |
Error Code List
| code | message | Description |
|---|---|---|
| 400 | userid is blank. | Username is empty |
| 400 | Could not find user by userid. | User ID does not exist |
| 400 | the sign is not right. | Encryption string error |
| 400 | cataid does not exist. | cataid does not exist |
| 400 | cataid format is incorrect. | cataid is not a pure number |
| 500 | Failed to retrieve. | Backend error or exception |
| 200 | success | Query successful |
Java Request Example
For quick integration of the basic code, please 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 VodSignUtil.java in the downloaded file.
It is strongly recommended to use the VOD Java SDK for API integration. The VOD 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(VodStatisticsTest.class);
/**
* 查询分类目录的空间占用
* @throws Exception
* @throws NoSuchAlgorithmException
*/
@Test
public void testGetCategorySpaceUsage() throws Exception, NoSuchAlgorithmException {
//公共参数,填写自己的实际参数
String secretKey = super.secretKey;
String userId = super.userId;
String ptime = String.valueOf(System.currentTimeMillis());
//业务参数
String url = "http://api.polyv.net/v2/cata/size";
String cataid = "1602300731843";
Map<String, String> requestMap = new HashMap<>();
requestMap.put("ptime", ptime);
requestMap.put("cataid", cataid);
requestMap.put("userid", userId);
requestMap.put("sign", VodSignUtil.getSign(requestMap, secretKey));
String response = HttpUtil.get(url, requestMap);
log.debug("测试查询分类目录的空间占用,{}", response);
//do somethings
}
Response Example
For global system error descriptions, see Global Error Description
Success Example
{
"code":200,
"status":"success",
"message":"success",
"data":474409450
}
Error Example
{
"code": 400,
"status": "error",
"message": "ptime is too old.",
"data": ""
}
