DEV Community

lulzasaur
lulzasaur

Posted on

Build a Price Comparison Tool in 15 Minutes with the Marketplace Price API

Ever tried to find the best price for something across multiple marketplaces? You'd need to open OfferUp, Poshmark, Reverb, TCGPlayer — each with different search interfaces and no way to compare side by side.

The Marketplace Price API solves this with a single unified /search endpoint that queries multiple marketplaces simultaneously and returns normalized results.

In this tutorial, we'll build a CLI price comparison tool in under 15 minutes.

What We're Building

A Node.js script that:

  1. Takes a search query as input
  2. Searches across 4 marketplaces in parallel
  3. Shows a sorted comparison table with the best prices

Prerequisites

Step 1: Get Your API Key

Subscribe to the Marketplace Price Tracker API on RapidAPI. The free tier gives you 500 requests/month — plenty for this tutorial.

Copy your X-RapidAPI-Key from the API dashboard.

Step 2: Set Up the Project

mkdir price-compare && cd price-compare
npm init -y
Enter fullscreen mode Exit fullscreen mode

Create a .env file:

RAPIDAPI_KEY=your_key_here
Enter fullscreen mode Exit fullscreen mode

Step 3: Build the Comparison Tool

Create compare.mjs:

const API_KEY = process.env.RAPIDAPI_KEY;
const BASE = "https://marketplace-price-tracker.p.rapidapi.com";
const HEADERS = {
  "X-RapidAPI-Key": API_KEY,
  "X-RapidAPI-Host": "marketplace-price-tracker.p.rapidapi.com",
};

const query = process.argv[2];
if (!query) {
  console.error("Usage: node compare.mjs <search query>");
  process.exit(1);
}

console.log(`\nSearching for "${query}" across 4 marketplaces...\n`);

// Search all marketplaces in parallel
const endpoints = [
  { name: "Reverb", path: `/reverb/search?query=${encodeURIComponent(query)}&limit=5` },
  { name: "TCGPlayer", path: `/tcg/search?query=${encodeURIComponent(query)}&limit=5` },
  { name: "OfferUp", path: `/offerup/search?query=${encodeURIComponent(query)}&limit=5` },
  { name: "Poshmark", path: `/poshmark/search?query=${encodeURIComponent(query)}&limit=5` },
];

const results = await Promise.allSettled(
  endpoints.map(async ({ name, path }) => {
    const res = await fetch(`${BASE}${path}`, { headers: HEADERS });
    if (!res.ok) return { name, items: [] };
    const data = await res.json();
    const items = (data.results || data.listings || []).map((item) => ({
      marketplace: name,
      title: item.title || item.productName || item.name,
      price: parseFloat(item.price || item.marketPrice || item.lowestPrice || 0),
      condition: item.condition || "N/A",
      url: item.url || "#",
    }));
    return { name, items };
  })
);

// Flatten and sort by price
const allItems = results
  .filter((r) => r.status === "fulfilled")
  .flatMap((r) => r.value.items)
  .filter((item) => item.price > 0)
  .sort((a, b) => a.price - b.price);

if (allItems.length === 0) {
  console.log("No results found. Try a different search term.");
  process.exit(0);
}

// Display results
console.log("Price".padEnd(10) + "Marketplace".padEnd(14) + "Condition".padEnd(12) + "Title");
console.log("-".repeat(80));

for (const item of allItems.slice(0, 20)) {
  const price = `$${item.price.toFixed(2)}`.padEnd(10);
  const mp = item.marketplace.padEnd(14);
  const cond = (item.condition || "N/A").slice(0, 10).padEnd(12);
  const title = item.title?.slice(0, 44) || "";
  console.log(`${price}${mp}${cond}${title}`);
}

console.log(`\nFound ${allItems.length} results across ${results.filter((r) => r.status === "fulfilled").length} marketplaces`);
Enter fullscreen mode Exit fullscreen mode

Step 4: Run It

RAPIDAPI_KEY=your_key_here node compare.mjs "fender stratocaster"
Enter fullscreen mode Exit fullscreen mode

Output:

Searching for "fender stratocaster" across 4 marketplaces...

Price     Marketplace   Condition   Title
--------------------------------------------------------------------------------
$149.99   OfferUp       Good        Fender Squier Stratocaster Electric Gui
$225.00   Poshmark      N/A         Fender Player Stratocaster HSS Buttercr
$349.00   Reverb        Excellent   Fender Player Stratocaster 2019 3-Color
$425.00   Reverb        Very Good   Fender American Stratocaster Sunburst
$599.99   Reverb        Excellent   Fender American Pro II Stratocaster
...

Found 18 results across 4 marketplaces
Enter fullscreen mode Exit fullscreen mode

Available Endpoints

Endpoint Description
GET /reverb/search Reverb music gear listings
GET /reverb/price-history Historical price data for Reverb items
GET /tcg/search TCGPlayer card listings
GET /tcg/price TCGPlayer card price lookup
GET /offerup/search OfferUp local marketplace listings
GET /poshmark/search Poshmark fashion resale listings

Use Cases

  • Resellers: Find arbitrage opportunities across marketplaces
  • Collectors: Track TCG card prices, find the best deals on vintage gear
  • Shoppers: Compare prices before buying
  • Discord Bots: Power price-check commands with real-time data
  • Price Tracking Apps: Build dashboards with historical pricing

What's Next?

  • Add a simple web UI with React or Svelte
  • Store historical prices in SQLite for trend analysis
  • Set up a cron job to check prices daily
  • Build a Discord bot with /price-check commands

The Marketplace Price Tracker API free tier includes 500 requests/month — enough to build and test any of these.

Top comments (0)