João Cardoso edited this page Oct 16, 2017 · 16 revisions

Working with LibItemCache's API is very similar to working with Blizzard's: for example, the method :GetItemInfo(owner, bag, slot) works much alike the server method GetItemInfo(bag, slot).

It is strictly better than using Blizzard's API though, because it allows you to select the owner to query, and works independently of your character's location - for instance, whether he/she is at the bank is irrelevant.

Query API

:GetOwnerInfo(ownerID)

Returns information about the requested owner, such as class, gender and money owned, given a valid ownerID. An owner is an in-game entity that possesses items - currently, a character or a guild.

local info = LibStub('LibItemCache-2.0'):GetOwnerInfo('Smartypants')
print(info.money)

:bulb: All LibItemCache functions assume that, if ownerID is nil, then the current character being played is the owner being queried.

:GetBagInfo(ownerID, bagID)

Returns an information data structure about the requested bag. Note that the Void Storage is considered a bag as well, and that guild bank tabs are considered bags owned by the guild. See more in bagID.

local info = LibStub('LibItemCache-2.0'):GetOwnerInfo('Smartypants', 1)
print(info.icon, info.free)

:GetItemInfo(ownerID, bagID, slot)

Similarly to :GetBagInfo, returns an information data structure about the requested item slot.

Listing API

:IterateOwners()

Returns a stateless iterator over all the cached onwers (players and guilds) that belong to the current realm being played on, or to realms the current one is connected to.

for ownerID in LibStub('LibItemCache-2.0'):IterateOwners() do
  print(ownerID)
end

LibItemCache :floppy_disk:

Using the Library
API
Data Specification
Advanced Uses

Exposing your Cache
Interface Protocol

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.