Marketplace

eBay Deal Hunter

by Leo Anthias

Searches eBay for any collector or deal-hunting niche, filters out unwanted listings, inspects listing photos against your buying criteria, and sends top candidates for approval.

  • sourcing
  • ebay
  • ecommerce
  • research

Instructions

eBay Deal Hunter

eBay Deal Hunter automates high-signal eBay sourcing for collectors, traders, dealers, and resellers in any niche — from vintage watches, cameras, and audio gear to trading cards, archival fashion, and rare parts.

It searches eBay through the official Browse API, filters out unwanted keywords, seller locations, and price-cap violations, downloads full-resolution photos to inspect every candidate against your buying guide, and sends only s_tier and borderline finds to you for approval.


Step 1: Get Your eBay Developer Account & API Keys

Because eBay blocks automated page scraping, eBay Deal Hunter uses the official eBay Browse API. Before setting up the app:

  1. Register for an eBay Developer Account: Go to the eBay Developers Program portal and sign up or sign in.
  2. Create a Production Keyset: Open your Application Keys page, enter an application title (e.g., eBay Deal Hunter), and create a Production keyset.
  3. Save Your Credentials as Secrets: Copy your Production App ID (Client ID) and Cert ID (Client Secret) and save them in your organization's secrets as EBAY_APP_ID and EBAY_CERT_ID.
  4. Verify Access: Once configured, you can run uv run app/ebay.py token in a workspace terminal to confirm your credentials work.

Step 2: Define Your Niche & Storage (Onboarding Checklist)

Walk through these eight questions to tailor the configuration files, storage backend, and environment variables to your workflow:

  1. Where do you want to store seen listings and approved finds? Choose one of three storage backends for tracking seen eBay item IDs (log) and saving your approved deals (finds):
    • Option A — Supabase (via app/db.py): Best for high volume and atomic batch claiming. Set SUPABASE_URL in App Metadata and SUPABASE_SERVICE_KEY in Secrets.
    • Option B — Notion (via notion MCP connection): Bind the notion MCP connection to the app and create two Notion databases (or one database with a Status/Verdict property) for Seen Listings Log and Approved Finds.
    • Option C — Google Sheets (via google_sheets MCP connection): Bind the google_sheets MCP connection to the app and create a spreadsheet with two tabs: Log (one row per seen ebay_item_id) and Finds (approved deals).
  2. What is your niche & eBay category?
    • Pick your target eBay category ID (for example, 31387 for Wristwatches, 625 for Cameras & Photo, 183454 for Collectible Card Games, or leave blank to search all categories) and set EBAY_CATEGORY_ID in App Metadata.
  3. What are your target makers, models, and specs?
    • List the exact brands, model references, eras, and desirable traits in app/search-criteria.md and agent/interest-map.md.
  4. What are your price limits and "grail" exceptions?
    • Set your everyday price cap in STANDARD_MAX_PRICE (e.g., 1500 USD).
    • If you have rare, high-value exceptions you are willing to pay more for, set MAX_PRICE (e.g., 5000 USD) and set EXCEPTION_REGEX to match those titles. Otherwise, set MAX_PRICE equal to STANDARD_MAX_PRICE and leave EXCEPTION_REGEX empty.
  5. Buy It Now vs. Auction?
    • Set REQUIRE_FIXED_PRICE to "true" to only pull listings with a Buy It Now (FIXED_PRICE) option, or "false" if you also want pure auctions (auctions ending within 48 hours are automatically prioritized first).
  6. What should be automatically excluded?
    • Add title keywords you never want to see (e.g., "box only", "for parts", replicas, unwanted sub-models, wrong sizes) to agent/exclusions.txt (one term per line).
    • Optionally set BLOCKED_COUNTRIES (comma-separated ISO country codes like "EG") in App Metadata.
  7. What photo checks determine s_tier vs. borderline vs. pass?
    • Customize the 6 visual inspection checks in agent/interest-map.md (such as era/spec accuracy, serial/logo markings, component originality, body condition, internal/mechanism verification, and counterfeit red flags).
  8. What search queries and schedule do you want?
    • Configure your saved keyword queries or eBay search URLs, batch cap (max_items), and cron schedule on the Listing Search agent.

Shared App Configuration

App Metadata

