---
title: "eBay sold listings API in JavaScript and Node.js"
url: https://www.soldcomps.io/use-cases/ebay-sold-listings-api-javascript
updated: 2026-11-23
answer: "To get eBay sold listings in JavaScript, call GET https://www.soldcomps.io/v1/sold with fetch from your server and a Bearer key: it returns up to 200 eBay sales from the last 90 days plus the median, p25 and p75, at 20 credits per search + 1 per sale returned, with 2,000 free credits a month; keep the key server-side."
publisher: SoldComps.io (https://www.soldcomps.io)
---

# eBay sold listings API in JavaScript and Node.js

> To get eBay sold listings in JavaScript, call GET https://www.soldcomps.io/v1/sold with fetch from your server and a Bearer key: it returns up to 200 eBay sales from the last 90 days plus the median, p25 and p75, at 20 credits per search + 1 per sale returned, with 2,000 free credits a month; keep the key server-side.

**Node.js 18+: sold listings with retries**

```javascript
// 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]));
```

**Next step:** [Get a free API key](https://www.soldcomps.io/signup?ref=use-case-ebay-sold-listings-api-javascript)

## 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

1. **Get a key.** Free at /signup, no card. Store it as SOLDCOMPS_KEY in your server environment.
2. **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.
3. **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.
4. **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.
5. **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 (p25 to p75) | Clean sales | Left out | Auction share | Sales from |
|---|---|---|---|---|---|---|---|
| [PlayStation 5 (disc)](https://www.soldcomps.io/comps/ps5-disc) | used | $475.00 | $449.99 to $519.99 | 40 | 4 | 5% | Nov 11, 2026 to Nov 12, 2026 |
| [Steam Deck OLED 512GB](https://www.soldcomps.io/comps/steam-deck-oled) | used | $600.00 | $590.00 to $629.99 | 41 | 3 | 15% | Nov 9, 2026 to Nov 12, 2026 |
| [AirPods Pro (2nd gen)](https://www.soldcomps.io/comps/airpods-pro-2) | 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)](https://www.soldcomps.io/comps/nike-dunk-low-panda-10) | new | $65.00 | $53.98 to $79.64 | 35 | 1 | 6% | Aug 16, 2026 to Nov 11, 2026 |
| [NVIDIA RTX 3080](https://www.soldcomps.io/comps/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: SoldComps.io eBay Sold Comps Index (https://www.soldcomps.io/comps), eBay US sold listings, snapshot 2026-11-13. Prices exclude shipping.

## 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

```bash
curl "https://www.soldcomps.io/v1/sold?q=rolex+submariner&condition=used" \
  -H "Authorization: Bearer sh_live_xxxxxxxx"
```

```javascript
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();
```

```python
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"])
```

MCP (no code): add https://www.soldcomps.io/mcp to Claude, ChatGPT or Cursor. Full reference: https://www.soldcomps.io/docs.md

## 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](https://www.soldcomps.io/docs)
- [Python version](https://www.soldcomps.io/use-cases/ebay-sold-listings-api-python)
- [Price suggestions for a marketplace app](https://www.soldcomps.io/use-cases/marketplace-price-suggestions)
- [MCP server for AI agents](https://www.soldcomps.io/mcp-server)
- [Developer integration overview](https://www.soldcomps.io/use-cases/developer-integration)
- [Pricing](https://www.soldcomps.io/pricing)

SoldComps.io sells an eBay sold comps API, so we have a commercial interest here. Corrections: hello@soldcomps.io
