跳到正文
DEV Community· Sam Smith·· 51 分鐘前AI 評分31

Reverb 吉他成交價會低於標價多少?用 Python 分析上架至售出天數

How far below list price do guitars sell? Reverb's days-on-market data, in Python

AI 導讀

CompsAPI 會在 Reverb 成交資料中提供折扣比例及上架至售出的天數,文章用 Python 按在市場上的時間分組,計算各組的折扣及成交價中位數,以比較等待較久是否伴隨更大折扣。程式會略過缺少所需欄位的資料;作者只用模擬伺服器測試分組邏輯,未以實際 API key 執行。

正文

Sam Smith

Disclosure: we build CompsAPI, the sold-price API used in this post. It was drafted with AI assistance, and the fields below come from CompsAPI's documentation. A free key needs no card.

A sold price tells you what an item went for. It does not tell you how far the seller dropped from the asking price, or how long it sat before someone bought it. On Reverb, CompsAPI returns both on every sale: signals.discount_pct (percent under the list price it sold for) and signals.days_on_market (days from listing to sale).

This post builds a short Python script that groups Reverb sales by time on market and prints the median discount and median price for each group. It answers a question a median price cannot: does waiting longer mean a bigger discount?

The two fields

Each marketplace row can carry a signals object, under the same names on every source that has them:

"signals": {
  "days_on_market": 18.8,
  "discount_pct": 14.1,
  "listed_date": "2026-10-29T19:08:13Z"
}

The object is only present where the marketplace provides these values, and each field can be missing from a row. Reverb provides list price, discount and days on market, and its sold history goes back to 2014. The script has to skip rows without them.

The script

import os
import statistics
import sys

import requests

BASE = os.environ.get("COMPSAPI_BASE", "https://api.compsapi.com")
QUERY = " ".join(sys.argv[1:])
BUCKETS = [
    ("under 1 week", 0, 7),
    ("1 to 4 weeks", 7, 30),
    ("1 to 3 months", 30, 90),
    ("over 3 months", 90, float("inf")),
]


def reverb_sales(query):
    resp = requests.get(
        f"{BASE}/v1/sold",
        params={"source": "reverb", "q": query, "exclude": "ai_junk"},
        headers={"X-API-Key": os.environ["COMPSAPI_KEY"]},
        timeout=30,
    )
    resp.raise_for_status()
    return resp.json().get("items", [])


def usable(rows):
    # signals only appears where the marketplace has them, and each field can be missing
    out = []
    for row in rows:
        sig = row.get("signals") or {}
        if row.get("price") is None:
            continue
        if sig.get("days_on_market") is None or sig.get("discount_pct") is None:
            continue
        out.append((sig["days_on_market"], sig["discount_pct"], row["price"]))
    return out


if not QUERY:
    sys.exit('usage: python signals.py "item name"')

rows = reverb_sales(QUERY)
data = usable(rows)
print(f"{len(rows)} sales returned, {len(data)} with both days on market and discount")
if not data:
    sys.exit("nothing to measure")

print(
    f"all: median discount {statistics.median(d for _, d, _ in data):.1f}%, "
    f"median {statistics.median(t for t, _, _ in data):.0f} days to sell"
)
print(f"{'time on market':<15}{'sales':>6}{'median discount':>17}{'median price':>14}")
for label, lo, hi in BUCKETS:
    group = [(d, p) for t, d, p in data if lo <= t < hi]
    if not group:
        print(f"{label:<15}{0:>6}")
        continue
    print(
        f"{label:<15}{len(group):>6}"
        f"{statistics.median(d for d, _ in group):>16.1f}%"
        f"{'$' + format(statistics.median(p for _, p in group), ',.0f'):>14}"
    )

Run it with any search:

python signals.py "fender stratocaster"

The first line says how many sales came back and how many had both signals. The second gives the overall median discount and median days to sell. The table then splits the sales into four time-on-market groups.

How to read the table

  1. Check the sales column before the discount column. A group of 3 sales is an anecdote. Ignore its median.
  2. Compare discount across groups, not within one. If the 3-month group sells at a deeper discount than the one-week group, sellers who wait are eventually cutting. If the discounts are similar, waiting did not change the price.
  3. Watch the median price column too. A group's price can differ for reasons that have nothing to do with time: the slow sellers may be listing pricier models. Narrow the search (a specific model and finish) before reading anything into it.
  4. Zero discount is a real answer. Many sales close at list price, which pulls the median down towards 0.

Why exclude=ai_junk

Reverb listings include accessories, parts and lots under the instrument's name. The AI filter leaves out sales it labels as junk, so the discounts describe the item and not a pedal that shares its title. In CompsAPI's published example, fender stratocaster reads about $400 without the filter and about $900 with it. It is opt-in and not perfect, so compare both before relying on it.

What it costs

One request per search. On the free plan (100 requests a month, 10 a minute) that is 100 searches.

Limits worth knowing

  • It reads one page of the newest sales. For a popular search, that is a slice of recent history, not the whole year. Pass start and end (YYYY-MM-DD) to read an earlier window.
  • The discount is against the seller's list price, not against a market price. A seller who lists high and cuts 20% may still be above the going rate.
  • Other sources carry the same fields where they have them. Swap source=reverb for another marketplace, and rows that lack signals are skipped. Check that the marketplace provides them before trusting an empty result.
  • I have not run this script against a live key. I ran its grouping logic against a fake local server returning the documented fields (signals.days_on_market, signals.discount_pct, price), and it printed the expected table. The real response may differ. If it reports zero usable rows, print one raw row and check the field names.

CompsAPI is not affiliated with Reverb or any marketplace named.

Try it

A free key is enough to run this on a few searches: get one here. If you find a search where the groups look wrong, tell us in the comments.

來源:DEV Community · dev.to