PuddlePuddle Docs
Storefront API

Search and filtering

Search a store's products by text, with filters, sorting, pages and facet counts, from a headless storefront.

GET /storefront/v1/search/products searches the store's live products. It's what the search on Puddle websites uses, and it's the endpoint to use for search pages, search-as-you-type and filtered product listings on a headless storefront.

Search is typo-tolerant ("rooibso" finds Rooibos) and matches prefixes ("te" finds Tea), so it suits searching as the shopper types. Without q, it lists products with the filters and sort you give.

Calling it

Like every Storefront API route, it needs your storefront public key, and server-side callers send their storefront's host:

curl "https://api.puddle.co.za/storefront/v1/search/products?q=rooibos&tags=tea&inStock=true&facets=tags&facets=price" \
  -H "Authorization: Bearer <storefront-public-key>" \
  -H "x-puddle-storefront-host: shop.example.com"

With the SDK (@puddle/storefront 1.4.0 or later):

const { data } = await storefront.search.products({
  q: "rooibos",
  tags: ["tea"],
  inStock: "true",
  facets: ["tags", "price"],
  throwOnError: true,
});

Parameters

All parameters are optional. Repeat a parameter to pass more than one value (tags=tea&tags=gifts).

ParameterMeaning
qSearch text, up to 200 characters. Leave it out to browse.
collectionA collection's slug: only its products, including its sub-collections'.
tagsProducts with any of these tags.
typephysical, digital or gift_card.
priceMin, priceMaxPrice range in cents, on the price after automatic promotions.
inStocktrue leaves out products that are out of stock.
onSaletrue returns only products an automatic promotion discounts.
optionsOption values as Name=Value, e.g. Colour=Red. Products must have every one.
sortRELEVANCE, TRENDING, PRICE_ASC, PRICE_DESC, NAME_ASC, NAME_DESC, NEWEST or OLDEST. Defaults to RELEVANCE with q, otherwise the collection's default sort, otherwise TRENDING.
page, perPagePage number from 1 (up to 100) and page size (up to 100, default 24).
facetsCounts to return: tags, type, price, options, inStock, onSale.

Response

{
  "hits": [{ "id": "…", "name": "Classic Rooibos Tea", "slug": "classic-rooibos-tea", "price": 4900, "promotionPreview": null, "stockStatus": "IN_STOCK", "primaryImageUrl": "…" }],
  "facets": { "tags": [{ "value": "tea", "count": 8 }] },
  "priceRange": { "min": 3500, "max": 64900 },
  "page": 1,
  "perPage": 24,
  "total": 8
}
  • hits are the same product summaries as /products/infinite and collection listings, so existing product cards work unchanged. Prices, stock and promotions in them are always current.
  • facets holds the facets you asked for, most common first, up to 50 values each. They count the products matching the whole query, so use them to show how many results each filter would leave. options values are Name=Value; inStock and onSale values are "true" and "false".
  • priceRange is the lowest and highest price after promotions, when you ask for the price facet and something matches. Use it to set up a price slider.
  • total counts matches across all pages.

Limits

Each visitor can make 120 searches a minute per store. Past that, the API answers 429 Too Many Requests with a Retry-After header. For search-as-you-type, wait until the shopper pauses (around 150–250 ms) and cancel the previous request when a new one starts.

The limit counts per visitor IP. Calls from your own server all share your server's IP, so call search from the browser where you can, and cache results you fetch on the server.

Moving from /products/search

/products/search returns every product so you can filter in the browser. It still works, but /search/products does the work on the server: ranking, typo tolerance, filters and pages, without downloading the catalogue.

On this page