WoWInterface (
-   Lua/XML Help (
-   -   Auction house : get specific item price (

Opertune 10-01-20 03:39 PM

Auction house : get specific item price
Hello everyone, i'm new developer and i would like to create an addon who show specific item price when i click on a button (item set in code and no with in game auction house research).

Currently i can create frame and button when i open auction house but i don't know how work auction house api (C_AuctionHouse.GetReplicateItemInfo or C_AuctionHouse.GetCommoditySearchResultInfo).

I try with Xrystal code : but nothing really gets done.

My currently code :


local UIConfig = CreateFrame("Frame", "OpertuneAH", UIParent, "BasicFrameTemplateWithInset");

UIConfig:RegisterEvent("AUCTION_HOUSE_SHOW") -- Event when auction house is opened
UIConfig:RegisterEvent("AUCTION_HOUSE_CLOSED") -- Event when auction house is closed

UIConfig:SetSize(600, 535) -- Window size
                if event == "AUCTION_HOUSE_SHOW" then -- If auction house is opened we create frame
                        -- Frame Settings
                        UIConfig:SetPoint("CENTER", UIParent, "CENTER", 200, 155) -- Position
                        UIConfig:SetMovable(true) -- Drag and drop option's
                        UIConfig:EnableMouse(true) -- Drag and drop option's
                        UIConfig:RegisterForDrag("LeftButton") -- Drag and drop option's
                        UIConfig:SetScript("OnDragStart", UIConfig.StartMoving) -- Drag and drop option's
                        UIConfig:SetScript("OnDragStop", UIConfig.StopMovingOrSizing) -- Drag and drop option's
                        -- Show Frame
                if event == "AUCTION_HOUSE_CLOSED" then -- If auction house is closed we close the frame
                        UIConfig:Hide() -- Hide Frame
                        UIConfig.text:SetText("") -- Reset text area

-- Child frames and regions
-- Frame title
UIConfig.title = UIConfig:CreateFontString(nil, "OVERLAY")
UIConfig.title:SetPoint("LEFT", UIConfig.TitleBg, "LEFT", 5, 0)

-- Scan button
UIConfig.scanButton = CreateFrame("Button", nil, UIConfig, "GameMenuButtonTemplate")
UIConfig.scanButton:SetPoint("TOPLEFT", UIConfig, "TOPLEFT", 10, -28)
UIConfig.scanButton:SetSize(90, 25)
UIConfig.scanButton:SetNormalFontObject("GameFontNormalLarge") -- Text Color
UIConfig.scanButton:SetHighlightFontObject("GameFontHighlightLarge") -- Text Color

-- Event click button scan
        UIConfig.text:SetText("Hello World")

-- Label text
UIConfig.text = UIConfig:CreateFontString(nil, "TEST")
UIConfig.text:SetPoint("CENTER", UIConfig, "CENTER", 0, 0)

Ketho 10-02-20 01:35 PM

I don't know why my posts keep getting ignored.

Did you try to work with the example I posted in that thread and

Opertune 10-03-20 07:37 PM

Ohhhh my bad, i see your post but i missed

and ItemMaxin api.
I try with that but i'm on the right way. Thank you for your answer.

Opertune 10-09-20 06:32 PM

Okay, i have an another problem, i can print information's from my specific item but when i want to print minimum buyout price (after gold conversion and after retrieve the minimum value in my table) my function return a random value.

Auction house price :

When i print all price and min price :

On the screen he return the second price but with other item he return other price.
After many research i've tried differents ways but i have always the same result.

My functions :


local auctions = {}
local allPrice = {}
local initialQuery
local silverPrice, goldPrice, min

UIConfig.scanButton:SetScript("OnClick",function(self, button, down)
    if initialQuery then
        initialQuery = false

function ScanAuctions()
    local continuables = {}

    for i = 0, C_AuctionHouse.GetNumReplicateItems() - 1 do
        auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
        local item = Item:CreateFromItemID(auctions[i][17])
        continuables[item] = true

            auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
            continuables[item] = nil


function getLowestPrice()
    for i, _ in pairs(auctions) do
        if auctions[i][17] == 152510 then -- Anchor Weed id
            silverPrice = (auctions[i][10] / auctions[i][3]) -- copper price / count
            goldPrice = (silverPrice / 10000)
            allPrice = {goldPrice}

            min = allPrice[1]
            for j = 1, #allPrice do
                print(allPrice[j]) -- print all price
                if allPrice[j] < min then
                    min = allPrice[j]

    print("Min Price : " .. min) -- print min price

Ketho 10-09-20 11:48 PM


Originally Posted by Opertune (Post 337066)
but when i want to print minimum buyout price (after gold conversion and after retrieve the minimum value in my table) my function return a random value.

I'm guessing it's because you're not waiting for all auction items to get cached, and skip ahead to checking the auctions

Here's another example which prints the lowest price for an item ID right after it's done scanning or when you press the button or run a script
Lua Code:
  1. local initialQuery
  2. local auctions = {}
  3. local f = CreateFrame("Frame", "SomeAddon")
  5. -- you can also press the button or use this script when scanning is done
  6. -- /run print(GetMoneyString(SomeAddon:GetLowestPrice(152510)))
  7. local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
  8. btn:SetPoint("CENTER")
  9. btn:SetSize(120, 40)
  10. btn:SetText("Example")
  11. btn:SetScript("OnClick", function(self, button)
  12.     if next(auctions) then
  13.         f:SomeExample()
  14.     else
  15.         print("No data")
  16.     end
  17. end)
  19. function f:SomeExample()
  20.     local price = self:GetLowestPrice(152510)
  21.     print("Min Price:", GetMoneyString(price))
  22. end
  24. function f:GetLowestPrice(itemID)
  25.     local minPrice = math.huge
  26.     for _, v in pairs(auctions) do
  27.         if v[17] == itemID then
  28.             local unitPrice = v[10] / v[3] -- totalPrice / count
  29.             --print(unitPrice)
  30.             minPrice = min(minPrice, unitPrice)
  31.         end
  32.     end
  33.     if minPrice < math.huge then
  34.         return minPrice
  35.     end
  36. end
  38. function f:ScanAuctions(callback)
  39.     local continuables = {}
  40.     wipe(auctions)
  41.     for i = 0, C_AuctionHouse.GetNumReplicateItems()-1 do
  42.         auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
  43.         local item = Item:CreateFromItemID(auctions[i][17]) -- itemID
  44.         continuables[item] = true
  46.         item:ContinueOnItemLoad(function()
  47.             auctions[i] = {C_AuctionHouse.GetReplicateItemInfo(i)}
  48.             continuables[item] = nil
  49.             if not next(continuables) then
  50.                 print("I'm done scanning")
  51.                 callback()
  52.             end
  53.         end)
  54.     end
  55. end
  57. function f:OnEvent(event)
  58.     if event == "AUCTION_HOUSE_SHOW" then
  59.         C_AuctionHouse.ReplicateItems()
  60.         initialQuery = true
  61.     elseif event == "REPLICATE_ITEM_LIST_UPDATE" then
  62.         if initialQuery then
  63.             self:ScanAuctions(function() self:SomeExample() end)
  64.             initialQuery = false
  65.         end
  66.     end
  67. end
  69. f:RegisterEvent("AUCTION_HOUSE_SHOW")
  70. f:RegisterEvent("REPLICATE_ITEM_LIST_UPDATE")
  71. f:SetScript("OnEvent", f.OnEvent)

Opertune 10-10-20 03:43 PM

Thanks for your help Ketho, i reused a part of your code and now my addon works great. I think i need more practice with lua and wow api but it's pretty cool to create a wow addon.

deres 12-18-20 04:40 PM

awesome code!

Is there any other way besides using C_AuctionHouse.ReplicateItems? The 15 min throttle seems too long for me as prices change quite quickly and the cached value becomes out of date pretty fast.

Or did you manage to use some other API?

Ketho 12-19-20 05:13 PM


Originally Posted by deres (Post 337975)
Is there any other way besides using C_AuctionHouse.ReplicateItems?

I added an example to C_AuctionHouse.SendSearchQuery()

deres 12-19-20 06:17 PM

Awesome, this one looks even better as I'd only need to query max 20 items. Thanks for this one!

The REPLICATE_ITEM_LIST_UPDATE event however acts weirdly for me. sometimes the 15 min throttle is accurate, sometime it just doesn't happen. I even waited several hours (tried reopening the AH) but nothing happened.

Shouldn't it trigger automatically after this 15 min throttle expires?


Ketho 12-19-20 06:42 PM


Originally Posted by deres (Post 337990)
Shouldn't it trigger automatically after this 15 min throttle expires?

You mean that the event should fire automatically after the 15 minutes cooldown expires?
No, it only fires once you call C_AuctionHouse.ReplicateItems() and while it's not throttled

deres 12-20-20 05:09 AM

The C_AuctionHouse.ReplicateItems() is called on the AUCTION_HOUSE_SHOW event like in your code. It worked 2 times in a row, now it seems to be bricked. Interesting. Tried attaching it to a button click, 35 minutes passed but nothing.

I might be throttled for more than 15 min I guess. Anyways the C_AuctionHouse.SendSearchQuery() works perfectly and suits my needs as I don't really need to scan the whole AH!

All times are GMT -6. The time now is 10:53 AM.

vBulletin © 2021, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI