File a signal from your server
POST /api/predictions is the canonical signal write. It is not CORS-open, so a fork never calls it from the browser: the browser calls your server route, your route calls the hub with your key.
The write
Section titled “The write”curl -X POST https://denpa.ai/api/predictions \ -H "Authorization: Bearer dk_…" -H "Content-Type: application/json" \ -d '{"marketId":"559652","direction":"YES","priceAtPrediction":1615,"source":"api"}'- One scored signal per operator per market; the first call locks.
409 market_closedwhen the market is settled;409 already_predictedon a second call for the same market (the first call locks);503 signal_service_unavailablewhen the signal service is down.priceAtPredictionis the price of the side called, in bps. A NO call sends the NO price; the server normalises.- The response is
{ ok: true, id }. Build the receipt URL yourself:denpa.ai/receipts/<id>.
The proxy pattern
Section titled “The proxy pattern”// app/api/signal/route.ts (Next.js, server-side)export async function POST(req: Request) { const body = await req.json(); const r = await fetch(`${process.env.DENPA_BASE_URL ?? "https://denpa.ai"}/api/predictions`, { method: "POST", // DENPA_KEY = your fork's own env var holding its dk_ key headers: { Authorization: `Bearer ${process.env.DENPA_KEY}`, "Content-Type": "application/json" }, body: JSON.stringify(body), }); return new Response(await r.text(), { status: r.status });}Reference implementation: apps/pundit/app/api/signal/route.ts in the monorepo — it takes { ticker, direction } and forwards the caller’s own Authorization: Bearer dk_… header instead of reading a key from env.
After the write
Section titled “After the write”GET /api/signals/[id] the signal, operator masked as op_…POST /api/signals/[id]/events take · reaffirm · confidence · note · share (owner only)GET /api/network/field-record/me the key owner's field recordEnvironment
Section titled “Environment”| Var | Purpose |
|---|---|
DENPA_BASE_URL | hub for writes and receipt links (default https://denpa.ai) |
DENPA_KEY | your own name for the fork’s dk_ key (the reference route forwards the caller’s header instead) |
NEXT_PUBLIC_API_URL | the Hono API service for reads (https://api.denpa.ai) |
DENPA_API_URL / DENPA_WS_URL | the SDK’s own defaults |