Zum Inhalt springen

WoW Codex

MarketLens Public API v1 – Developer Documentation

The MarketLens Public API provides addon developers with a versioned interface to access Auction House prices, market values, vendor prices and disenchanting data in World of Warcraft Forever. MarketLens also provides a compatibility layer for supported Auctionator pricing functions, allowing existing addons to access MarketLens price data without requiring Auctionator itself. This documentation covers all available API functions, return values, integration examples and update notifications.

MarketLens Public API v1

World of Warcraft: Forever · MarketLens 1.7.15

MarketLens provides a versioned, read-only pricing interface for other addons. It uses MarketLens's existing market data and never starts an Auction House scan as a result of a price request. No Auctionator installation is necessary for the native API.

Integration

Declare MarketLens as an optional dependency in your addon's TOC:

## OptionalDeps: MarketLens

Use MarketLens as a required dependency instead only if your addon cannot function without it. Access the interface at PLAYER_LOGIN or later, or subscribe to price updates during addon initialization. The Scanner module must be enabled and market data must be available for AH prices. A price can be unavailable before the initial login is complete or before the first scan.

local ml = MarketLensAPI and MarketLensAPI.v1
if ml then
    local price = ml.GetAuctionPrice(10940)
    if price then
        -- Copper per unit.
    end
end

The item argument accepts a positive integer item ID, an item string such as item:10940, or a complete item hyperlink. Supply a hyperlink where item variants matter. The API uses MarketLens's existing item-resolution rules, which may fall back to an item-ID match; check resolution and matchedKey in the price information when variant precision is important.

Functions

All monetary values are in copper, per item unless otherwise stated. Missing data returns nil, never a fabricated zero AH price. Vendor prices may legitimately be zero. Functions use dot notation, not colon notation.

Function Returns
GetAPIVersion() 1
GetAddonVersion() Addon version string
GetAuctionPrice(item) Last observed minimum unit buyout, or nil
GetMarketValue(item, metric) MarketLens reference price and actual metric used, or nil
GetPriceAge(item) Seconds since the minimum buyout was observed, or nil
GetPriceInfo(item) Independent table with price and observation metadata, or nil
GetVendorPrice(item) Blizzard NPC sell price, or nil if item data is unavailable
GetDisenchantResults(item) Independent array of possible material outcomes, or nil
GetDisenchantValue(item, metric) Expected gross material value for one item, or nil
RegisterForPriceUpdates(callback) true for a valid callback; otherwise false
UnregisterForPriceUpdates(callback) Removes the specified callback

Market value metrics: current, smart, 24h, 7d, 30d. Omitting the metric uses the user's preferred MarketLens reference. Unavailable metrics fall back through MarketLens's existing rules; the second return value identifies the actual metric used. Forever currently relies on local Scanner data; not all historical metrics are available.

GetDisenchantValue also accepts minBuyout explicitly. It weights each possible outcome by its probability and average quantity. It returns nil if any required material price is unavailable. It is an estimate before AH fees and does not incorporate acquisition costs or player skill restrictions. GetDisenchantResults returns rows with itemId, probability (0–100), minQuantity, and maxQuantity.

Price information

local info = ml.GetPriceInfo(10940)
if info and info.minBuyout then
    print(info.minBuyout, info.ageSeconds, info.lastKnown)
end
Field Meaning
itemID, exactKey Requested item identity
matchedKey Market record used by the provider
minBuyout, marketValue Unit price and selected reference price
marketValueType Actual reference metric
updatedAt, ageSeconds Observation Unix timestamp and age in seconds
quantity, auctionCount Quantity and auction count at the last snapshot; absent for archived observations
lastKnown true if the observation is archived rather than current snapshot data
source, resolution Provider name and matching method

Fields may be absent when information is unavailable. A snapshot is not a live price guarantee. Archived observations may be retained indefinitely; consumers should apply their own maximum price age. resolution describes matching (e.g. auction-key, item-id-summary, item-id-unique, item-id-material), not a promise of variant identity.

Update notifications

local function OnPriceUpdate(source, updatedAt)
    -- Refresh your own cached values/UI as appropriate.
end
ml.RegisterForPriceUpdates(OnPriceUpdate)
-- Later, when no longer needed:
ml.UnregisterForPriceUpdates(OnPriceUpdate)

Callbacks receive (source, updatedAt). The initial notification is initial with no timestamp after login; scanner indicates a committed scan; market-reference and fee setting changes may also produce notifications (market-value-setting, fee-setting). Callbacks are deduplicated by function identity and isolated from each other's errors. Do not run full database scans or expensive UI updates inside callbacks.

Auctionator price API compatibility

When Auctionator is not enabled and no Auctionator global is already present, MarketLens exposes the following subset under Auctionator.API.v1 (default enabled, configurable in MarketLens → Compatibility; a reload is required):

  • GetAuctionPriceByItemID(callerID, itemID)
  • GetAuctionPriceByItemLink(callerID, itemLink)
  • GetAuctionAgeByItemID(callerID, itemID)
  • GetAuctionAgeByItemLink(callerID, itemLink)
  • GetVendorPriceByItemID(callerID, itemID)
  • GetVendorPriceByItemLink(callerID, itemLink)
  • GetDisenchantPriceByItemID(callerID, itemID)
  • GetDisenchantPriceByItemLink(callerID, itemLink)
  • RegisterForDBUpdate(callerID, callback)

The caller ID must be a non-empty string. AH prices are last observed minimum unit buyouts; age is measured in completed days. Disenchant values use minimum buyout estimates. MarketLens retention and matching may differ from Auctionator. The DB update callback is called without arguments after initial login and committed scans.

The bridge does not supply Auctionator's internal database, search, UI, exactness checks, addon metadata, or other functions. Addons with a hard Auctionator dependency, explicit installed/loaded checks, unsupported API calls, or early load-time detection may require changes. The bridge is installed at MarketLens's ADDON_LOADED event (with login fallback); native integrations should use the optional dependency above. The real Auctionator takes priority if enabled or already loaded. The bridge is not a solution for running competing AH interfaces simultaneously.

Integration verification

  1. Enable MarketLens and its Scanner module; disable Auctionator; reload.
  2. Run /mlf api to inspect compatibility status.
  3. After a scan, compare the following output with the MarketLens minimum buyout tooltip:
/run print(MarketLensAPI.v1.GetAuctionPrice(10940), Auctionator.API.v1.GetAuctionPriceByItemID("Test",10940))
  1. Enable Auctionator and reload; verify the original Auctionator API is used and MarketLens's native API remains available.
  2. Use /mlf api off followed by /reload to disable the bridge. Use /mlf api on and reload to re-enable it.

New integrations should prefer the native MarketLens API. The MarketLensAPI.v1 namespace is the public contract; other members of MarketLensAPI are internal interfaces and are not covered by this versioned contract.