Querying Cost Data
Function
This API is used to query the cost data on the self-built platform.
- Original costs: There is an appropriately one-hour delay before data from Billing Center shows up as original costs for the current month on the platform. To view the exact amounts, see the final bill that will be generated on the 3rd day of the following month. The original costs are available for viewing after 12:00 noon on the 4th day of the following month.
- Amortized costs: They are not calculated in real time. Your amortized costs are refreshed once every 24 hours, and it may take longer than 24 to 48 hours for some data to be displayed. The current month costs of monthly-settlement cloud services, such as CDN and VPC, are available for viewing after 12:00 noon on the 4th day of the following month.
Note:
This API can be invoked using the customer AK/SK or token.
The data of the previous month is available after the bill is generated.
Debugging
You can debug this API in API Explorer.
URI
POST /v4/costs/cost-analysed-bills/query
Parameter |
Mandatory |
Value Range |
Description |
---|---|---|---|
X-Language |
No |
A maximum of 8 characters |
Language.
Default value: zh_CN |
Request
Request Parameters
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
time_condition |
Yes |
TimeCondition Object |
- |
Time condition. For details, see Table 2. |
groupby |
Yes |
List<GroupBy> |
A maximum of 2 values |
Search dimension. For details, see Table 3.
NOTE:
If there are two values for this parameter, the values must be a combination of tag, cost_unit, and dimension, or both of these two values are set to dimension. |
cost_type |
Yes |
String |
A maximum of 256 characters |
Cost type.
|
amount_type |
Yes |
String |
Amount type.
|
|
filters |
No |
List<Filter> |
Minimum length: 0 characters Maximum length: 100 characters |
Filter. For details, see Table 4. If this parameter is not included in the request parameters, is left empty, or is set to null, it cannot be used as a filter criterion. |
offset |
No |
Integer |
[0-200000] |
Offset, starting from 0. The default value is 0.
NOTE:
This parameter is used for pagination. Use the default value 0 if pagination is not required. offset indicates the offset relative to the first data record that meets the conditions. If you set offset to 1, the second and subsequent data records will be returned. For example, there are 10 data records, and if you set limit to 10 and offset to 1, the second to the tenth data records will be returned. |
limit |
No |
Integer |
[1,1000] |
Number of records queried each time. The default value is 10. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
time_measure_id |
Yes |
Integer |
[1,2] |
Time unit.
|
begin_time |
Yes |
String |
32 |
Start date (GMT+08:00).
|
end_time |
Yes |
String |
32 |
End date (GMT+08:00).
NOTICE:
Only the cost data within 18 months can be queried. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
type |
Yes |
String |
A maximum of 64 characters |
|
key |
Yes |
String |
A maximum of 128 characters |
|
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
operator |
Yes |
Integer |
[0-1] |
Operator.
|
filter_factor |
Yes |
FilterFactor Object |
- |
Filter factor. For details, see Table 5. |
Parameter |
Mandatory |
Type |
Value Range |
Description |
---|---|---|---|---|
key |
Yes |
String |
A maximum of 256 characters |
Grouping conditions.
|
value |
Yes |
List<String> |
Minimum count: 1 Maximum count: 100 |
Filter value. |
Example Request
POST https://bss-intl.myhuaweicloud.com/v4/costs/cost-analysed-bills/query HTTP/1.1 Content-Type: application/json X-Auth-Token: MIIPAgYJKoZIhvcNAQcCo...ggg1BBIINPXsidG9rZ { "amount_type": "PAYMENT_AMOUNT", "offset": 0, "cost_type": "ORIGINAL_COST", "limit": 10, "groupby": [{ "type": "dimension", "key": "CLOUD_SERVICE_TYPE" }], "filters": [{ "filter_factor": { "value": ["cn-north-1"], "key": "REGION_CODE" }, "operator": 0 }], "time_condition": { "end_time": "2021-07-15", "begin_time": "2021-07-14", "time_measure_id": 1 } }
Response Message
Response Parameters
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
error_code |
String |
A maximum of 20 characters |
Returned value. For details, see Returned Values. This parameter is returned only when the query failed. |
error_msg |
String |
A maximum of 1000 characters |
Error description. This parameter is returned only when the query failed. |
currency |
String |
A maximum of 8 characters |
Currency.
|
total_count |
Integer |
- |
Total number of records. |
cost_data |
List<CostDataByDimension> |
- |
Cost details by day or month. For details, see Table 6. |
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
dimensions |
List<DimensionGroup> |
A maximum of 1 value |
Dimensions. For details, see Table 7. |
costs |
List<Cost> |
Max Count: 10000 |
Cost value. For details, see Table 8. |
amount_by_costs |
String |
A maximum of 64 characters |
Total cost in a period. |
official_amount_by_costs |
String |
A maximum of 64 characters |
Total expenditures based on list prices in a period. |
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
key |
String |
A maximum of 128 characters |
Grouping conditions
|
value |
String |
- |
Dimension. |
Parameter |
Type |
Value Range |
Description |
---|---|---|---|
time_dimension_value |
String |
A maximum of 20 characters |
Time dimension.
|
time_measure_id |
Int |
- |
Time unit.
|
amount |
String |
A maximum of 64 characters |
One of the following cost types: original costs, net original costs, amortized costs, and net amortized costs. |
official_amount |
String |
A maximum of 64 characters |
List price. |
Example Response
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Content-Length: length Date: response time { "currency": "USD", "total_count": 1, "cost_data": [ { "dimensions": [ { "key": "tag", "value": "Group:noTagKey" } ], "costs": [ { "time_dimension_value": "2021-08", "time_measure_id": 2, "amount": "13225.00", "official_amount": "13225.00" } ], "amount_by_costs": "13225.00", "official_amount_by_costs": "13225.00" } ] }
Returned Values
- 4xx: This class of HTTP status code is intended for situations in which the error seems to have been caused by the client, for example, the request contains bad syntax or incorrect parameters. You must ensure the request is correct.
- 5xx: This class of HTTP status code is intended for cases in which the Huawei Cloud server is aware that it has encountered an error or is otherwise incapable of performing the request. In this case, contact Huawei Cloud customer service.
HTTP Value |
Error Code |
Description |
---|---|---|
400 |
CBC.0100 |
Invalid parameter. |
400 |
CBC.18000014 |
Cost Center not enabled. |
400 |
CBC.18000016 |
Insufficient permissions. Contact your partner. |
400 |
CBC.18000053 |
Insufficient permissions. Contact your enterprise master. |
500 |
CBC.0999 |
Other errors. |
400 |
CBC.18000048 |
Too many independent accounting members. Specify a member account for query. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot