GraphQL API
The BuyWhere GraphQL API provides a flexible query interface for AI agents to fetch exactly the product fields they need, reducing over-fetching and saving bandwidth and tokens.
Endpoint
- Playground:
GET /graphql— Interactive GraphQL IDE (GraphiQL) - API:
POST /graphql— GraphQL endpoint
Authentication
Include your API key in the Authorization header:
Authorization: Bearer <your-api-key>
Queries
products
Search and filter products with full control over returned fields.
Arguments:
| Argument | Type | Description |
|---|---|---|
query | String | Full-text search query |
category | String | Filter by category name |
minPrice | Float | Minimum price filter |
maxPrice | Float | Maximum price filter |
source | String | Filter by source (e.g., lazada_sg, shopee_sg) |
limit | Int | Number of results (default: 20, max: 100) |
offset | Int | Pagination offset (default: 0) |
Example:
query {
products(query: "iphone 15", category: "Smartphones", limit: 5) {
total
limit
offset
hasMore
items {
id
name
price
currency
source
brand
category
imageUrl
affiliateUrl
isAvailable
}
}
}
Response:
{
"data": {
"products": {
"total": 42,
"limit": 5,
"offset": 0,
"hasMore": true,
"items": [
{
"id": 12345,
"name": "iPhone 15 Pro Max 256GB",
"price": "1499.00",
"currency": "SGD",
"source": "lazada_sg",
"brand": "Apple",
"category": "Smartphones",
"imageUrl": "https://...",
"affiliateUrl": "https://...",
"isAvailable": true
}
]
}
}
}
product
Get a single product by ID.
Arguments:
| Argument | Type | Description |
|---|---|---|
id | Int! | Product ID (required) |
Example:
query {
product(id: 12345) {
id
name
sku
source
merchantId
price
currency
buyUrl
affiliateUrl
imageUrl
brand
category
categoryPath
rating
isAvailable
lastChecked
metadata
updatedAt
priceTrend
}
}
categories
List all available product categories with product counts.
Example:
query {
categories {
name
count
children {
name
count
}
}
}
taxonomy
Get the full unified category taxonomy with hierarchical structure.
Example:
query {
taxonomy {
total
version
categories {
id
name
productCount
subcategories {
id
name
productCount
}
}
}
}
deals
Find products currently priced below their original/historical price.
Arguments:
| Argument | Type | Description |
|---|---|---|
category | String | Filter by category |
minDiscountPct | Float | Minimum discount percentage (default: 10) |
limit | Int | Number of results (default: 20, max: 100) |
offset | Int | Pagination offset (default: 0) |
Example:
query {
deals(category: "Electronics", minDiscountPct: 20, limit: 10) {
total
limit
offset
items {
id
name
price
originalPrice
discountPct
dealScore
currency
source
category
buyUrl
affiliateUrl
imageUrl
clickCount
}
}
}
priceDrops
Find products with recent price decreases using price history data.
Arguments:
| Argument | Type | Description |
|---|---|---|
category | String | Filter by category |
days | Int | Number of days to look back (default: 7, max: 90) |
minDropPct | Float | Minimum price drop percentage (default: 5) |
limit | Int | Number of results (default: 20, max: 100) |
offset | Int | Pagination offset (default: 0) |
Example:
query {
priceDrops(category: "Laptops", days: 14, minDropPct: 10) {
total
limit
offset
items {
id
name
price
previousPrice
priceDrop
priceDropPct
dealScore
currency
source
category
buyUrl
priceDropDays
}
}
}
Why GraphQL?
Compared to the REST API, GraphQL offers:
- No over-fetching: Agents only get the fields they request
- Single request: Fetch products, categories, and deals in one query
- Predictable responses: No need to parse different REST endpoint shapes
- IDE support: Built-in GraphiQL playground for exploration
Rate Limits
Same rate limits apply as the REST API. Use the Authorization header with your API key.