API

Recipes

Short, copyable starting points.

Post the daily special from your POS

Run it each morning. Limefizz makes the image, writes captions, and queues the post when posting is on.

special.js
const LF = process.env.LF_BASE ?? "https://www.limefizz.ai/api/v1";
const LF_KEY = process.env.LF_KEY;

async function lf(method, path, body) {
  const res = await fetch(`${LF}${path}`, {
    method,
    headers: {
      Authorization: `Bearer ${LF_KEY}`,
      "Content-Type": "application/json",
    },
    ...(body ? { body: JSON.stringify(body) } : {}),
  });
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  return res.json();
}

async function waitUntilReady(creativeId) {
  for (;;) {
    const cr = await lf("GET", `/creatives/${creativeId}`);
    if (cr.status === "ready") return cr;
    if (cr.status === "failed") throw new Error("Creative failed");
    await new Promise((r) => setTimeout(r, 3000));
  }
}

const special = await pos.todaysSpecial(); // "Spicy honey pie, $14"

const cr = await lf("POST", "/creatives", {
  brand_id: "YOUR_BRAND_ID",
  type: "image",
  prompt: special.name,
});

const ready = await waitUntilReady(cr.id);

await lf("POST", "/posts", {
  brand_id: "YOUR_BRAND_ID",
  creative_id: ready.id,
  connections: ["Instagram", "Facebook"],
});

Make a batch of posts from a product feed

feed.py
import os, time, requests

LF = os.environ.get("LF_BASE", "https://www.limefizz.ai/api/v1")
LF_KEY = os.environ["LF_KEY"]

def lf_post(path, payload):
    r = requests.post(
        f"{LF}{path}",
        headers={"Authorization": f"Bearer {LF_KEY}"},
        json=payload,
        timeout=60,
    )
    r.raise_for_status()
    return r.json()

queue = []
for product in shopify.products(collection="new"):
    cr = lf_post("/creatives", {
        "brand_id": "YOUR_BRAND_ID",
        "type": "carousel",
        "prompt": f"{product.title}: {product.short_description}",
    })
    queue.append(cr["id"])  # schedule each one when it is ready

Send what went out recently to Slack

slack.sh
curl -s "$LF/posts?status=posted&brand_id=$BRAND" \
  -H "Authorization: Bearer $LF_KEY" \
  | jq -r '.posts[] | "\(.scheduled_at // .day)  \(.caption)"' \
  | slack-post "#marketing"