Recipes

Common patterns, ready to copy-paste.

Real working snippets that we use ourselves. Drop in your sk_live_* key and go.

Search restaurants by city

Most common starting point. POST to /v1/search/restaurants with a query and optional city / state filters.

const res = await fetch(
  "https://api.souslab.site/v1/search/restaurants",
  {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.SOUSLAB_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      q: "ramen",
      city: "portland",
      state: "OR",
      limit: 10,
    }),
  },
);
const { data } = await res.json();
console.log(`${data.length} ramen spots in Portland`);
200 OK · 38 ms

Get a full menu by restaurant ID

Once you have a restaurant_id (from search or another lookup), pull the normalized menu in one call.

curl https://api.souslab.site/v1/restaurants/rst_4c1a2b/menu \
  -H "Authorization: Bearer $SOUSLAB_API_KEY" \
  | jq '.sections[] | { title: .title, items: (.items | length) }'
200 OK · 38 ms

Find restaurants serving a specific dish

POST /v1/search/items finds menu items across the corpus. Group by restaurant_id in your code to surface places.

import os, requests
from collections import Counter
r = requests.post(
    "https://api.souslab.site/v1/search/items",
    headers={"Authorization": f"Bearer {os.environ['SOUSLAB_API_KEY']}"},
    json={"q": "carbonara", "city": "san francisco"},
)
restaurants = Counter(item["restaurant_id"] for item in r.json()["data"])
for rid, count in restaurants.most_common(5):
    print(rid, count, "carbonara variants")
200 OK · 38 ms

Build a city-level price map

Combine /v1/stats/{state}/{city} across multiple cities to chart price-per-entrée by metro.

const cities = [
  ["NY", "new york"],
  ["CA", "san francisco"],
  ["IL", "chicago"],
  ["TX", "austin"],
];

const auth = { Authorization: `Bearer ${process.env.SOUSLAB_API_KEY}` };
const stats = await Promise.all(
  cities.map(async ([state, city]) => {
    const r = await fetch(
      `https://api.souslab.site/v1/stats/${state}/${encodeURIComponent(city)}`,
      { headers: auth },
    );
    return { city, ...(await r.json()) };
  }),
);

stats.sort((a, b) => a.median_price - b.median_price);
console.table(stats.map(s => ({ city: s.city, median: s.median_price })));
200 OK · 38 ms