Okay .. after playing with my little project addon for a little while I came up with the following results.
Events:
AUCTION_HOUSE_BROWSE_RESULTS_UPDATED - Triggered when you click Search
AUCTION_HOUSE_NEW_RESULTS_RECEIVED - Triggered when you click on a specific item on the list
Functions:
local results = C_AuctionHouse.GetBrowseResults()
Used after AUCTION_HOUSE_BROWSE_RESULTS_UPDATED returns a table with the following as example entries
Lua Code:
{
["itemKey"] = {
["itemLevel"] = 0,
["itemSuffix"] = 0,
["itemID"] = 159827,
["battlePetSpeciesID"] = 0,
},
["totalQuantity"] = 20,
["minPrice"] = 100,
["containsOwnerItem"] = false,
}, -- [4]
{
["itemKey"] = {
["itemLevel"] = 1,
["itemSuffix"] = 0,
["itemID"] = 54456,
["battlePetSpeciesID"] = 0,
},
["totalQuantity"] = 1,
["minPrice"] = 100,
["containsOwnerItem"] = false,
}, -- [16]
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)
Used after AUCTION_HOUSE_NEW_RESULTS_RECEIVED returns the following table
The following are two tables, one commodity, one item
Lua Code:
{
["isPet"] = false,
["itemName"] = "Bomb-samdi Mojo Bombs",
["isCommodity"] = true,
["isEquipment"] = false,
["iconFileID"] = 463515,
["quality"] = 2,
}, -- [2]
{
["isPet"] = false,
["itemName"] = "Mournful Essence",
["isCommodity"] = false,
["isEquipment"] = false,
["iconFileID"] = 132871,
["quality"] = 1,
}, -- [2]
You can then use the following function to find out what auctions there are relating to that item
Lua Code:
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
This then results in either an ITEM_SEARCH_RESULTS_UPDATED event call or COMMODITY_SEARCH_RESULTS_UPDATED event call.
For Items ..
Lua Code:
local itemKey, auctionID = ...
local numResults = C_AuctionHouse.GetNumItemSearchResults(itemKey)
for index = 1, numResults do
local result = C_AuctionHouse.GetItemSearchResultInfo(itemKey, index)
....
end
Resulting in the following table contents
Lua Code:
{
["itemKey"] = {
["itemLevel"] = 1,
["itemSuffix"] = 0,
["itemID"] = 54456,
["battlePetSpeciesID"] = 0,
},
["containsOwnerItem"] = false,
["buyoutAmount"] = 100,
["itemLink"] = "|cffffffff|Hitem:54456::::::::110:264::::::|h[Mournful Essence]|h|r",
["quantity"] = 1,
["containsSocketedItem"] = false,
["owners"] = {
"Riannia", -- [1]
},
["containsAccountItem"] = false,
["timeLeft"] = 2,
["auctionID"] = 2092193565,
}, -- [1]
For Commodities ..
Lua Code:
local itemID = ...
local numResults = C_AuctionHouse.GetNumCommoditySearchResults(itemID)
for index = 1,numResults do
local result = C_AuctionHouse.GetCommoditySearchResultInfo(itemID, index)
....
end
Which results in the following table of data
Lua Code:
{
["containsOwnerItem"] = false,
["timeLeftSeconds"] = 27423,
["quantity"] = 20,
["itemID"] = 159827,
["owners"] = {
"Galdrena", -- [1]
"Rhys", -- [2]
},
["unitPrice"] = 100,
["containsAccountItem"] = false,
["numOwnerItems"] = 0,
["auctionID"] = 2092122023,
}, -- [1]
It is then the case of accessing the table contents as per normal for display purposes.
This of course still relies on you making that initial search and clicking the button and isn't automated at all. I suspect there is a way of doing this periodically using other functions. But whichever way you use auction house api ( if there is more than one way ) you will ultimately end up with repeating event calls for commodity and item updates after you have requested an auction search query.
I then added the following to automate searching for a specific set of items and then one of the items in the list generated.. it didn't work quite right but will give an idea of what is possible but it does mean you don't have to click and select to get information out. You just have to have opened the auction house window to start it off.
Lua Code:
if event == "AUCTION_HOUSE_SHOW" then
local searchString = "Netherweave"
local minLevel = nil
local maxLevel = nil
local filtersArray = nil
local filterData = { classID = LE_ITEM_CLASS_CONTAINER, subClassID = nil, inventoryType = nil }
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local query = {};
query.searchString = searchString;
query.minLevel = minLevel;
query.maxLevel = maxLevel;
query.filters = filtersArray;
query.itemClassFilters = filterData;
query.sorts = sorts
XrystalUI_Auctioneer_Info = {}
print("Sending Browse Query Automatically")
C_AuctionHouse.SendBrowseQuery(query);
elseif event == "AUCTION_HOUSE_BROWSE_RESULTS_UPDATED" then
-- Get the first 500 items
local results = C_AuctionHouse.GetBrowseResults()
local itemKey = results[1].itemKey
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
print("Automatically searching for item ", itemKey)
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["BrowseResults"] = results
So my final version of my addon file is as follows:
Lua Code:
XrystalUI_Auctioneer_Info = XrystalUI_Auctioneer_Info or {}
local function OnEvent(self, event, ...)
if event == "AUCTION_HOUSE_SHOW" then
local searchString = "Netherweave"
local minLevel = nil
local maxLevel = nil
local filtersArray = nil
local filterData = { classID = LE_ITEM_CLASS_CONTAINER, subClassID = nil, inventoryType = nil }
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local query = {};
query.searchString = searchString;
query.minLevel = minLevel;
query.maxLevel = maxLevel;
query.filters = filtersArray;
query.itemClassFilters = filterData;
query.sorts = sorts
XrystalUI_Auctioneer_Info = {}
print("Sending Browse Query Automatically")
C_AuctionHouse.SendBrowseQuery(query);
elseif event == "AUCTION_HOUSE_BROWSE_RESULTS_UPDATED" then
-- Get the first 500 items
local results = C_AuctionHouse.GetBrowseResults()
local itemKey = results[1].itemKey
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
print("Automatically searching for item ", itemKey)
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["BrowseResults"] = results
elseif event == "AUCTION_HOUSE_NEW_RESULTS_RECEIVED" then
local itemKey = ...
if ( itemKey ) then
-- Retrieve Info about this item
local itemKeyInfo = C_AuctionHouse.GetItemKeyInfo(itemKey)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["NewResults"] = XrystalUI_Auctioneer_Info["NewResults"] or {}
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"] = {}
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Key = itemKey
XrystalUI_Auctioneer_Info["NewResults"]["itemKey"].Info = itemKeyInfo
-- Request more details about this item's auctions
local sorts = { sortOrder = Enum.AuctionHouseSortOrder.Price, reverseSort = false }
local separateOwnerItems = true
C_AuctionHouse.SendSearchQuery(itemKey, sorts, separateOwnerItems)
end
elseif event == "ITEM_SEARCH_RESULTS_UPDATED" then
local itemKey, auctionID = ...
local itemID = itemKey.itemID
if itemKey then
-- Get the number of auctions for this itemKey
local numResults = C_AuctionHouse.GetNumItemSearchResults(itemKey)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["ItemSearchResults"] = XrystalUI_Auctioneer_Info["ItemSearchResults"] or {}
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID] = {}
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].itemKey = itemKey
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].auctionID = auctionID
XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions = {}
-- Get the auction entries for this item
for index = 1, numResults do
local result = C_AuctionHouse.GetItemSearchResultInfo(itemKey, index)
-- Add this entry to our list of auctions
table.insert(XrystalUI_Auctioneer_Info["ItemSearchResults"][itemID].Auctions,result)
end
end
elseif event == "COMMODITY_SEARCH_RESULTS_UPDATED" then
local itemID = ...
if itemID then
-- Get the number of auctions for this commodity item
local numResults = C_AuctionHouse.GetNumCommoditySearchResults(itemID)
-- Store for later retrieval
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] = XrystalUI_Auctioneer_Info["CommoditiesSearchResults"] or {}
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID] = {}
XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions = {}
-- Get the auction entries for this commodity
for index = 1,numResults do
local result = C_AuctionHouse.GetCommoditySearchResultInfo(itemID, index)
table.insert(XrystalUI_Auctioneer_Info["CommoditiesSearchResults"][itemID].Auctions,result)
end
end
end
end
local f = CreateFrame("Frame")
f:RegisterEvent("AUCTION_HOUSE_SHOW")
f:RegisterEvent("AUCTION_HOUSE_BROWSE_RESULTS_UPDATED")
f:RegisterEvent("AUCTION_HOUSE_NEW_RESULTS_RECEIVED") -- [itemKey]
f:RegisterEvent("ITEM_SEARCH_RESULTS_UPDATED")
f:RegisterEvent("COMMODITY_SEARCH_RESULTS_UPDATED")
f:SetScript("OnEvent", OnEvent)
Hopefully this will help lead you to identifying what you need to do to make your addon work as close to its original design as possible. Printing out the results are as simple as accessing the relevant part of the table returned.