November 23, 2017
Get location prices for a datacenter

This script retrieves location prices for a package from a specific datacenter

Important manual pages:
@Author: SoftLayer Technologies, Inc. <>

# So we can talk to the SoftLayer API:
import SoftLayer
import json

# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Declare the package id
packageId = 265
# Declare the datacenter name that you wish to retrieve the item prices
datacenter = 'London 1'
# Create a client instance
client = SoftLayer.Client(username=API_USERNAME, api_key=API_KEY)
objectMask = 'mask[pricingLocationGroup[locations[longName]]]'
# Declare an object filter to get location item prices
objectFilter = {'itemPrices': {'pricingLocationGroup': {'locations': {'longName': {'operation': datacenter}}}}}
    standardPrices = client['SoftLayer_Product_Package'].getItemPrices(id=packageId, mask=objectMask, filter=objectFilter)
    print(json.dumps(standardPrices, sort_keys=True, indent=2, separators=(',', ':')))
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to get location item prices faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))


If this article contains any error, or leaves any of your questions unanswered, please help us out by opening up a github issue.
Open an issue