Shop Actions & Stock API
This page documents the committed source. Treat revision-sensitive RuneLite UI, packet, or in-game outcomes as pending live-client verification unless the page records direct evidence.
ShopActions provides static, paced, result-aware action dispatches for buying items from NPC shops, while query helpers handle stock inspections.
Action Methods
All buy methods return an InteractionResult indicating the outcome. You must run them while the shop interface is open, and they respect ActionPacer settings. If pacing blocks an action, it returns InteractionStatus.PACED and you should retry it on a subsequent tick.
Buying Items
| Method (ID overload) | Method (Name overload) | Action Queued |
|---|---|---|
buyOne(int itemId) | buyOne(String name) | Buy-1 |
buyFive(int itemId) | buyFive(String name) | Buy-5 |
buyTen(int itemId) | buyTen(String name) | Buy-10 |
buyFifty(int itemId) | buyFifty(String name) | Buy-50 |
Name overloads are case-insensitive and match using the display name (tags stripped).
Stock Queries
| Method | Returns | Description |
|---|---|---|
isOpen() | boolean | true if a shop container interface is currently open. |
getStock(int itemId) | int | Returns the quantity of the item in stock (returns 0 if not found or shop is closed). |
getItems() | List<Integer> | Returns a list of all item IDs currently visible in the open shop stock. |
Developer Example
Open a shop and purchase items while checking stock levels:
import com.n3plugins.Api.actions.ShopActions;
import com.n3plugins.Api.common.InteractionResult;
import com.n3plugins.Api.common.InteractionStatus;
public void purchaseRunes() {
// 1. Ensure the shop interface is open
if (!ShopActions.isOpen()) {
log.debug("Waiting for shop interface to be opened by pathing or NPC interaction.");
return;
}
// 2. Check stock level before buying (e.g. ItemID.DEATH_RUNE = 560)
int stock = ShopActions.getStock(560);
if (stock > 10) {
// Buy 10 runes
InteractionResult result = ShopActions.buyTen(560);
if (result.getStatus() == InteractionStatus.PACED) {
return; // Wait and retry next tick
}
if (result.failed()) {
log.warn("Buy action failed: {}", result.getMessage());
}
} else {
log.info("Death rune stock is too low ({}); skipping purchase.", stock);
}
}
A returned InteractionResult.succeeded() (status DISPATCHED) indicates the packet wrote to the client queue successfully. It does not guarantee the server processed the trade or that player coins were sufficient. Monitor player inventory item-container updates via the events layer to track final transaction outcomes.