Give Your OpenAI Agent Live Singapore Prices in 5 Minutes
Most shopping agents either hallucinate prices or scrape pages that break every month.
BuyWhere fixes that: one API call returns real-time prices from Harvey Norman, Shopee, Lazada, and 20+ Singapore retailers. Here's how to wire it into an OpenAI Agents SDK agent in under 5 minutes.
Prerequisites
- Python 3.11+
-
openai-agentsSDK - A free BuyWhere API key (grab one at buywhere.ai/dashboard)
Install
pip install openai-agents requests
The Agent
import os
import requests
from agents import Agent, Runner, function_tool
BUYWHERE_API_KEY = os.environ["BUYWHERE_API_KEY"]
BUYWHERE_BASE = "https://api.buywhere.ai"
@function_tool
def search_products(query: str, limit: int = 5) -> dict:
resp = requests.get(
f"{BUYWHERE_BASE}/v1/search",
params={"q": query, "limit": limit},
headers={"Authorization": f"Bearer {BUYWHERE_API_KEY}"},
timeout=10
)
resp.raise_for_status()
return resp.json()
@function_tool
def get_product_prices(product_id: str) -> dict:
resp = requests.get(
f"{BUYWHERE_BASE}/v1/products/{product_id}/prices",
headers={"Authorization": f"Bearer {BUYWHERE_API_KEY}"},
timeout=10
)
resp.raise_for_status()
return resp.json()
shopping_agent = Agent(
name="Singapore Shopping Agent",
instructions=(
"You are a shopping assistant for Singapore. "
"When asked about a product, use search_products to find live prices. "
"Always include the retailer name and exact price."
),
tools=[search_products, get_product_prices]
)
import asyncio
async def main():
result = await Runner.run(
shopping_agent,
"Where's the cheapest Samsung Galaxy S25 in Singapore right now?"
)
print(result.final_output)
asyncio.run(main())
What You Get
When you run this, the agent will:
- Call
search_productswith "Samsung Galaxy S25" - Get live prices from Shopee, Lazada, Harvey Norman, and others
- Return a grounded answer with actual current prices — no hallucinations
Sample output:
The Samsung Galaxy S25 (256GB) is currently cheapest on Shopee at S$1,099,
compared to S$1,199 at Harvey Norman and S$1,149 on Lazada.
Why This Beats Scraping
- No brittle selectors — retailers change their HTML constantly
- Live data — prices update throughout the day
- Structured output — product IDs, images, specs alongside price
- Rate-limit safe — one API call, not 20 page loads
Using BuyWhere MCP Instead
If you're building with Claude or any MCP-compatible tool:
{
"mcpServers": {
"buywhere": {
"command": "npx",
"args": ["-y", "buywhere-mcp"],
"env": {
"BUYWHERE_API_KEY": "your_api_key_here"
}
}
}
}
The MCP server exposes search_products, get_product, get_price, and compare_prices as native MCP tools. A remote Streamable HTTP endpoint is also available at https://api.buywhere.ai/mcp — now listed on Smithery.
Next Steps
- Developer docs — full API reference
- buywhere-mcp on npm — MCP server package
- API key — free tier available
Questions? Drop a comment or email surf@buywhere.ai.
Top comments (0)