Skip to content
This repository was archived by the owner on Dec 1, 2026. It is now read-only.

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

eBay Sold Comps Intelligence

eBay Sold Comps, Sell-Through & Buyback Pricing

Sold-listing valuation math for resellers and AI agents: landed price, purity-gated medians, 90-day sell-through, and a target-ROI max-buy ceiling — async HTTP by default, headless Chrome on request (fetchEngine).

Apify Actor: https://apify.com/mycelia/ebay-sold-comps-intelligence · Apify ID: iqIo5DcNhy0sBSUZs

For $2.00 / 1,000 sold comps parsed, and a query eBay blocks costs $0.


What it returns

Field What you get
total_landed_price sold_price + shipping_price — a "free shipping" listing and a $12.50 shipping listing stop being the same number
comp_purity 5 gates: clean_comp, accessory_or_box_only, parts_or_broken, lot_bundle, variation_price_range, best_offer_hidden_price. Query-aware: searching "Switch OLED empty box" keeps box rows as clean comps
is_iqr_outlier Tukey 1.5×IQR fences applied before the quartiles, so one $1,150 lot can't carry your median
landed_price_p10 / p25 / median / p75 / p90 Computed on clean inliers only, in the marketplace's currency
active_supply_count, sell_through_90d_pct, liquidity_grade Parallel active-listing fetch (LH_Sold=0) → sold ÷ (sold + active), graded A_HIGH → D_SLOW
est_net_payout_after_fees, recommended_max_buy_price Median minus feeRatePct (default 13.25% + $0.40), divided by your targetRoiPct (default 25%)
sold_date_iso Parsed from the sold badge across locales (en/de/fr/it/es/nl), giving the real observed_window_days

10 marketplaces: EBAY_US, UK, DE, CA, AU, FR, IT, ES, NL, IE.

Why it is built this way

Raw sold-com scrapers dump noisy rows. A $18 empty box, a $9.99–$299 variation, and a $120 for-parts unit all pollute a naive median — typically dragging it 15–40%. This Actor classifies each row before the math, removes IQR outliers, and only then reports quartiles, so the number you quote is the number you can actually repeat.

Money rounding is explicit ROUND_HALF_UP (src/ebay_comps.py::_round_money), because Python's round(216.475, 2) is 216.47 and a half-cent in a buyback ceiling is a decision, not a rounding error.

