All Products
Search
Document Center

BSS OpenAPI:QueryInstanceBill

Last Updated:Nov 09, 2023

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

debugging

Authorization information

There is currently no authorization information disclosed in the API.

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
DeductedByCashCouponsfloat

The amount deducted by using vouchers.

0
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)
OutstandingAmountfloat

The unsettled amount.

0
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
AdjustAmountfloat

The amount deducted by using credit refunds.

0
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
DeductedByPrepaidCardfloat

The amount deducted by using prepaid cards.

0
UsageUnitstring

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

GB
PaymentAmountfloat

The amount paid in cash.

0
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
CashAmountfloat

The amount paid in cash. The amount that was deducted by using credit refunds is not included.

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.