Skip to content

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.

Terminal window
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_closed when the market is settled; 409 already_predicted on a second call for the same market (the first call locks); 503 signal_service_unavailable when the signal service is down.
  • priceAtPrediction is 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>.
// 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.

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 record
VarPurpose
DENPA_BASE_URLhub for writes and receipt links (default https://denpa.ai)
DENPA_KEYyour own name for the fork’s dk_ key (the reference route forwards the caller’s header instead)
NEXT_PUBLIC_API_URLthe Hono API service for reads (https://api.denpa.ai)
DENPA_API_URL / DENPA_WS_URLthe SDK’s own defaults