DEV Community

miccho27
miccho27

Posted on

Building a Price Comparison Tool with Free APIs (Step-by-Step)

Price comparison tools are one of the most profitable side projects -- affiliate commissions on every click. But building one from scratch means solving multiple data problems.

Here is how to build a basic price comparison tool using free APIs, with no backend costs.

Architecture

User enters product URL -> Scrape metadata -> Enrich with market data -> Display comparison
Enter fullscreen mode Exit fullscreen mode

We will use 4 free APIs to build this:

  1. Web Metadata Extractor API -- Pull product titles, images, descriptions from URLs
  2. Currency Exchange Rate API -- Convert prices across currencies
  3. AI Text API -- Summarize product descriptions
  4. SEO Analyzer API -- Score product page quality (for ranking which merchants to feature)

All available on RapidAPI with free tiers.

Step 1: Extract Product Data from URLs

When a user pastes a product URL, extract the metadata:

async function extractProductInfo(url) {
  const response = await fetch(
    `https://web-meta-extractor-api.p.rapidapi.com/extract?url=${encodeURIComponent(url)}`,
    {
      headers: {
        'X-RapidAPI-Key': API_KEY,
        'X-RapidAPI-Host': 'web-metadata-extractor-api.p.rapidapi.com',
      },
    }
  );
  const data = await response.json();

  return {
    title: data.metadata.ogTitle || data.metadata.title,
    image: data.metadata.ogImage,
    description: data.metadata.ogDescription || data.metadata.description,
    price: extractPriceFromMeta(data.metadata),
  };
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Normalize Prices Across Currencies

Products from different countries? Normalize to one currency:

async function convertPrice(amount, fromCurrency, toCurrency) {
  const response = await fetch(
    `https://currency-exchange-rate-api.p.rapidapi.com/convert?from=${fromCurrency}&to=${toCurrency}&amount=${amount}`,
    {
      headers: {
        'X-RapidAPI-Key': API_KEY,
        'X-RapidAPI-Host': 'currency-exchange-rate-api.p.rapidapi.com',
      },
    }
  );
  const data = await response.json();
  return data.result;
}

// Usage
const priceUSD = await convertPrice(2980, 'JPY', 'USD'); // 2,980 JPY -> $19.87
Enter fullscreen mode Exit fullscreen mode

Step 3: Summarize Product Descriptions

Long product descriptions? Summarize them for quick comparison:

async function summarizeDescription(text) {
  const response = await fetch(
    'https://ai-text-api.p.rapidapi.com/summarize',
    {
      method: 'POST',
      headers: {
        'X-RapidAPI-Key': API_KEY,
        'X-RapidAPI-Host': 'ai-text-api.p.rapidapi.com',
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({ text, max_length: 100 }),
    }
  );
  const data = await response.json();
  return data.summary;
}
Enter fullscreen mode Exit fullscreen mode

Step 4: Score Merchant Page Quality

Use SEO analysis to rank which merchant pages are most trustworthy:

async function scoreMerchant(url) {
  const response = await fetch(
    `https://seo-analyzer-api.p.rapidapi.com/analyze?url=${encodeURIComponent(url)}`,
    {
      headers: {
        'X-RapidAPI-Key': API_KEY,
        'X-RapidAPI-Host': 'seo-analyzer-api.p.rapidapi.com',
      },
    }
  );
  const data = await response.json();
  return {
    seoScore: data.score,
    hasSSL: data.checks.ssl,
    mobileOptimized: data.checks.viewport,
  };
}
Enter fullscreen mode Exit fullscreen mode

Putting It Together

async function compareProducts(urls) {
  const products = await Promise.all(
    urls.map(async (url) => {
      const [info, seo] = await Promise.all([
        extractProductInfo(url),
        scoreMerchant(url),
      ]);

      const normalizedPrice = info.price
        ? await convertPrice(info.price.amount, info.price.currency, 'USD')
        : null;

      const summary = info.description
        ? await summarizeDescription(info.description)
        : 'No description available';

      return {
        url,
        title: info.title,
        image: info.image,
        price: normalizedPrice,
        summary,
        trustScore: seo.seoScore,
      };
    })
  );

  return products.sort((a, b) => (a.price || Infinity) - (b.price || Infinity));
}
Enter fullscreen mode Exit fullscreen mode

Cost Analysis

With free tiers (500 req/month each):

API Calls per comparison Monthly comparisons possible
Metadata Extractor 1 per URL 500
Currency Exchange 1 per URL 500
AI Text 1 per URL 500
SEO Analyzer 1 per URL 500

Comparing 3 products = 12 API calls. Free tier supports about 40 comparisons/month.

For production, the Basic plans ($4.99-5.99/mo each) give you 5,000-50,000 requests -- enough for thousands of daily comparisons at under $25/month total infrastructure cost.

Monetization

  • Affiliate links: Replace product URLs with affiliate tracking links
  • Sponsored listings: Charge merchants for featured placement
  • Premium features: Price alerts, historical price charts (using cached API data)

Next Steps

  1. Add a database (Supabase free tier) to cache product data
  2. Set up a cron job to refresh prices daily
  3. Build email alerts for price drops
  4. Add more data sources (product review APIs, stock availability)

The full source code pattern works with any product category -- electronics, books, software, SaaS tools.


What would you build with these APIs? Price comparison is just one pattern -- the same metadata + currency + AI stack works for content aggregators, research tools, and marketplace builders.

Browse all 31 APIs

Top comments (0)