Look up eBay prices by ISBN, UPC or EAN in Python
In this tutorial you will build a barcode lookup for book and media resellers. For each ISBN, UPC or EAN it finds the eBay listings for that product. It prints the number of listings, the cheapest price with shipping and its condition, and the median price, then saves everything to a CSV. It uses the eBay Data API and about 45 lines of Python.
What you need: Python 3.8+, pip install requests, and a free RapidAPI key.
1. Subscribe to the free plan
- Open the eBay Data API on RapidAPI and subscribe to the free Basic plan (20 requests a month).
- Copy your
X-RapidAPI-Keyand export it:
export RAPIDAPI_KEY=your_key
2. A small helper to call the API
The helper sends your key, retries rate limits (HTTP 429) and server errors (5xx) with a growing wait, and stops with the API’s error message on anything else.
"""Look up books and products on eBay by ISBN, UPC or EAN and find the best price.
Uses the eBay Data API on RapidAPI:
https://rapidapi.com/apiwren-apiwren-default/api/ebay-data-api-search-item-details-seller
"""
import csv, os, sys, time
from statistics import median
import requests
HOST = "ebay-data-api-search-item-details-seller.p.rapidapi.com"
HEADERS = {"X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"], "X-RapidAPI-Host": HOST}
def get(path, **params):
"""GET one endpoint. Retries rate limits (429) and server errors (5xx)."""
for attempt in range(4):
r = requests.get(f"https://{HOST}{path}", headers=HEADERS, params=params, timeout=90)
retry = r.status_code == 429 or r.status_code in range(500, 600)
if retry and attempt != 3:
time.sleep(float(r.headers.get("Retry-After") or 2 ** (attempt + 1)))
continue
if not r.ok:
sys.exit(f"HTTP {r.status_code}: {r.text[:300]}")
body = r.json()
if isinstance(body, dict) and body.get("success") is False:
sys.exit(f"API error: {body.get('error')}")
return body
3. Look up a code
/product-lookup takes a code (UPC, EAN or ISBN) and returns total_results and items with price, shipping and condition. We add a landed price and sort by it.
def lookup(code, country="US"):
data = get("/product-lookup", code=code, country=country)["data"]
items = [i for i in data["items"] if i["price"]]
for i in items:
i["landed"] = round(i["price"] + (i["shipping"] or 0), 2)
return data["total_results"], sorted(items, key=lambda i: i["landed"])
4. Print and save
def main(codes, out="ebay_barcodes.csv"):
with open(out, "w", newline="") as f:
w = csv.writer(f)
w.writerow(["code", "listings", "cheapest", "median", "condition", "title", "url"])
for code in codes:
total, items = lookup(code)
if not items:
print(f"{code}: no listings")
continue
low, mid = items[0], median(i["landed"] for i in items)
print(f"{code}: {total} listings cheapest {low['landed']:.2f} ({low['condition']}) "
f"median {mid:.2f} {low['title'][:45]}")
w.writerow([code, total, low["landed"], mid, low["condition"], low["title"], low["url"]])
print(f"saved {out}")
if __name__ == "__main__":
main(sys.argv[1:] or ["9780735211292", "9780593135204", "045496596439"])
5. Run it
python ebay_barcode_lookup.py 9780735211292 9780593135204 045496596439
Real output from a run on 2026-11-28:
9780735211292: 513 listings cheapest 6.12 (Pre-Owned) median 11.94 Atomic Habits James Clear Hardcover Dust Jack
9780593135204: 77 listings cheapest 13.64 (Pre-Owned) median 40.11 Project Hail Mary: A Novel
045496596439: 466 listings cheapest 25.98 (New (Other)) median 40.68 Animal Crossing: New Horizons - Nintendo Swit
saved ebay_barcodes.csv
The complete script is in examples/ebay_barcode_lookup.py.
Tips
- Scan barcodes with a phone app that exports to text, then pass the file:
python ebay_barcode_lookup.py $(cat codes.txt). - Matches are eBay’s own search results for the code, so check titles on low prices.
- Each code costs one request.
Next steps
- eBay Data API on RapidAPI: all endpoints, plans and the live playground.
- eBay Data API overview and more tutorials.
- Questions? Email terrelllouis056@gmail.com.