November 23, 2017


Retrieve standard item prices from a package.

This script retrieves standard prices from a package. All standard prices don't have an specific
location, taking account this last, we'll retrieve all prices that have 'locationGroupId' IS NULL.
See below for more information.

Important manual pages:

Author: SoftLayer Technologies, Inc. <>
package main

import (

func main() {
	// SoftLayer API username and key
	username := "set me"
	apikey   := "set me"

	// The id of package you wish to get information
	packageId := 46             // Virtual Server Instance

	// Create SoftLayer API session
	sess := session.New(username, apikey)

	// Get SoftLayer_Product_Package service
	service := services.GetProductPackageService(sess)

	// Declare object mask in order to get specific data
	mask := "id,hourlyRecurringFee,laborFee,recurringFee,item"

	// Declare filter in order to get all item prices with locationGroupId = NULL
	filter := filter.Path("itemPrices.locationGroupId").IsNull().Build()

	// Call the getItemPrices() method to get item prices according to filter.
	itemPrices, err := service.Id(packageId).Mask(mask).Filter(filter).GetItemPrices()
	if err != nil {
		fmt.Printf("\n Unable to retrieve item prices from package:\n - %s\n", err)

	// Following helps to print the result in json format.
	for _,item := range itemPrices {
		jsonFormat, jsonErr := json.Marshal(item)
		if jsonErr != nil {


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