Set these environment variables and metadata keys on the app, replacing the placeholder values with your own niche and storage settings:

{
  "env": {
    "EBAY_MARKETPLACE": "EBAY_US",
    "EBAY_CATEGORY_ID": "<optional-ebay-category-id>",
    "REQUIRE_FIXED_PRICE": "true",
    "BLOCKED_COUNTRIES": "",
    "STANDARD_MAX_PRICE": 1500,
    "MAX_PRICE": 5000,
    "EXCEPTION_REGEX": "<optional-regex-for-high-tier-exceptions>",
    "STORAGE_BACKEND": "supabase",
    "SUPABASE_URL": "https://<your-project-ref>.supabase.co"
  },
  "max_price": 5000,
  "standard_max_price": 1500,
  "storage_backend": "supabase",
  "notion_log_db_id": "<optional-notion-log-database-id>",
  "notion_finds_db_id": "<optional-notion-finds-database-id>",
  "google_sheet_id": "<optional-google-spreadsheet-id>"
}

Shared Instructions

eBay Deal Hunter finds listings on eBay for a buyer based on their niche criteria, inspects candidate listings, and puts top candidates in front of the buyer to approve or reject. Be conservative: a false S-tier costs the buyer money. Write plainly.

## Price Rule ($STANDARD_MAX_PRICE limit, with optional high-tier exception up to $MAX_PRICE)
- **Standard price cap (`standard_max_price` / `$STANDARD_MAX_PRICE`):** Every listing must be at or under `$STANDARD_MAX_PRICE` USD (item price, excluding shipping), unless it matches the buyer's defined high-tier exception in `app/search-criteria.md` and `$EXCEPTION_REGEX`.
- **High-tier exception (up to `$MAX_PRICE`):** Only items matching the exception criteria may exceed `$STANDARD_MAX_PRICE` up to `$MAX_PRICE`. Any other item over `$STANDARD_MAX_PRICE` is strictly blocked and dropped in both `ebay.py` and `Listing Assessment`.
- **Over `$MAX_PRICE`:** Hard ceiling — always excluded.

## Run output policy
- **Listing Search** always publishes a clear run result after every search showing what was found/started and what was ignored/excluded.
- **Listing Assessment** ONLY publishes a run result (`output` text/data) when the buyer **approves** a listing (in `Add to Finds`). If a listing is auto-blocked, rated `pass`, over the price limit, rejected by the buyer, expired, or already assessed, keep notes in working data and the storage log ONLY — leave the run `output` completely empty.

## Scripts & Storage Backends
- `uv run app/ebay.py ...` reads eBay through the Browse API. Commands: `token`, `search`, `search-url`, `item`, `photos`, `merge`; see the file's docstring. It reads the secrets $EBAY_APP_ID and $EBAY_CERT_ID and enforces the price limits, format filter, and exclusions itself. Never scrape ebay.com pages; they block automated requests.
- **Storage Backend (choose one during setup):**
  - **Supabase (`storage_backend: "supabase"`):** Run `uv run app/db.py ...` (`claim-batch`, `settle`, `claim`, `update`, `find`), which reads `$SUPABASE_URL` and `$SUPABASE_SERVICE_KEY`. Always pass values through a JSON file.
  - **Notion (`storage_backend: "notion"`):** Use the `notion` MCP connection tools to query and update the Seen Listings Log database (`notion_log_db_id`) and create approved rows in the Approved Finds database (`notion_finds_db_id`).
  - **Google Sheets (`storage_backend: "google_sheets"`):** Use the `google_sheets` MCP connection tools on spreadsheet `google_sheet_id` to read/write rows in the `Log` tab and append approved deals to the `Finds` tab.
- A script that exits non-zero has failed: record its stderr in an exception before deciding what to do.

## Data Model (Log & Finds)
- **Log (`watch_log` table / Notion Log DB / Sheet `Log` tab):** One row per `ebay_item_id`. `verdict` is `sent`, `awaiting_review`, `qualified`, `rejected`, `expired`, or `error`. Any verdict except `error` means the item has been handled and must not be assessed again; an `error` row may be retried.
- **Finds (`watch_finds` table / Notion Finds DB / Sheet `Finds` tab):** Listings the buyer approved. `status` starts at `new`.
- `agent_rating` values: `s_tier`, `borderline`, `pass`.

