All Products
Search
Document Center

BSS OpenAPI:QueryInstanceBill

更新時間:Mar 01, 2024

Queries the bills of instances or billable items in a billing cycle.

Operation description

  • This API operation has been upgraded to DescribeInstanceBill. We recommend that you call the DescribeInstanceBill operation to query the bills of instances or billable items in a billing cycle. You can call the QueryInstanceBill operation to query a maximum of 50,000 data rows in a bill.
  • Instance bills are generated after bills are split. In most cases, the instance bills do not include data generated on the last day of the specified period.
  • The instance information changes within a billing cycle. The instance configurations and specifications and the time when the instance was used in the billing cycle are all recorded. For more information, see the corresponding bill details.
  • You can query the data generated in June 2020 or later for Cloud Communications services, and the data generated in November 2020 or later for Alibaba Cloud Domains.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
bssapi:QueryInstanceBillREAD
  • All Resources
    *
  • bssapi:ProductCode
  • bssapi:ProductType
none

Request parameters

ParameterTypeRequiredDescriptionExample
BillingCyclestringYes

The billing cycle. Format: YYYY-MM.

2020-03
ProductCodestringNo

The code of the service.

rds
ProductTypestringNo

The type of the service. This parameter is required if the ProductCode parameter is set to the service code of Alibaba Cloud Marketplace.

rds
SubscriptionTypestringNo

The billing method. Valid values:

  • Subscription: the subscription billing method
  • PayAsYouGo: the pay-as-you-go billing method

**

****This parameter must be used together with the ProductCode parameter.

PayAsYouGo
IsBillingItembooleanNo

Specifies whether to query data by billable item. Valid values:

  • false: does not query data by billable item. The data queried is consistent with the data that is displayed for the specified instance on the Billing Details tab of the Bill Details page in User Center.
  • true: queries data by billable item. The data queried is consistent with the data that is displayed for the specified billable item on the Billing Details tab of the Bill Details page in User Center.

Default value: false.

false
PageNumintegerNo

The number of the page to return. Default value: 1.

1
PageSizeintegerNo

The number of entries to return on each page. Default value: 20. Maximum value: 300.

20
IsHideZeroChargebooleanNo

Specifies whether to filter out a bill whose pretax gross amount and pretax amount are 0. Default value: false.******** Valid values:

  • false: does not filter the bill.
  • true: filters the bill.
false
BillingDatestringNo

The billing date. This parameter is required only if the Granularity parameter is set to DAILY. Format: YYYY-MM-DD.

2020-03-03
GranularitystringNo

The granularity at which bills are queried. Valid values:

  • MONTHLY: queries bills by month. The data queried is consistent with the data that is displayed for the specified billing cycle on the Billing Details tab of the Bill Details page in User Center.
  • DAILY: queries bills by day. The data queried is consistent with the data that is displayed for the specified day on the Billing Details tab of the Bill Details page in User Center.

You must set the BillingDate parameter before you can set the Granularity parameter to DAILY.

MONTHLY
BillOwnerIdlongNo

The ID of the member. If you specify a value for this parameter, you can query the bills of the specified member. If you leave this parameter empty, the bills of the current account are queried by default.

122

Response parameters

ParameterTypeDescriptionExample
object
Codestring

The status code returned.

Success
Messagestring

The message returned.

Successful!
RequestIdstring

The ID of the request.

79EE7556-0CFD-44EB-9CD6-B3B526E3A85F
Successboolean

Indicates whether the request is successful.

true
Dataobject

The data returned.

PageNuminteger

The page number of the returned page.

1
BillingCyclestring

The billing cycle in the YYYY-MM format.

2020-03
AccountIDstring

The ID of the account.

185xxxx3489
PageSizeinteger

The number of entries returned per page.

20
TotalCountinteger

The total number of returned entries.

2
AccountNamestring

The name of the account.

test@test.aliyunid.com
Itemsobject []

The details of the bill.

BillingDatestring

The billing date. This parameter is returned only if the Granularity parameter is set to DAILY. Format: YYYY-MM-DD.

2020-03
InstanceConfigstring

The configurations of the instance.

CPU:12
InternetIPstring

The public IP address.

34.xx.x.x
Itemstring

The type of the bill.

  • SubscriptionOrder: subscription order
  • PayAsYouGoBill: pay-as-you-go bill
  • Refund: refund
  • Adjustment: reconciliation
PayAsYouGoBill
Tagstring

The tag.

tag
InstanceIDstring

The ID of the instance.

i-kjhdskjgshfdlkjfdh
Currencystring

