# Vinted, Reverb, TCGPlayer & Discogs Scraper — Sold Comps (`vesper_studio/reseller-arbitrage-sold-comps`) Actor

Compute real sold market comps (P25, Median, P75, 30d velocity) and live buy/resell arbitrage margins across Vinted, Reverb, TCGPlayer, and Discogs using Chrome TLS & JSON APIs. Built for pro resellers, collectibles shops, Discord/Telegram deal bots, and n8n arbitrage alerts.

- **URL**: https://apify.com/vesper_studio/reseller-arbitrage-sold-comps.md
- **Developed by:** [Xavier Richard](https://apify.com/vesper_studio) (community)
- **Categories:** E-commerce, Business, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.50 / 1,000 marketplace comp or listing delivereds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Reseller Arbitrage & Sold Comps (`reseller-arbitrage-sold-comps`)

Production Apify Actor for resellers, thrift/pawn/record/card shops, collectors, and Discord/Telegram/n8n deal bots to compute **real sold market value** (P25, Median, P75, 30-day velocity) and detect **underpriced active listings** (`spreadPct`, `isUnderpriced`, `estimatedGrossMargin`) across underserved high-arbitrage verticals.

Built on **Python 3.12**, **`apify` (~=4.1)**, **`curl_cffi`** (Chrome TLS/HTTP2 impersonation), **`selectolax`** (`LexborHTMLParser`), **`pydantic` v2**, and Python **`statistics`**. Target memory: **256–512 MB**, **proxy-free by default**.

***

### Verified Marketplaces (Live HTTP/TLS Verification)

Every marketplace endpoint was tested live with `curl_cffi` before implementation:

| Marketplace | Status (No Proxy) | Data Source | Sold Comps | Active Asks | Auth / Proxy Notes |
| :--- | :--- | :--- | :---: | :---: | :--- |
| **Reverb** | `200 HAL+JSON` | `api.reverb.com/api/listings/all?show_only_sold=true` & `/api/listings` | ✅ Individual sales | ✅ Live asks | No proxy or API key required |
| **TCGPlayer** | `200 JSON` | `mp-search-api.tcgplayer.com` + `mpapi.tcgplayer.com/v2/product/{id}/latestsales` | ✅ Individual sales | ✅ Standard asks | No proxy or API key required |
| **Discogs** | `200 JSON` + `200 HTML` | `api.discogs.com` (`/database/search`, `/releases/{id}`, `/marketplace/stats/{id}`) + `www.discogs.com/release/{id}-{slug}` | ✅ Release Median + Last Sold date | ✅ Lowest ask | Optional free `discogsToken` increases limit (25 → 60 req/min) & enables `/marketplace/price_suggestions/{id}` fallback |
| **Vinted** | `200 HTML` (SSR Flight JSON) | `www.vinted.{fr,com,co.uk,de,es,it,nl,be}/catalog` (`self.__next_f.push` + DOM fallback) | ❌ Removed on Vinted | ✅ Live asks (96/page) | Great sourcing feed paired with sold anchors; no proxy required |

#### Platforms Explicitly Excluded from Proxy-Free Defaults

- **eBay (`ebay.com`, `.fr`, `.co.uk`, `.de`)**: Tested with `chrome124`, `chrome131`, and `safari17_0` TLS impersonation — returns `403 Error Page` from Akamai Bot Manager (`Server: AkamaiGHost`, `bm_s`/`bm_so` cookies) on datacenter/non-residential connections. Requires residential proxies or official eBay Browse/Marketplace Insights OAuth API.
- **Discogs `/sell/history` & `/sell/list` web routes**: Gated behind Cloudflare JS Challenge (`Just a moment...`). The Actor cleanly uses `api.discogs.com` + `www.discogs.com/release/{id}-{slug}` (`200 OK`) instead.

***

### Architecture & Output

#### 1. Unified Dataset Schema (`ListingComp`)

Every item pushed to the Apify Dataset conforms to:

- `query`, `marketplace` (`reverb` | `tcgplayer` | `discogs` | `vinted`)
- `itemId`, `title`, `condition`, `listingType` (`sold` | `active_ask`)
- `price`, `shippingPrice`, `totalPrice`, `currency` (kept in native listing currency)
- `soldDate` (ISO timestamp/date for `sold`, `null` for `active_ask`)
- `sellerCountry`, `url`, `imageUrl`
- `isUnderpriced` (`bool`), `estimatedGrossMargin` (`float | null` in `targetCurrency`), `discountBelowMedianPct` (`float | null`)

#### 2. Arbitrage Analytics & Relevance Filtering (`KEY_VALUE_STORE / MARKET_SUMMARY`)

For every query, `src/relevance.py` filters out off-topic search hits (`strictQueryMatch: true`) and accessory/parts noise (`excludeAccessories: true` — adapters, knobs, manuals, empty boxes, posters, pins, sleeves, etc. unless present in your query) before `src/analytics.py` normalizes currencies to `targetCurrency` (`USD`, `EUR`, `GBP`, or `CAD`) and stores `MARKET_SUMMARY` in the Default Key-Value Store:

- `soldCount`, `activeCount`, `soldVelocity30d`, `filteredNoiseCount`
- `p25SoldPrice`, `medianSoldPrice`, `p75SoldPrice`
- `minActivePrice`
- `spreadPct`: `((medianSoldPrice - minActivePrice) / medianSoldPrice) * 100`
- `underpricedCount` & top `underpricedDeals`

#### 3. Delta Mode (`onlyNew`) & Discord / n8n Webhook Alerts

- Enable `onlyNew: true` for scheduled cron monitoring (e.g., every 10–15 minutes).
- Seen keys (`marketplace:listingType:itemId`) persist in the named Key-Value Store `reseller-arbitrage-sold-comps-state`.
- **Smart design**: Fresh sold comps are always evaluated to compute an accurate `medianSoldPrice`, while previously seen listings are skipped from dataset delivery, Pay-Per-Event billing, and webhook notifications.
- If `webhookUrl` is set, new `isUnderpriced` active deals are sent automatically:
  - **Discord** (`discord.com/api/webhooks/...`): rich green embeds (chunked 10/message) with ask price, sold median, estimated margin, discount %, condition, and thumbnail.
  - **n8n / Make / Telegram relay**: structured JSON payload (`event: "underpriced_deals_detected"`).

#### 4. Pay-Per-Event Billing

Charges `comp-item` via `Actor.get_charging_manager()` in batches of 25 and enforces `maxTotalChargeUsd` strictly before each batch.

***

### Local Development & Testing

```bash
## Run unit & fixture integration tests
python -m pytest -v

## Run Actor locally with Apify CLI
apify run
```

# Actor input Schema

## `queries` (type: `array`):

One or more product names, card names, vinyl releases, or gear models to price-check and scan for arbitrage opportunities.

## `marketplaces` (type: `array`):

Select which verified proxy-free marketplaces to query. Note: eBay requires residential proxies (Akamai 403 on datacenter IPs) and is intentionally excluded from default proxy-free adapters.

## `includeSold` (type: `boolean`):

Fetch completed/sold transactions to compute P25, Median, P75 market value and 30-day sales velocity.

## `includeActive` (type: `boolean`):

Fetch live active asking listings to compute spreadPct and flag underpriced arbitrage deals.

## `maxSoldPerMarketplace` (type: `integer`):

Maximum number of sold comps to fetch per marketplace for each query.

## `maxActivePerMarketplace` (type: `integer`):

Maximum number of live active listings to fetch per marketplace for each query.

## `targetCurrency` (type: `string`):

Currency used in MARKET_SUMMARY and cross-marketplace gross margin calculations (listings keep their native currency on each item).

## `vintedDomain` (type: `string`):

Vinted country storefront to scan when Vinted is enabled.

## `discogsToken` (type: `string`):

Optional free Discogs developer token (from discogs.com/settings/developers). Increases API rate limit from 25 to 60 req/min and enables per-condition price suggestions fallback.

## `strictQueryMatch` (type: `boolean`):

Filter out off-topic marketplace search results whose title does not contain the core query tokens (normalizes hyphens/spaces like DS-1 vs DS1).

## `excludeAccessories` (type: `boolean`):

Exclude accessories, empty boxes, manuals, power adapters, pins, posters, and 'for parts' listings unless those terms appear in your search query.

## `alertDiscountBelowMedianPct` (type: `number`):

Active listings priced at least this percentage below medianSoldPrice are flagged with isUnderpriced=true and sent to webhookUrl.

## `onlyNew` (type: `boolean`):

Persist seen listing IDs across runs in Key-Value Store and output/alert only brand-new listings not delivered in previous runs. Market summary medians are still computed from fresh sold comps.

## `webhookUrl` (type: `string`):

Optional HTTPS webhook URL. Automatically formats rich Discord embeds for discord.com/api/webhooks/... or sends structured JSON for n8n/Make/bots whenever new underpriced deals are detected.

## `maxItems` (type: `integer`):

Hard cap on total ListingComp records pushed to the dataset (also bounded by Pay-Per-Event maxTotalChargeUsd).

## `proxyConfiguration` (type: `object`):

Disabled by default. All 4 supported marketplaces work proxy-free via Chrome TLS impersonation; enable only if you run high-frequency schedules from a single IP.

## Actor input object example

```json
{
  "queries": [
    "Boss DS-1",
    "Charizard ex 199"
  ],
  "marketplaces": [
    "reverb",
    "tcgplayer"
  ],
  "includeSold": true,
  "includeActive": true,
  "maxSoldPerMarketplace": 40,
  "maxActivePerMarketplace": 40,
  "targetCurrency": "USD",
  "vintedDomain": "fr",
  "strictQueryMatch": true,
  "excludeAccessories": true,
  "alertDiscountBelowMedianPct": 20,
  "onlyNew": false,
  "maxItems": 500,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `comps` (type: `string`):

Unified sold comps and active asking listings across Reverb, TCGPlayer, Discogs, and Vinted with underpriced deal flags and estimated gross margins.

## `marketSummary` (type: `string`):

Per-query soldCount, activeCount, medianSoldPrice, p25SoldPrice, p75SoldPrice, minActivePrice, spreadPct, soldVelocity30d, and top underpriced deals.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "queries": [
        "Boss DS-1",
        "Charizard ex 199"
    ],
    "marketplaces": [
        "reverb",
        "tcgplayer"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("vesper_studio/reseller-arbitrage-sold-comps").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "queries": [
        "Boss DS-1",
        "Charizard ex 199",
    ],
    "marketplaces": [
        "reverb",
        "tcgplayer",
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("vesper_studio/reseller-arbitrage-sold-comps").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "queries": [
    "Boss DS-1",
    "Charizard ex 199"
  ],
  "marketplaces": [
    "reverb",
    "tcgplayer"
  ]
}' |
apify call vesper_studio/reseller-arbitrage-sold-comps --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,vesper_studio/reseller-arbitrage-sold-comps"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/f6XLKV3cSp8eGCGhN/builds/rbG3C2moZPuDT2XMW/openapi.json
