Skip to content

How to Buy and Sell Items on the Grand Exchange

Open the Grand Exchange

You can open the Grand Exchange by standing near it then calling:

GrandExchange.open();

Buy and collect items

With it open, you can buy items using the GrandExchange#buyItem method which takes three parameters: item name, amount, and price.

Then, you can sleep until it's ready to collect, and if you manage to buy them, you can actually collect the items:

1
2
3
4
5
if (GrandExchange.buyItem("Cowhide", 100, 200)) {
    if (Sleep.sleepUntil(GrandExchange::isReadyToCollect, 15000)) {
        GrandExchange.collect();
    }
}

Line 1: This will attempt to put an offer for 100 cowhides at a price of 200 each, and return true if it succeeds.

Line 2: Then we wait until either the item is purchased, or 15 seconds (15000 ms) has passed. This will only return true if the condition is met, so if it times out it won't try to collect.

Line 3: Press the collect button to get the items

Sell items and collect the coins

Adding items for sale and collecting the coins is just as easy:

1
2
3
4
5
if (GrandExchange.sellItem("Cowhide", 100, 5)) {
    if (Sleep.sleepUntil(GrandExchange::isReadyToCollect, 15000)) {
        GrandExchange.collect();
    }
}

Line 1: This will attempt to list 100 cowhides for sale at a price of 5 each, and return true if it succeeds.

Line 2: Then we wait until either the item has sold, or 15 seconds (15000 ms) has passed. This will only return true if the condition is met, so if it times out it won't try to collect.

Line 3: Press the collect button to get the coins