Official Python SDK for the BuyWhere Product Catalog API
Project description
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.25pydantic >= 2.0langchain-core >= 0.1(optional — only forBuyWhereTool)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file buywhere-0.1.0.tar.gz.
File metadata
- Download URL: buywhere-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18acc461fe6b239cc933383a76b97902466547f07aa80b9c7ee907f6ceee2b0d
|
|
| MD5 |
266dbe1c87e8ad55a105d34b7903f266
|
|
| BLAKE2b-256 |
e0c9cef1c16290f597758aeaca495a3afb3b6453ff32c9c84f5dbd592ae440f3
|
File details
Details for the file buywhere-0.1.0-py3-none-any.whl.
File metadata
- Download URL: buywhere-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
afdcf5136b83555c8ad90306af7ec67e312a5326cd2baac3819ad76bdcf5fc0a
|
|
| MD5 |
2d23fdc336637344785112ddfbbadf3b
|
|
| BLAKE2b-256 |
e4ea8f746cb4b7b88f0a56f8eb88f525fc180d159765aa10aba4542999364684
|