Back

Documentation

Everything you need to connect to the Grocery Intelligence Index — via API or CLI.

Base URL: https://api.supermarketpuzzle.com/v1CLI: npx supermarket-puzzle-cliFeedback & Roadmap

Quick Start

Register to get a gii_ API key, then include it in every request.

1. Register
curl -X POST https://api.supermarketpuzzle.com/v1/register \
  -H "Content-Type: application/json" \
  -d '{ "name": "MyAgent", "description": "Meal planning assistant" }'

# Response:
# { "ok": true, "data": { "agent_id": "...", "api_key": "gii_..." } }
2. Search
curl -X POST https://api.supermarketpuzzle.com/v1/products/search \
  -H "Authorization: Bearer gii_..." \
  -H "Content-Type: application/json" \
  -d '{
    "query": "high protein greek yogurt without seed oils",
    "filters": { "has_seed_oils": false, "high_protein": true },
    "limit": 5
  }'

Or use the CLI: npx supermarket-puzzle-cli register --name "MyAgent" --description "..."

For the full agent workflow, read the skill file.

Endpoints

All endpoints require Authorization: Bearer gii_... except /register.

POST/register
GET/me
POST/products/searchsearch credit
POST/products/filter
GET/products/{id}
GET/flags
GET/collections
GET/collections/{slug}search credit
GET/stores
GET/stores/{tag}
GET/brands
GET/brands/{slug}
POST/feedback

Semantic product search. Natural language query embedded via OpenAI, matched against 18,000+ products in Pinecone. Costs one search credit.

Request
{
  "query": "keto snacks for road trips under $5",
  "filters": {
    "keto_friendly": true,
    "maxPrice": 5
  },
  "limit": 10
}

Parameters

querystringRequired. Natural language description of what you want.
filtersobjectOptional. Any combination of the 27 flags, store_tag, price range.
limitnumberOptional. 1–50, default 20.

Response (each result)

Each result includes score (0–1 relevance),id, and a product object with: brand, product_name, price, size_oz, store_tag, nova_score, reason, subcategory, ingredients, narrative_card, occasions, emotional_tags, image_url, and all 27 knowledge graph flags as booleans.

POST /products/filter

Pure metadata filter. No embedding call — faster and cheaper. Does not count as a search credit.

Request
{
  "filters": {
    "vegan": true,
    "has_seed_oils": false,
    "store_tag": "wholefoods"
  },
  "limit": 20
}

At least one filter is required. Returns the same product shape as search but without a semantic relevance score.

GET /products/{id}

Full product record by ID. Returns everything: nutrition panel with %DV, tokenized ingredients, flagged ingredients with typed categories and reasons, NOVA score with reasoning, all dietary flags, narrative card, occasions, vibes, price, store, size, and image URL.

Example
curl https://api.supermarketpuzzle.com/v1/products/abc123 \
  -H "Authorization: Bearer gii_..."

GET /flags — Available Filters

Returns all 27 knowledge graph flags grouped by category. Use this to discover what filters exist before building queries.

diet

veganContains no animal products
vegetarianContains no meat
gluten_freeContains no gluten
dairy_freeContains no dairy
keto_friendlyLow carb, high fat compatible
organic_certifiedUSDA organic certified
plant_basedPrimarily plant-derived ingredients
minimally_processedNOVA 1-2 classification

ingredient

has_seed_oilsContains canola, soybean, sunflower, or other seed oils
has_canola_oilContains canola oil specifically
has_artificial_dyesContains Red 40, Yellow 5, or other artificial colors
has_added_sugarsContains added sugars beyond natural content
has_high_fructose_corn_syrupContains HFCS
has_artificial_sweetenersContains aspartame, sucralose, or similar
has_preservativesContains BHT, BHA, TBHQ, or similar preservatives
has_emulsifiersContains polysorbate, carrageenan, or similar emulsifiers
has_whole_grainsContains whole grain ingredients

nutrient

high_protein10g+ protein per serving
high_fiber5g+ fiber per serving
high_sugarHigh sugar content
low_sugarLess than 5g sugar per serving
high_sodiumHigh sodium content
low_sodiumLess than 140mg sodium per serving
low_calorieUnder 150 calories per serving
calorie_denseHigh calorie density

Additional Filters

store_tagstringwholefoods, traderjoes, foodtown
subcategorystringProduct subcategory
functional_groupstringFunctional product group
minPricenumberMinimum price
maxPricenumberMaximum price

Collections

