November 23, 2017


# Retrieve the billing items  for the Bare Metals in the account.
# This script makes a single call to the getHardware() method in the
# SoftLayer_Account API service and uses a object mask to get the
# billing items and items for each Bare Metal server in the account.
# Important manual pages
# License:
# Author: SoftLayer Technologies, Inc. <>
require 'softlayer_api'
require 'pp'

# Your SoftLayer API key and username.
USERNAME = 'set me'
API_KEY = 'set me'

# Declaring the object mask to get information about the items
object_mask = 'mask[id, hostname, domain, datacenter[longName], billingItem[item]]'

# Declaring the API client
client = USERNAME, api_key: API_KEY)
hardware_account = client['SoftLayer_Account']

  # Retrieve the bare metal servers billing items for the account.
  servers = hardware_account.object_mask(object_mask).getHardware
  print servers
rescue StandardError => exception
  puts "Unable to retrieve the servers. : #{exception}"


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