Bulk pricing with batch jobs
You have a spreadsheet of 3,000 items and want a sold median for each. Sending 3,000 calls yourself means pacing them under your plan’s speed and handling retries. A batch job takes 100 keywords in one call and runs them for you; this guide chains jobs to price a list of any size and writes one CSV.
Plan the run
| Items | Jobs | Requests used |
|---|---|---|
| 100 | 1 | up to 100 |
| 1,000 | 10 | up to 1,000 |
| 3,000 | 30 | up to 3,000 |
A keyword uses one request only when it succeeds. Check GET /account/usage first: a job is refused up front, with
nothing counted, when you have fewer requests left than keywords in it. One job runs at a time per account.
Step 1: clean keywords
Good keywords make good medians: brand, model, size or edition, and condition words only when they matter. Drop your internal SKU codes and words like “great deal”. Two items with the same keyword cost twice: deduplicate first.
import csv
with open("inventory.csv") as f:
items = [row for row in csv.DictReader(f)]
keywords = list(dict.fromkeys(row["keyword"].strip() for row in items if row["keyword"].strip()))
print(len(items), "items,", len(keywords), "unique keywords")Step 2: run jobs one after another
import time, requests
API = "https://api.sellercomps.com"
HEADERS = {"Authorization": "Bearer YOUR_API_KEY"}
OPTIONS = {"clean": True, "itemCondition": "used", "bestOfferPrice": True}
def run_job(chunk):
while True:
r = requests.post(f"{API}/scrape/batch", json={"keywords": chunk, **OPTIONS}, headers=HEADERS, timeout=30)
if r.status_code == 409: # a job is still running
time.sleep(15)
continue
if r.status_code == 429:
time.sleep(int(r.headers.get("Retry-After", 10)))
continue
r.raise_for_status()
job_id = r.json()["jobId"]
break
while True:
data = requests.get(f"{API}/scrape/batch/{job_id}", headers=HEADERS, timeout=30).json()
if data["status"] == "complete":
return data
time.sleep(10)
results = {}
for i in range(0, len(keywords), 100):
job = run_job(keywords[i:i + 100])
for k in job["results"]:
results[k["keyword"]] = k
print(f"{min(i + 100, len(keywords))}/{len(keywords)} done, {job['failed']} failed in this job")Step 3: retry the failures for free
Keywords that failed were not counted. Collect them and run them again in one more job:
failed = [k for k, v in results.items() if v["status"] == "failed"]
if failed:
for i in range(0, len(failed), 100):
job = run_job(failed[i:i + 100])
for k in job["results"]:
results[k["keyword"]] = kA keyword that fails twice is worth a look: an unusual spelling, or a page past the last one.
Step 4: summarize and export
import statistics
with open("priced.csv", "w", newline="") as f:
w = csv.writer(f)
w.writerow(["keyword", "sales", "median", "low", "high"])
for kw in keywords:
rows = results.get(kw, {}).get("results", [])
prices = [float(s.get("acceptedOfferPrice") or s["soldPrice"]) for s in rows]
if prices:
w.writerow([kw, len(prices), statistics.median(prices), min(prices), max(prices)])
else:
w.writerow([kw, 0, "", "", ""])Prefer every individual sale? Each finished job has downloadUrl: one CSV with every sale and a keyword column, free
to download.
Make it nightly
- Store the medians with the date and compare night to night to spot moves.
- Price only what changed: new items, and items whose last price is older than a week.
- Add
soldAfter(for example 30 days ago) so medians follow the current market.
Other marketplaces
Batch jobs search eBay. For other marketplaces, send GET /sold?source=... calls from a small pool of workers, at or
under your plan’s speed: see rate limits and
one format for all.
FAQ
How long does a job of 100 take?
Usually a few minutes; keywords run in parallel in the background. Read finished keywords while the rest run.
What happens if my requests run out mid job?
Keywords that cannot be paid are marked failed and not counted. Add extra requests or wait for the new month, then run the failed ones again.
Can I run two jobs at once?
No, one at a time per account. Start the next when the last is complete; the code above waits for you.