Python Request Example

Finance Finance

  • API Reference
    • Access control
    • Balance Query Related Interfaces
      • Account Balance Query
    • Bill Related Interfaces
      • Appendix
      • Charge Item Bill
      • Python Request Example
      • Resource Month Bill
    • Error response
    • Feature Update Records
    • General Description
    • Interface Specifications
    • Introduction
  • Bill Management
    • Bill Details
    • Bill Subscription
    • Consumption Information Subscription Guide
    • Consumption Overview
    • How to View
    • Tag-Based Billing
  • Charge
    • Billing & Configuration Changes
      • Configuration Upgrade Or Shrinkage
      • Shift Charge
    • Charge type
    • On-Demand Billing
    • Pay-as-you-go
    • Subscription billing
  • Contract
    • Apply for Electronic Contract
    • Overview
  • Cost Management
    • Cost Allocation
    • Cost Splitting
  • Disclaimer
  • Enterprise Organization Financial Management
  • FAQs
    • Bill and Debt
    • Billing Issues
    • Common Questions Overview
    • Contract Issues
    • Coupon Issues
    • Dedicated Account Remittance Issues
    • Invoice Issues
    • Order Issues
    • Recharge Issues
    • Refund Issues
    • Renew Issues
    • Withdrawal Issues
  • Invoice
    • Apply for Baidu Intelligent Cloud Invoice
    • Return or Exchange Baidu Intelligent Cloud Invoice
  • Multi-Account Multi-User Financial Management
    • Enterprise Organization - Financial Management
    • Multi-User Access Control - Financial Permission
    • Unified Finance
  • Order Management
  • Overview
  • Partner Deposit Payment
  • Purchase Guide
    • Coupon
      • Activating Coupons
      • Coupon Overview
      • Using Coupons
      • Viewing Coupons
    • Income and Expense Details
    • Purchase
    • Recharge
      • Exclusive Account Wire Transfer
      • Recharge Operations
      • Viewing Balance
    • Refund and Compensation
      • Product Compensation Standards
      • Refund Application Process
      • Refund policy
      • Unsubscribe Overview
      • Unsubscribe Rule Description
    • Renew
      • Auto-renewal
      • Renew Overview
      • Unified Resource Expiration Time
    • Withdrawal
  • Resource Package Management
    • Resource Package Deduction Details
    • Resource Package Overview
  • SDK
    • Java-SDK
      • Bill
      • BillingClient
      • Exception handling
      • Install SDK
      • Overview
      • Version Update Description
All documents
menu
No results found, please re-enter

Finance Finance

  • API Reference
    • Access control
    • Balance Query Related Interfaces
      • Account Balance Query
    • Bill Related Interfaces
      • Appendix
      • Charge Item Bill
      • Python Request Example
      • Resource Month Bill
    • Error response
    • Feature Update Records
    • General Description
    • Interface Specifications
    • Introduction
  • Bill Management
    • Bill Details
    • Bill Subscription
    • Consumption Information Subscription Guide
    • Consumption Overview
    • How to View
    • Tag-Based Billing
  • Charge
    • Billing & Configuration Changes
      • Configuration Upgrade Or Shrinkage
      • Shift Charge
    • Charge type
    • On-Demand Billing
    • Pay-as-you-go
    • Subscription billing
  • Contract
    • Apply for Electronic Contract
    • Overview
  • Cost Management
    • Cost Allocation
    • Cost Splitting
  • Disclaimer
  • Enterprise Organization Financial Management
  • FAQs
    • Bill and Debt
    • Billing Issues
    • Common Questions Overview
    • Contract Issues
    • Coupon Issues
    • Dedicated Account Remittance Issues
    • Invoice Issues
    • Order Issues
    • Recharge Issues
    • Refund Issues
    • Renew Issues
    • Withdrawal Issues
  • Invoice
    • Apply for Baidu Intelligent Cloud Invoice
    • Return or Exchange Baidu Intelligent Cloud Invoice
  • Multi-Account Multi-User Financial Management
    • Enterprise Organization - Financial Management
    • Multi-User Access Control - Financial Permission
    • Unified Finance
  • Order Management
  • Overview
  • Partner Deposit Payment
  • Purchase Guide
    • Coupon
      • Activating Coupons
      • Coupon Overview
      • Using Coupons
      • Viewing Coupons
    • Income and Expense Details
    • Purchase
    • Recharge
      • Exclusive Account Wire Transfer
      • Recharge Operations
      • Viewing Balance
    • Refund and Compensation
      • Product Compensation Standards
      • Refund Application Process
      • Refund policy
      • Unsubscribe Overview
      • Unsubscribe Rule Description
    • Renew
      • Auto-renewal
      • Renew Overview
      • Unified Resource Expiration Time
    • Withdrawal
  • Resource Package Management
    • Resource Package Deduction Details
    • Resource Package Overview
  • SDK
    • Java-SDK
      • Bill
      • BillingClient
      • Exception handling
      • Install SDK
      • Overview
      • Version Update Description
  • Document center
  • arrow
  • FinanceFinance
  • arrow
  • API Reference
  • arrow
  • Bill Related Interfaces
  • arrow
  • Python Request Example
Table of contents on this page
  • Python demo code example for resource month bill query.
  • Prerequisites
  • Request example

Python Request Example

Updated at:2025-10-27

Python demo code example for resource month bill query.

Prerequisites

pip install bce-python-sdk

Request example

Plain Text
1from baidubce.auth import bce_v1_signer
2from baidubce import protocol
3from baidubce.auth.bce_credentials import BceCredentials
4from baidubce.bce_client_configuration import BceClientConfiguration
5from baidubce.http import bce_http_client, http_content_types, http_headers
6from baidubce.http import handler
7from baidubce.http import http_methods
8def query_demo(config, month, begin_time, end_time, product_type, service_type, page_no, page_size):      
9    return bce_http_client.send_request(
10        config,
11        bce_v1_signer.sign,
12        [handler.parse_error, handler.parse_json],
13        http_methods.GET,
14        b"/v1/bill/resource/month",
15        None,
16        {http_headers.CONTENT_TYPE: http_content_types.JSON},
17        {
18            "month": month,
19            "beginTime": begin_time,
20            "endTime": end_time,
21            "productType": product_type,
22            "serviceType": service_type,
23            "pageNo": page_no,
24            "pageSize": page_size
25         })
26         
27if __name__ == '__main__':
28    conf = BceClientConfiguration(
29 credentials = BceCredentials("Replace with user’s AccessKey", "Replace with user’s SecretKey"),
30        endpoint="billing.baidubce.com",
31        protocol=protocol.HTTP,
32        connection_timeout_in_mills=60000
33    )
34
35    res = query_demo(conf, "2021-02", "2021-02-01", "2021-02-28", "postpay", "BCC", 1, 10)
36 print(res.raw_data) # Print the HTTP response.

Previous
Charge Item Bill
Next
Resource Month Bill