Bank API
The Bank API allows you to interact with the Bank within OSRS, it handles everything from opening the bank to interacting with items within the bank.
Bank Tab
To retrieve the current tab of the bank you can use the currentTab
function which will return an integer value of the current tab open in the bank.
To open a specific tab in the bank you can pass the index of the tab to the currentTab
function like so
Depositing
There are multiple functions to provide support for depositing items into the bank.
Using Item Ids
Using Item Strings
String itemName = "Ring of recoil";
int amountToDeposit = 12;
Bank.deposit(itemName, amountToDeposit);
String itemName = "Ring of recoil";
int amountToDeposit = 12;
Bank.deposit(itemName, Bank.Amount.ALL);
Depositing with exceptions
Sometimes you may want to deposit all items except for a specific item e.g a pickaxe when you're mining. The Bank API offers a function called depositAllExcept()
that does exactly this.
Checking if the bank is in the viewport
Before interacting with the bank you check if the bank is in the current viewport you can do this by calling the inViewport
function.
Opening the bank
To open a bank you need to check if the Bank is in the viewport and then call Bank.open()
to open the bank.
Retrieving the nearest bank
To get the nearest bank you can call Bank.nearest()
however the bank must be loaded for this to work, so if you're in a cave Bank.nearest()
will return null. Bank.nearest()
returns a Locatable type if a bank can be found.
Checking if the bank is open
Before interacting with the items in your bank you will want to check if the bank is open you can do this by calling Bank.opened()
Withdrawing from the bank
Withdrawing from the bank is a similar process to depositing to the bank