eBay sold listings API in JavaScript and Node.js
// sold.mjs, Node 18+ (built-in fetch). Free key: soldcomps.io/signup
const API = "https://www.soldcomps.io/v1/sold";
export async function sold(q, params = {}) {
const url = new URL(API);
url.search = new URLSearchParams({ q, ...params });
for (let attempt = 0; attempt < 4; attempt++) {
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.SOLDCOMPS_KEY}` } });
if (res.status === 429 || res.status === 502) { // never billed: wait, then retry
const wait = Number(res.headers.get("retry-after")) || 2 ** attempt;
await new Promise((r) => setTimeout(r, wait * 1000));
continue;
}
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);
return body;
}
throw new Error("still rate limited after 4 tries");
}
const { count, stats, items } = await sold("steam deck oled", { condition: "used", limit: "20" });
console.log(`${count} sales, median ${stats.median} ${stats.currency} (p25 ${stats.p25}, p75 ${stats.p75})`);
console.log(items.filter((i) => i.flags.length === 0).map((i) => [i.sold_at, i.sold_price.value]));The job
Listing tools, Chrome extensions, marketplace apps and Next.js sites need sold prices in JavaScript. eBay's Browse API only returns items still for sale, and its sold-data API, Marketplace Insights, isn't open to new developers.
The function above runs anywhere with fetch: a Next.js route handler, Express, a serverless function or a queue worker. Call it from your server, never from the browser, because the key is a secret.
How to do it
- Get a key. Free at /signup, no card. Store it as SOLDCOMPS_KEY in your server environment.
- Call it server-side. From a route handler or API endpoint, call sold(q, params) and return only what the page needs: median, p25, p75 and a few sales.
- Handle errors by code. Every error has error.code and error.message. 429 rate_limited and 502 upstream_unavailable are safe to retry; 402 quota_exceeded means out of credits.
- Cache on your side too. Results for the same search are cached for up to 12 hours on ours; cache them on yours for the same window to cut calls.
- Credit the data. If you show prices publicly, display "Sold data by SoldComps.io" with a link (Terms, section 3).
What five calls returned (eBay US, snapshot Nov 13, 2026)
| Item | Condition | Median | Middle half | Clean sales | Left out | Auctions | Sales from |
|---|---|---|---|---|---|---|---|
| PlayStation 5 (disc) | used | $475.00 | $449.99 to $519.99 | 40 | 4 | 5% | Nov 11, 2026 to Nov 12, 2026 |
| Steam Deck OLED 512GB | used | $600.00 | $590.00 to $629.99 | 41 | 3 | 15% | Nov 9, 2026 to Nov 12, 2026 |
| AirPods Pro (2nd gen) | used | $65.00 | $59.97 to $73.00 | 35 | 8 | 26% | Sep 17, 2026 to Nov 11, 2026 |
| Nike Dunk Low Panda (size 10, new) | new | $65.00 | $53.98 to $79.64 | 35 | 1 | 6% | Aug 16, 2026 to Nov 11, 2026 |
| NVIDIA RTX 3080 | used | $414.97 | $385.00 to $459.99 | 41 | 3 | 5% | Sep 13, 2026 to Nov 12, 2026 |
- Show the range, not just the median. The used Steam Deck OLED 512GB's middle half is $590.00 to $629.99, tight enough for one number; the Nike Dunk Low Panda (size 10, new) runs $53.98 to $79.64 around $65.00, so a single price would mislead.
- Every row came from one call. At limit=20 that's 40 credits per call, and failed calls (4xx, 5xx) cost nothing; each response reports credits.charged and credits.remaining.
Source: the eBay Sold Comps Index, eBay US sold listings, snapshot 2026-11-13. Prices exclude shipping. “Left out” = lots, for-parts units, outliers and hidden Best Offers (methodology).
Cost per call
| limit (sales listed) | Credits per search | Searches on Free (2,000 credits) | Searches on Starter ($5, 50,000 credits) |
|---|---|---|---|
| 1 | 21 | 95 | 2,380 |
| 10 | 30 | 66 | 1,666 |
| 20 | 40 | 50 | 1,250 |
| 50 | 70 | 28 | 714 |
| 200 | 220 | 9 | 227 |
Code
curl "https://www.soldcomps.io/v1/sold?q=rolex+submariner&condition=used" \ -H "Authorization: Bearer sh_live_xxxxxxxx"
const url = new URL("https://www.soldcomps.io/v1/sold");
url.searchParams.set("q", "charizard 4/102 \"psa 9\"");
url.searchParams.set("buying_format", "auction");
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.SOLDCOMPS_KEY}` } });
if (!res.ok) throw new Error(`${res.status} ${(await res.json()).error.code}`);
const { count, stats, items } = await res.json();import requests
r = requests.get(
"https://www.soldcomps.io/v1/sold",
params={"q": "rolex submariner 126610ln", "condition": "used"},
headers={"Authorization": "Bearer sh_live_xxxxxxxx"},
timeout=30,
)
r.raise_for_status()
data = r.json()
print(data["count"], "sales, median", data["stats"]["median"])No code: add the MCP server https://www.soldcomps.io/mcp to Claude, ChatGPT or Cursor (setup). Full reference in the API docs.
When SoldComps.io is not the right tool
- Calling from the browser: the key would be public. Proxy through your server.
- Real-time feeds of every new sale: this is search-based, cached up to 12 hours per query.
- Marketplaces beyond eBay US, UK and Germany: sold-comps.com and Soldgraph cover more.
Frequently asked questions
Can I call it from the browser?
Don't: the key would be visible to anyone. Call it from your server (a Next.js route handler, Express route or serverless function) and send the browser only the numbers.
Is there an npm package?
No package is needed. It's one GET endpoint returning JSON, so the built-in fetch in Node 18+ is enough. There's an OpenAPI spec at /openapi.json if you want to generate types.
Does it work with TypeScript?
Yes. Generate types from /openapi.json, or type the fields you use: count, stats.median, stats.p25, stats.p75 and items[].sold_price.value.
What does a call cost?
20 credits per search plus 1 credit per sale returned: a 50-sale search costs 70, a 200-sale search costs 220, a search with no sales costs 20. Failed calls and usage checks cost nothing.
Related
- API docs
- Python version
- Price suggestions for a marketplace app
- MCP server for AI agents
- Developer integration overview
- Pricing
SoldComps.io sells an eBay sold comps API, so we have a commercial interest here. Corrections: hello@soldcomps.io.