← Back to blog
developerstutorialprice-comparisonsingaporeapi

How to Build a Price Comparison Tool with a Product API

A practical guide to building a price comparison tool using the BuyWhere API — the agent-native product catalog API for Singapore and Southeast Asia.

BuyWhere TeamApril 16, 2026

Building a price comparison tool from scratch means dealing with scraper maintenance, retailer ToS enforcement, and data normalization across dozens of sources. Most developers who try this approach end up spending more time on infrastructure than on the actual comparison logic.

The alternative is to query a unified product catalog API. This guide walks through how to use the BuyWhere API to build a working price comparison tool for Singapore e-commerce — in under 100 lines of code.

What You Need Before You Start

  • A BuyWhere API key — sign up at buywhere.ai/api-keys-keys
  • Python 3.10+ or Node.js 18+
  • pip install buywhere-sdk or npm install @buywhere/sdk

Step 1: Search for a Product Across Sources

The core of any price comparison tool is finding the same product listed across multiple retailers. The BuyWhere search endpoint accepts a text query and returns normalized results from all connected platforms:

from buywhere import BuyWhereClient

client = BuyWhereClient(api_key=os.environ["BUYWHERE_API_KEY"])

# Search for the same product across all Singapore retailers
results = client.search("lay's chips original 150g", limit=10)

for product in results.items:
    print(f"{product.source}: S${product.price} — {product.name}")

The key advantage here is that BuyWhere handles product normalization — the same product sold on Shopee, Lazada, and FairPrice appears with consistent field names even though each retailer has a different product page structure.

Step 2: Rank by Price

Once you have results, sorting by price is straightforward:

# Sort search results by price ascending
ranked = sorted(results.items, key=lambda p: p.price)

for product in ranked:
    print(f"S${product.price:.2f} @ {product.source} — {product.name}")
    print(f"  Buy: {product.buy_url}")

Step 3: Filter by Retailer

If you want to compare only specific platforms — say, Shopee vs Lazada — pass a source filter:

results = client.search("lay's chips original 150g", source="shopee_sg", limit=10)

Replace shopee_sg with any registered source identifier to scope results to that retailer.

Step 4: Find the Best Price Across All Sources

For a quick answer without manual sorting, use best_price:

cheapest = client.best_price("lay's chips original 150g")
print(f"Best price: S${cheapest.price} at {cheapest.source}")
print(f"Buy link: {cheapest.buy_url}")

Integrating with MCP

For AI agent workflows, BuyWhere also exposes an MCP server with structured tools. An agent can call search_products directly:

Tool: search_products
Query: lay's chips original 150g
Limit: 10

The agent receives normalized JSON with product names, prices, sources, and buy links — ready to reason over without parsing HTML or handling retailer-specific quirks.

What Makes This Different from Scraping

A scraper for Shopee or Lazada breaks when the retailer changes their site template. The repair cycle is unpredictable and often catches you on a weekend. BuyWhere absorbs that maintenance: when a retailer's site changes, the scraper adapter is updated and the API response shape stays the same.

Additionally, scrapers operate on a schedule. If you refresh every 6 hours, you miss price changes that happen between runs. The BuyWhere pipeline runs on a shorter cadence for active products, giving you fresher data than a self-hosted scraper can reasonably achieve.

What to Look for in a Price Comparison API

If you're evaluating options for a production comparison tool, here are the criteria that matter most:

Normalized product schema. Each retailer returns product data in a different shape. A good API normalizes fields like price, product name, brand, and availability into a consistent schema across all sources.

Source filtering. You often want to compare only a subset of retailers. The API should support filtering by source identifier.

Price sorting and ranking. The ability to sort results by price without downloading everything and sorting in your application.

Buy URL and affiliate support. For monetization, the API should return direct purchase URLs or affiliate links where available.

SDK support. Official SDKs for Python and TypeScript reduce boilerplate and handle auth, retries, and errors.

Get Started

Sign up at buywhere.ai/api-keys-keys and read the full API reference at docs.buywhere.ai. The quickstart guide will have you making your first comparison call in under five minutes.


BuyWhere is the only agent-native product catalog API built for Southeast Asia — serving product data across Singapore, Malaysia, Thailand, Indonesia, and the Philippines from a single unified interface.