Measured status — read before the first run

  • 21 offline tests, deterministic. The parser contract is pinned by tests/fixtures/ebay_sold_search_sample_us.html (modern s-card sold DOM) and tests/fixtures/ebay_sch_403_errorpage_live_2026-12-01.html — a real response captured from a cloud run, not a hand-written mock.
  • Where eBay blocks us, measured precisely. 403 "Error Page | eBay" (Akamai reference-id, ~1.9 KB) is returned to every /sch/ path and every URL carrying LH_Sold=1. From the same session and IP, https://www.ebay.com/ returns 200 (400 KB of real s-card markup) and /itm/... returns a served 404 — so the rule is endpoint-specific (search listings + the completed/sold filter), not "all of eBay".
  • What has already been ruled out, with measurements. Egress: the free proxy pool (datacenter AS49532/AS264850/AS36352), a Thai ISP exit, and US residential (AS7922 Comcast, Frontier, AS11426 Charter). Residential is not the unlock: from it / returns 200 and /sch/ still returns the same 403. Profiles: Chrome and Firefox fail identically. Cookies: the same-session warm-up fetches / with 200 first, so the search request carries fresh first-party cookies anyway. Also ruled out: HTTP/1.1 vs HTTP/2, m.ebay.com, &_rss=1, /sch/ebay.ajax. The 403 page ships an Akamai bot-sensor script - it expects JavaScript.
  • A real browser is shipped, and it is not the unlock either. fetchEngine: "browser" runs headless Chrome (branded chrome first) on Apify; on verified US residential it launched chrome@158.0.8127.88 and /sch/i.html?...LH_Sold=1... still returned 403 - the same 1,899 B error page, no s-item/s-card, 0 rows, $0 charged (run QQSuhHXqgCNnJ1TMm). The active-listings URL is 403 from Apify residential too, while a genuine consumer residential exit serves it as 200: /sch/ is egress-reputation-dependent as well as endpoint-specific.
  • Proxy keys. Apify honours apifyProxyGroups / apifyProxyCountry only; proxyCountries, groups and friends are silently ignored and hand back the datacenter pool with no error. Residential is accepted on the free tier (billed per GB). The Actor keeps the free pool as its default so you are not billed bandwidth for a 0-row result, and maxFetchProfiles caps how many profiles a run tries (2 on residential).
  • Error vocabulary you will actually see: blocked_by_challenge, blocked_<profile> (e.g. blocked_chrome), blocked_browser_chrome / blocked_browser_chromium (browser engine, and SUMMARY.browser_launches records which browser actually ran) or signin_wall_redirect. Only the last one means eBay asked for a signed-in session - then pass the optional sessionCookie input. It has been observed once, from a local branded-Chrome fetch of the sold URL (https://signin.ebay.com/ws/eBayISAPI.dll?SignIn...&sgfl=srch); it parses as 0 rows, never as data.
  • No eBay API for sold data. The Finding API - findCompletedItems, the only sold-items call - was decommissioned on 2025-02-05 (https://developer.ebay.com/devzone/finding/callref/findCompletedItems.html); Browse returns active listings only, and Marketplace Insights is eligibility-restricted.
  • Shipped behaviour today: a live query returns SUCCEEDED in ~8.6 s with blocked_by_challenge: true (http engine) or blocked_browser_chrome (fetchEngine: "browser", ~37 s), 0 rows and $0 charged. That is an upstream bot-management property, not a parser bug - the 403 body contains no s-card markup, so nothing can be invented from it, which is precisely what the fixture test asserts.

Quick start

One click, input pre-filled — published example Tasks (append .md to any URL for the machine-readable rendition):

Use case Task page
Sold comps + max buyback ceiling https://apify.com/mycelia/ebay-sold-comps-intelligence/examples/ebay-sold-comps-and-max-buyback-price-calculator
Sell-through rate & price bands https://apify.com/mycelia/ebay-sold-comps-intelligence/examples/used-electronics-sell-through-rate-and-price-bands
Clean sold comps for collectibles & TCG https://apify.com/mycelia/ebay-sold-comps-intelligence/examples/collectibles-and-tcg-clean-ebay-sold-comps
apify call mycelia/ebay-sold-comps-intelligence -i '{"queries":["Nintendo Switch OLED Console"],"condition":"USED","onlyCleanComps":true}'
from apify_client import ApifyClient

client = ApifyClient("APIFY_API_TOKEN")
run = client.actor("mycelia/ebay-sold-comps-intelligence").call(
    run_input={"queries": ["Sony WH-1000XM5"], "targetRoiPct": 30}
)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["title"], row["total_landed_price"], row["comp_purity"])
summaries = client.key_value_store(run["defaultKeyValueStoreId"]).get_record("VALUATION_SUMMARIES")["value"]

Use it from an AI agent (MCP)

{
  "mcpServers": {
    "apify": { "type": "http", "url": "https://mcp.apify.com/?tools=mycelia/ebay-sold-comps-intelligence" }
  }
}

Billing that fails safe

  • sold-comp-item = $0.002 per emitted row ($2.00/1,000); apify-actor-start = $0.00005.
  • Push-before-charge: Actor.push_data(row) runs before Actor.charge(...).
  • Blocked or failed queries are never billed; SUMMARY.charged_events == items_pushed.
  • onlyCleanComps: true drops purity-flagged rows before the dataset write and before billing.

Debugging a failure without redeploying

debugSaveRawHtml: true writes every fetched catalog page into the run's key-value store as RAW_HTML_00_0_sold_p1 / RAW_HTML_00_1_active_p1 (status, interstitial flag, body). This is how the live 403 above was captured, and how you can tell "eBay blocked me" from "the parser broke".

Running the tests

python -m pip install -r requirements.txt
python -m unittest discover -s tests -p "test_*.py"   # 10 tests, offline

Covers money parsing across US/EU formats, the 5 purity gates, IQR + valuation math, currency rounding, URL builders for all locales, interstitial detection, the modern s-card DOM, and the real captured 403 response.

License

MIT © 2026 Mycelia

Machine-readable summary for AI agents: llms.txt.

Releases

Packages

Contributors

Languages