## Conventions
- Never record a seller's username or any other personal data; seller feedback score and percentage are fine.
- Times shown to the buyer are in their local time zone (default Pacific).
- Keep tool calls low: batch work in one script or MCP call where you can.

App Files

Attach these files at the app level (app/):

  • ebay.py — CLI for querying the eBay Browse API, filtering candidates by price, buying format, country, and keyword exclusions, and downloading full-resolution listing photos.
  • db.py — CLI for claiming, updating, settling, and logging approved finds in Supabase via RPC functions (wh_claim_batch, wh_settle, wh_claim, wh_update, wh_add_find). (Used when storage_backend is "supabase"; optional if using Notion or Google Sheets via MCP.)
  • search-criteria.md — Customizable reference document listing target categories, brands, models, price rules, and automatic blocks.

Agents

1. Listing Search

Searches eBay for one or more keyword queries or eBay search URLs, enforces price limits, format filters, and title exclusions, claims unseen listings in your chosen storage backend (Supabase, Notion, or Google Sheets), and starts a Listing Assessment run for each new candidate.

  • How it starts: On a schedule (e.g., daily at 7:00 AM America/Los_Angeles, disabled by default) or manually with queries (list of search strings or eBay URLs) and optional max_items.
  • Metadata:
    {
      "assessment_agent_id": "<your-listing-assessment-agent-id>",
      "default_max_items": 10
    }
    
  • Schedule: Cron 0 7 * * * (America/Los_Angeles), disabled by default, with payload:
    {
      "max_items": 10,
      "queries": [
        "<your first search query>",
        "<your second search query>",
        "<your third search query or eBay search URL>"
      ]
    }
    
  • Agent Files: exclusions.txt (one excluded title term per line).
  • Approvals: None.

Listing Search Instructions

One run searches eBay for one or more queries, enforces the `$STANDARD_MAX_PRICE` limit (and optional high-tier exception up to `$MAX_PRICE`), claims unseen listings in the configured storage backend (Supabase via `db.py`, Notion via MCP, or Google Sheets via MCP), and starts a Listing Assessment run for each new qualifying listing, up to a cap.

## Price filtering (enforced automatically by `ebay.py`)
- **At or under `$STANDARD_MAX_PRICE`:** Kept and prioritised first.
- **Above `$STANDARD_MAX_PRICE` up to `$MAX_PRICE`:** Automatically excluded by `ebay.py` (`excluded_over_standard_cap`) UNLESS the listing title matches `$EXCEPTION_REGEX`.
- **Over `$MAX_PRICE`:** Always excluded.

## Input
- data `queries`: a list of keyword searches or eBay search URLs (a value starting with http is a URL). A single query may come in the run text instead.
- data `max_items`: how many assessments to start this run; default is the metadata `default_max_items`.

## Starting assessments
Start each assessment as a run of the Listing Assessment agent (metadata `assessment_agent_id`), named `<title, cut to 60 chars>`, with data `{listing: <the claimed row>, source: "search", search_query, claimed: true}`. Pump Up limits how many runs can be live at once. If starting a run is refused for that reason, stop starting runs and mark every remaining claimed listing as not started (`verdict: "error"`), so the next search retries them. Do not retry in a loop.

## Output (Always publish after every search)
Always publish a clear run result (`output` text and data) showing:
- **Found & started**: each listing started for assessment (title, price, eBay item id / URL, and started run id), plus how many kept candidates remain for future runs.
- **Ignored / excluded**: counts and reasons for everything dropped — over `$STANDARD_MAX_PRICE` (non-exception), over `$MAX_PRICE`, auction-only (when Buy It Now is required), blocked seller country, excluded by title term (with top matched terms), and already seen in the storage log.

Listing Search Steps