GET /collections

Returns all 98 collections with slug, title, description, type, category, and related_collections.

GET /collections/{slug}

Runs the collection's semantic query against the index and returns live product results. Costs one search credit.

Example
curl https://api.supermarketpuzzle.com/v1/collections/snacks-without-seed-oils \
  -H "Authorization: Bearer gii_..."

Categories include: Diets (keto, paleo, Mediterranean), Avoidance (seed oils, HFCS, artificial dyes), Processing (NOVA 1–2, clean label), Nutrition (high protein, high fiber, low sugar), Product types (chips, bars, frozen meals), Life stages (kids, toddler), Occasions (camping, BBQ, game day).

Browse — Stores & Brands

GET /stores

Lists stores: Whole Foods, Trader Joe's, Foodtown.

GET /stores/{tag}

Categories at a store. Tags: wholefoods, traderjoes, foodtown.

GET /brands

All brands in the index with slugs.

GET /brands/{slug}

All products for a specific brand.

POST /feedback — Report Issues

When something doesn't work, report it. Feedback directly drives what gets built next. All reports are visible at /iterate.

Request
{
  "type": "bug",
  "message": "Search for 'organic milk' returns 0 results, but filtering with dairy_free=false finds milk products.",
  "endpoint": "/v1/products/search",
  "request_body": { "query": "organic milk", "limit": 10 },
  "response_body": { "results": [], "count": 0 },
  "severity": "high",
  "context": "User was building a weekly grocery list"
}

Fields

typestringRequired. bug feature_request confusion data_quality rate_limit other
messagestringRequired. Be verbose — what happened, what you expected, why it matters. Max 5000 chars.
endpointstringOptional. Which route you hit.
request_bodyobjectOptional. What you sent.
response_bodyobjectOptional. What you got back.
contextstringOptional. What the user was trying to do.
severitystringOptional. low medium high critical. Default: medium.

Response Format

Every response uses this envelope:

Success
{
  "ok": true,
  "data": { ... },
  "meta": {
    "request_id": "req_a1b2c3d4",
    "latency_ms": 142,
    "rate_limit": { "remaining": 58, "reset": 1711234567 }
  }
}
Error
{
  "ok": false,
  "error": {
    "code": "rate_limited",
    "message": "Rate limit exceeded. Try again in 12 seconds.",
    "retry_after": 12
  }
}

Error codes: unauthorized, invalid_request, rate_limited, not_found, internal_error.

Rate Limits

Free tier: 60 requests/minute, 10,000 searches/month.

Search credits: Only /products/search and /collections/{slug} count as searches (they make embedding calls). Everything else counts toward the per-minute request limit only.

Headers: Every response includes X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset.

429 responses include retry_after in seconds. Respect it.

Check usage: GET /me returns your total requests and searches.

CLI — supermarket-puzzle-cli

Command-line interface that mirrors the full API surface. Install globally or run via npx.

Install
npm install -g supermarket-puzzle-cli

# or run without installing:
npx supermarket-puzzle-cli search "organic snacks"

Commands

supermarket-puzzle register --name "MealBot" --description "Meal planning agent"

Register an agent and save the API key locally

supermarket-puzzle search "high protein greek yogurt" --store wholefoods --limit 5

Semantic search with optional store filter and result limit

supermarket-puzzle filter --vegan --no-seed-oils --store traderjoes --limit 20

Filter by flags (no embedding cost)

supermarket-puzzle product <product-id>

Get full product detail including nutrition, ingredients, NOVA score

supermarket-puzzle collections

List all 98 curated collections

supermarket-puzzle collection keto-friendly-options

Get a collection with live product results

supermarket-puzzle stores

List all stores (Whole Foods, Trader Joe's, Foodtown)

supermarket-puzzle brands

List all brands in the index

supermarket-puzzle flags

List all 27 filter flags with descriptions

supermarket-puzzle whoami

Show your agent info and usage stats

Global Flags

--jsonOutput raw API JSON (useful for piping to other tools)
--api-key <key>Override the stored API key for this request

Filter Flags

The filter command accepts these flags:

--vegan--gluten-free--dairy-free--keto--organic--no-seed-oils--no-hfcs--no-artificial-dyes--no-artificial-sweeteners--high-protein--high-fiber--low-sugar--low-sodium--low-calorie--store <tag>--limit <n>

Config

After register, your API key is saved to ~/.config/supermarket-puzzle-cli/config.json. You can also pass --api-key on any command to override it.