You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于通过Softlayer Billing Invoice API获取服务器标价的技术咨询

How to Get the Sticker Price (List Price) for Discounted SoftLayer Servers via API

Great question! I’ve worked extensively with SoftLayer’s billing and product APIs, so let me confirm your approach and walk you through how to pull the list price alongside the discounted rate you’re already fetching.

Your current plan to use the SoftLayer_Billing_Invoice service and its getItems method is totally on the right track—you just need to extend your request with an object mask to retrieve the associated list price data that’s linked to each invoice item.

Key Details to Know

Each SoftLayer_Billing_Invoice_Item is tied to a billingItem, which in turn connects to a productItemPrice object. This object contains both:

  • recurringFee: The discounted price you’re already seeing on invoices
  • listPrice: The original sticker price you’re looking for

Step-by-Step Implementation

  1. Add an Object Mask to Your getItems Call
    When you call getItems, include a mask that drills down to the productItemPrice of each billing item. Here’s the mask you’ll need:

    mask[billingItem[productItemPrice[listPrice, recurringFee], productItem[description]]]
    

    Adding productItem[description] will also help you easily identify which server each price corresponds to.

  2. Example Code (Using SoftLayer Python Client)
    Here’s a practical snippet to fetch both prices for your server invoice items:

    import SoftLayer
    
    # Initialize your API client
    client = SoftLayer.Client(username="YOUR_SL_USERNAME", api_key="YOUR_SL_API_KEY")
    
    # Replace with a target invoice ID (you can fetch recent invoices via SoftLayer_Billing_Invoice::getInvoices if needed)
    target_invoice_id = 12345678
    
    # Apply the object mask
    price_mask = "mask[billingItem[productItemPrice[listPrice, recurringFee], productItem[description]]]"
    invoice_items = client["SoftLayer_Billing_Invoice"].getItems(id=target_invoice_id, mask=price_mask)
    
    # Filter to only server-related items (adjust the filter logic based on your invoice descriptions)
    server_billing_items = [
        item for item in invoice_items
        if "Server" in item["billingItem"]["productItem"]["description"]
    ]
    
    # Print out the results
    for item in server_billing_items:
        print(f"Server: {item['billingItem']['productItem']['description']}")
        print(f"Sticker Price: ${item['billingItem']['productItemPrice']['listPrice']}")
        print(f"Discounted Price: ${item['billingItem']['productItemPrice']['recurringFee']}\n")
    
  3. Adjust Filters as Needed
    If your invoices include non-server items, tweak the filter to match your server-specific category codes or descriptions. For example, you could check for categoryCode == 'server' in the productItem object for more precise filtering.

Confirmation of Your Initial Approach

Your idea to use the billing invoice API is solid because it directly ties each billed item to its underlying product pricing data—this is the most reliable way to get both discounted and list prices for active servers that have been invoiced.

内容的提问来源于stack exchange,提问作者ChuanWee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:36:50