Step IDLabelOwnerGroupChecklist / GateExitsInstructions
b100ReadyAGENTREADYQueries readb101Read the queries and max_items from the input.
b101SearchAGENTIN_PROGRESSSearches run; candidates.json writtenb102, b104For each query run uv run app/ebay.py search --q "<query>" --exclude-file agent/exclusions.txt > s<n>.json (or search-url "<url>" for a URL), batching them in one shell call. Then ebay.py merge s*.json > candidates.json. If every search failed, go to Error (b104).
b102DispatchAGENTIN_PROGRESSBatch claimed; Assessments started; Dispatch settledb103, b104Filter out already-seen listings and claim up to max_items new ones using the configured storage backend (uv run app/db.py claim-batch candidates.json --max <max_items> for Supabase, or via the notion / google_sheets MCP tools). Start a Listing Assessment run for each claimed listing, stopping at the first run-limit refusal. Record started run IDs and mark any unstarted items as error for retry (db.py settle dispatch.json or via Notion/Sheets MCP). Publish the full search summary to the run output.
b103DoneAGENTCOMPLETE(none)(none)Search finished and assessments started.
b104ErrorAGENTFAILED(none)(none)The search could not complete.

2. Listing Assessment

Evaluates a single eBay listing against the buyer's interest map and photo inspection checks, filters out automatic blocks, and requests human approval only for s_tier or borderline candidates.

  • How it starts: Triggered automatically by Listing Search (with {listing, source: "search", search_query, claimed: true}) or started manually with an eBay listing URL or item ID.
  • Schedule: None.
  • Agent Files: interest-map.md (target criteria, automatic blocks, six photo checks, and rating rules).
  • Approvals: Opens an approval request in the Review step (a103) for s_tier or borderline items meeting the price rules, attaching 3 to 6 listing photos.

Listing Assessment Instructions

One run assesses one eBay listing against the buyer's interest map (`agent/interest-map.md` and `app/search-criteria.md`) and puts qualifying candidates in front of the buyer to approve or reject.

## Run Output Policy (CRITICAL)
- **ONLY publish a run result (`output` text/data) when the buyer approves the item** (in `Add to Finds`).
- When a listing is auto-blocked, rated `pass`, over the price limit, rejected by the buyer, expired, or already assessed, record the details in working data and the storage log ONLY — **leave the run `output` completely empty (`text: ""`, `data: {}`)**.

## Price Rule ($STANDARD_MAX_PRICE limit, with optional exception up to $MAX_PRICE)
- **At or under `$STANDARD_MAX_PRICE`:** Open an approval request for the buyer if rated `s_tier` or `borderline`.
- **Over `$STANDARD_MAX_PRICE` (up to `$MAX_PRICE`):** Reject immediately UNLESS the item qualifies as a defined high-tier exception in `app/search-criteria.md` and is rated `s_tier` or `borderline`.
- **Over `$MAX_PRICE`:** Hard ceiling — always reject immediately.

## Automatic blocks (reject immediately in Fetch listing without bothering the buyer)
Reject immediately (without downloading photos, opening an approval request, or writing run output) if any of these apply:
- Item price exceeds `$STANDARD_MAX_PRICE` and is not a qualifying high-tier exception (or exceeds `$MAX_PRICE`)
- Buying format violates the buyer's rule (e.g., `"FIXED_PRICE"` not in `buying_options` when `REQUIRE_FIXED_PRICE` is true)
- Seller is in a blocked country (`$BLOCKED_COUNTRIES`)
- Listing matches any automatic block in `agent/interest-map.md` or `app/search-criteria.md` (replicas/reissues, blocked brands/models, wrong specs, or parts/accessories/boxes only).

## Input
- From Listing Search: data `{listing: {ebay_item_id, title, url, price, currency, ...}, source: "search", search_query, claimed: true}`. The log entry already exists.
- Manual: a listing URL or item id in data `listing` or in the run text, with no `claimed`. Check and claim it in the storage log (`db.py claim` for Supabase, or via Notion / Google Sheets MCP); if already handled, stop and go to `Already assessed`.

## Decision record
Write these keys in working data (not run `output`), so runs and the buyer's decisions can be compared: `ebay_item_id`, `title`, `price`, `currency`, `shipping`, `current_bid`, `bid_count`, `buying_options`, `ends_at`, `seller_feedback_score`, `seller_feedback_pct`, `photo_count`, `maker`, `model`, `era`, `category`, `spec_or_calibre`, `spec_source` (`photo`, `listing_text`, or `inferred`), `spec_confidence` (`high`, `medium`, `low`), `checks` (`era_and_spec`, `surface_and_markings`, `components`, `chassis_and_body`, `internals_or_mechanism`, `red_flags`, each `{result: pass|fail|unknown, photos: [n], note}`), `agent_rating`, `rating_reason`, `open_question`, `seller_question`. Use null for anything you cannot tell.

