Item Prices & Definitions

Learn how to get item prices, names, descriptions, and other item information using ItemManager.

ItemManager provides access to item data from the game. This is essential for plugins that need to:

- Calculate bank values

- Show item prices

- Display item names

- Track loot values


Getting Item Prices


The Grand Exchange price is the most common use case:


int price = itemManager.getItemPrice(995); // Coins

System.out.println("Coins price: " + price + " gp");


**Note**: Returns 0 for items without a GE price.


Getting Item Definitions


ItemComposition contains all item information:

- Name

- Description

- Stackable status

- Tradeable status

- And more


ItemComposition comp = itemManager.getItemComposition(itemId);

String itemName = comp.getName();

String description = comp.getDescription();


Calculating Total Value


When calculating bank or inventory value, use long to avoid overflow:


long totalValue = 0;

for (Item item : inventory.getItems()) {

if (item.getId() != -1) {

int price = itemManager.getItemPrice(item.getId());

totalValue += (long) price * item.getQuantity();

}

}


Best Practices


- Always check if price is 0 (item may not have GE price)

- Use long for total calculations to prevent overflow

- ItemComposition is cached - safe to call frequently

- Prices update periodically from GE data

Code Examples

Example 1

java
1// Get item price
2@Inject
3private ItemManager itemManager;
4
5public void checkItemPrice(int itemId) {
6    int price = itemManager.getItemPrice(itemId);
7    if (price > 0) {
8        System.out.println("Item " + itemId + " costs " + price + " gp");
9    } else {
10        System.out.println("Item has no GE price");
11    }
12}

Example 2

java
1// Calculate bank value
2public long calculateBankValue() {
3    ItemContainer bank = client.getItemContainer(InventoryID.BANK);
4    if (bank == null) {
5        return 0;
6    }
7    
8    long totalValue = 0;
9    for (Item item : bank.getItems()) {
10        if (item.getId() != -1) {
11            int price = itemManager.getItemPrice(item.getId());
12            totalValue += (long) price * item.getQuantity();
13        }
14    }
15    
16    return totalValue;
17}

Example 3

java
1// Get item information
2ItemComposition comp = itemManager.getItemComposition(995);
3String itemName = comp.getName();
4String description = comp.getDescription();
5boolean stackable = comp.isStackable();
6boolean tradeable = comp.isTradeable();
7
8System.out.println(itemName + ": " + description);

Related API Classes

Related Plugins

Related Concepts