Skip to main content

BuyWhere Python SDK

Official Python SDK for the BuyWhere Product Catalog API — the agent-native product search API for Singapore.

Installation

pip install buywhere-sdk

Or from source:

pip install -e sdk/python/

Quickstart

from buywhere import BuyWhereClient

client = BuyWhereClient(api_key="key_xxx", base_url="http://143.198.87.39:8000")

# Search products in Singapore
results = client.products.search(q="iphone 15", country="sg", limit=10)
for r in results.results:
    print(r.title, r.price.amount, r.price.currency)

Usage

Sync client

from buywhere import BuyWhereClient

client = BuyWhereClient(api_key="key_xxx")

# Search products
results = client.products.search(q="iphone 15", country="sg", limit=10)

# Get product by ID
product = client.products.get(product_id="abc123")

# Compare prices across merchants
prices = client.products.compare_prices(product_id="abc123")
print(prices.best_price)

# List categories
categories = client.categories.list()

# Category detail
electronics = client.categories.get("electronics")
print(electronics.subcategories)

Async client

import asyncio
from buywhere import AsyncBuyWhereClient

async def main():
    async with AsyncBuyWhereClient(api_key="key_xxx") as client:
        results = await client.products.search(q="airfryer", country="sg")
        for r in results.results:
            print(r.title, r.price.amount)

asyncio.run(main())

Pagination

results = client.products.search(q="laptop", limit=10)
while results.has_more:
    results = client.products.search(q="laptop", limit=10, cursor=results.next_cursor)
    for r in results.results:
        print(r.title)

Filtering and sorting

results = client.products.search(
    q="headphones",
    category="electronics/audio",
    price_min=50.0,
    price_max=300.0,
    platform="shopee",
    sort="price_asc",
    limit=20,
)

Error handling

from buywhere import BuyWhereClient, NotFoundError, AuthenticationError, RateLimitError

client = BuyWhereClient(api_key="key_xxx")

try:
    product = client.products.get("does-not-exist")
except NotFoundError:
    print("Product not found")
except AuthenticationError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limited — retry later")

Configuration

Parameter Default Description
api_key (required) Your BuyWhere API key
base_url https://api.buywhere.io Override for staging/local
timeout 30.0 Request timeout in seconds

LangChain integration

BuyWhere ships a first-class LangChain tool so your agents can search the catalog in natural language.

pip install buywhere-sdk[langchain]
from buywhere import BuyWhereClient, BuyWhereTool
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType

client = BuyWhereClient(api_key="bw_...")
tool = BuyWhereTool(client=client, country="sg")
agent = initialize_agent([tool], ChatOpenAI(model="gpt-4o-mini"), agent=AgentType.OPENAI_FUNCTIONS, verbose=True)
agent.run("Find me noise-cancelling headphones under SGD 200 on Shopee")

The tool exposes structured inputs so the LLM can pass filters (category, price range, platform) directly:

# Use the tool directly without an agent
result = tool.run("wireless earbuds")
print(result)
# Found 48 products for 'wireless earbuds' (showing 5):
# 1. Sony WF-1000XM5
#    Price: SGD 279.00 (was 349.00)
#    Platform: shopee | Merchant: Sony Official Store
#    ...

Requirements

  • Python 3.9+
  • httpx >= 0.25
  • pydantic >= 2.0
  • langchain-core >= 0.1 (optional — only for BuyWhereTool)

Metadata

Release files for buywhere 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for buywhere 0.2.0
File Size Uploaded
buywhere-0.2.0.tar.gz 9.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for buywhere 0.2.0
File Interpreter ABI Platform
buywhere-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / buywhere-0.2.0.tar.gz

Download URL buywhere-0.2.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2ce52bb640940b2a2686534511adcc6a4ce91da86167842871a1701581122eab
BLAKE2b-256 checksum
How to use checksums
fe0d9d43aad77eac34d0f06225c2337ab8022f6dbc9bf27c565af6a3bf4c9a71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / buywhere-0.2.0-py3-none-any.whl

Download URL buywhere-0.2.0-py3-none-any.whl
Size 12.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e72cecccc6f75d7904b5d39ef6267473e3c83c877586df3ccc24ae4251c05f8b
BLAKE2b-256 checksum
How to use checksums
b7a108d5b36b54055f6f64a9a8c827b8e04672cdf21cc31b0ed6d17f9bccb679
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page