The type of the currency. Valid values:

  • CNY
  • USD
  • JPY
CNY
SubscriptionTypestring

The billing method. Valid values:

  • Subscription: the subscription billing method
  • PayAsYouGo: the pay-as-you-go billing method

**

****This parameter is returned together with the ProductCode parameter.

PayAsYouGo
InstanceSpecstring

The instance type of the instance.

ecs.sn1ne.3xlarge
DeductedByCouponsfloat

The amount deducted by using coupons.

0
BillingItemstring

The billable item. This parameter is returned only if the IsBillingItem parameter is set to true.

Other
Regionstring

The region.

China (Hangzhou)
CostUnitstring

The cost center.

Not allocated
ListPriceUnitstring

The unit of the unit price. This parameter is returned only if the isBillingItem parameter is set to true.

CNY
ResourceGroupstring

The resource group.

Default resource group
PipCodestring

The code of the service. The service code is the same as that displayed in User Center.

rds
ServicePeriodUnitstring

The unit of the validity period.

Seconds
PretaxAmountfloat

The pretax amount.

0
CommodityCodestring

The code of the commodity. The commodity code is the same as that displayed in User Center.

rds
ProductNamestring

The name of the service.

ApsaraDB RDS
NickNamestring

The name of the instance.

test
ProductDetailstring

The details of the service.

ApsaraDB RDS
Usagestring

The usage of the billable item. This parameter is returned only if the isBillingItem parameter is set to true.

100
IntranetIPstring

The private IP address.

192.xx.xx.xx
OwnerIDstring

The ID of the member account. This parameter is returned in a multi-account payment scenario.

169***013
UsageUnitstring

The unit of usage. This parameter is returned only if the isBillingItem parameter is set to true.

GB
InvoiceDiscountfloat

The discount amount.

0
DeductedByResourcePackagestring

The amount deducted by using resource plans.

NULL
ProductTypestring

The type of the service.

rds
ServicePeriodstring

The validity period.

10
Zonestring

The ID of the zone.

cn-hangzhou-h
ListPricestring

The unit price. This parameter is returned only if the isBillingItem parameter is set to true.

100
PretaxGrossAmountfloat

The pretax gross amount.

0
ProductCodestring

The code of the service.

rds
BillingTypestring

The billing type.

Other

Examples

Sample success responses

JSONformat

{
  "Code": "Success",
  "Message": "Successful!",
  "RequestId": "79EE7556-0CFD-44EB-9CD6-B3B526E3A85F",
  "Success": true,
  "Data": {
    "PageNum": 1,
    "BillingCycle": "2020-03",
    "AccountID": "185xxxx3489",
    "PageSize": 20,
    "TotalCount": 2,
    "AccountName": "test@test.aliyunid.com",
    "Items": {
      "Item": [
        {
          "BillingDate": "2020-03",
          "InstanceConfig": "CPU:12",
          "InternetIP": "34.xx.x.x",
          "Item": "PayAsYouGoBill",
          "Tag": "tag",
          "InstanceID": "i-kjhdskjgshfdlkjfdh",
          "Currency": "CNY",
          "DeductedByCashCoupons": 0,
          "SubscriptionType": "PayAsYouGo",
          "InstanceSpec": "ecs.sn1ne.3xlarge",
          "DeductedByCoupons": 0,
          "BillingItem": "Other\n",
          "Region": "China (Hangzhou)\n",
          "OutstandingAmount": 0,
          "CostUnit": "Not allocated\n",
          "ListPriceUnit": "CNY\n",
          "ResourceGroup": "Default resource group\n",
          "PipCode": "rds",
          "ServicePeriodUnit": "Seconds\n",
          "PretaxAmount": 0,
          "CommodityCode": "rds",
          "ProductName": "ApsaraDB RDS\n",
          "AdjustAmount": 0,
          "NickName": "test",
          "ProductDetail": "ApsaraDB RDS\n",
          "Usage": "100",
          "IntranetIP": "192.xx.xx.xx",
          "OwnerID": "169***013",
          "DeductedByPrepaidCard": 0,
          "UsageUnit": "GB",
          "PaymentAmount": 0,
          "InvoiceDiscount": 0,
          "DeductedByResourcePackage": "NULL",
          "ProductType": "rds",
          "ServicePeriod": "10",
          "Zone": "cn-hangzhou-h",
          "ListPrice": "100",
          "PretaxGrossAmount": 0,
          "CashAmount": 0,
          "ProductCode": "rds",
          "BillingType": "Other\n"
        }
      ]
    }
  }
}

Error codes

For a list of error codes, visit the Service error codes.