API routes

Every HTTP endpoint in the app.

POST /api/scrape/run

Runs the scrape pipeline for the given sources.

{
  "platforms": ["tiktok", "instagram", "youtube"],  // default: tiktok + instagram
  "keywords": ["food", "fitness"],                  // optional, per-platform
  "trending": true                                   // optional
}
FieldTypeDescription
totalStorednumberRows upserted across all sources
totalCreditsnumberScrapeCreators credits spent
results[]arrayPer-source: items, credits, stored, top 3

POST /api/analyze

Analyzes a single video by URL. Costs 1 app credit (401 if signed out, 402 if out of credits).

{ "url": "https://www.tiktok.com/@creator/video/123…" }
FieldDescription
videoNormalized + scored video with preview_url
benchmarkAvg like/comment/share rates of DB peers
percentileWhere it ranks vs peers in your DB
peerCountHow many peers it was scored against

GET /api/cron/scrape

Daily cron entrypoint (06:00 UTC, configured in vercel.json). Re-scrapes trending + every niche present in the DB. Requires the Authorization: Bearer $CRON_SECRET header — Vercel sends it automatically for cron invocations.

GET /auth/callback

OAuth callback. Exchanges the Supabase auth code for a session and redirects to /platform.