## Approval request
Only open an approval request for `s_tier` or `borderline` items that pass the price rule.
Title: `[S-tier|Borderline] <maker model spec> - <price incl. shipping, or current bid and bid count>`. Body: end time, the listing link, the photo checks in one line each with photo numbers, the rating reason, and anything you could not check. Attach the 3 to 6 most telling photos. Approve adds it to Finds and publishes the run result; reject records the rejection in the storage log with empty run `output`.

Listing Assessment Steps

Step IDLabelOwnerGroupChecklist / GateExitsInstructions
a100ReadyAGENTREADYItem id founda101Read the input and work out the eBay item id. Do not write to run output.
a101Fetch listingAGENTIN_PROGRESSListing fetched; Claimed or already claimed; Passes automatic blocks and price rule; Photos downloaded and vieweda102, a106, a107, a108, a109Run uv run app/ebay.py item <id>. If input has no claimed: true, claim in the storage backend (db.py claim or Notion/Sheets MCP; if already handled, go to a108). If ended, update verdict to expired and go to a107. Check automatic blocks and price rule: if blocked, update verdict to rejected (agent_rating: pass) and go to a106. Otherwise run ebay.py photos <id> --out photos and inspect every photo. On failure, set verdict error and go to a109.
a102AssessAGENTIN_PROGRESSDecision record written to working data; Storage log updateda103, a106, a109Identify maker, model, era, and key spec, run the six photo checks in agent/interest-map.md, and rate s_tier, borderline, or pass. Write decision record in working data. If pass or over price rule, update storage log to rejected and go to a106. Otherwise update storage log to awaiting_review and go to a103.
a103ReviewAGENTIN_PROGRESSApproval request opened; Buyer decideda104, a106, a107Open an approval request for the buyer. When resumed, check end time first: if ended, set verdict expired and go to a107. If approved, go to a104. If rejected, update storage log to rejected with comment and go to a106.
a104Add to FindsAGENTIN_PROGRESSAdded to Finds; Storage log set to qualified; Run output publisheda105, a109Add the approved item to Finds (db.py find for Supabase, or create a row in Notion Finds DB / Google Sheets Finds tab via MCP, including why_compelling in two or three plain sentences on originality, condition, and rarity, saying nothing about price), then update the log entry to qualified. Publish the approved item summary and decision record to the run output.
a105QualifiedAGENTCOMPLETE(none)(none)The buyer approved; the item is in Finds and published to the run output.
a106RejectedAGENTCOMPLETE(none)(none)Rejected (by automatic block, Pass rating, price rule, or buyer). Ensure run output is empty.
a107ExpiredAGENTCOMPLETE(none)(none)The listing ended before the buyer decided. Ensure run output is empty.
a108Already assessedAGENTCOMPLETE(none)(none)The item was already in the storage log. Ensure run output is empty.
a109ErrorAGENTFAILED(none)(none)Something failed; storage log is set to error so a later search can retry it.

Connections & Secrets

Connections (Choose Based on Your Storage Backend)

Connection NameWhen NeededPurpose
notionIf storage_backend is "notion"Reads and updates the Seen Listings Log database and writes approved items to the Approved Finds database in Notion.
google_sheetsIf storage_backend is "google_sheets"Reads and updates the Log sheet tab and appends approved items to the Finds sheet tab in Google Sheets.
(none)If storage_backend is "supabase"Talks to Supabase directly through app/db.py over HTTPS.

Secrets

Create these secrets in your organization so the scripts can read them as environment variables:

Secret NameWhen NeededPurpose
EBAY_APP_IDAlwayseBay developer application Client ID from developer.ebay.com/my/keys (ebay.py).
EBAY_CERT_IDAlwayseBay developer application Client Secret for OAuth2 token generation (ebay.py).
SUPABASE_SERVICE_KEYIf using SupabaseSupabase service role key used by db.py to call the wh_* Postgres RPC functions (wh_claim_batch, wh_settle, wh_claim, wh_update, wh_add_find).

Files

  • db.py
  • ebay.py
  • search-criteria.md
  • interest-map.md
  • exclusions.txt

Details

Version
1
Updated
Nov 2, 2026