Nectar docs

These docs cover the Nectar terminal and the public API. If you're integrating prediction-market data, you're in the right place.

Quickstart

Terminalbash
git clone https://github.com/hyve-network/nectar-terminal
cd nectar-terminal
npm install
node server.js
# API: http://localhost:8787

# Frontend (Next.js), in a second terminal:
cd apps/web && npm install && npm run dev
# http://localhost:3000

The backend is a single Node.js server with three npm dependencies (pg and the @noble crypto libraries). The frontend is Next.js.

Endpoints

  • /api/polymarket/marketsLive Polymarket markets, normalized
  • /api/kalshi/marketsLive Kalshi markets, normalized
  • /api/arb/stateCurrent arb engine state: opportunities, monitored books, candidates (full detail on paid plans)
  • /api/smart/stateRecent smart-money fills of $5K and up
  • /api/whales/clustersWhale wallet clustering (Pro+ required)
  • /api/ai/briefAI market brief: POST market data, get an analyst summary (Pro+ required)
  • /api/trader/profilePublic trader profile by 0x address
  • /api/billing/checkoutPOST { tier } returns a Mollie checkout URL (card / iDEAL; crypto via /api/billing/crypto/*)
  • /api/billing/webhookMollie webhook: a paid payment upgrades the account tier
  • /api/stream/arbSSE: new arb opportunities, scan ticks
  • /api/stream/smartSSE: new smart-money fills

Auth (SIWE)

Clienttypescript
import { SiweMessage } from 'siwe';
import { signMessage } from 'wagmi/actions';

const nonce = await fetch('/api/auth/nonce').then(r => r.text());
const msg = new SiweMessage({
  domain: window.location.host,
  address: walletAddress,
  uri: window.location.origin,
  version: '1', chainId: 137, nonce,
});
const signature = await signMessage({ message: msg.prepareMessage() });
await fetch('/api/auth/wallet', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ message: msg, signature }),
});

Auth (email)

Email accounts sign in with a password or with a single-use link. Both set the same session cookie. The link request answers { ok: true } whether or not the address has an account; the link expires after 15 minutes and stops working once used, or when the account's sessions are reset.

Email sign-inhttp
POST /api/auth/signup                    { email, password }  -> session
POST /api/auth/signin                    { email, password }  -> session
POST /api/auth/email/login-link          { email, next? }     -> emails a link
POST /api/auth/email/login-link/consume  { token }            -> session
POST /api/auth/password/reset-request    { email }            -> emails a reset link
POST /api/auth/password/reset-confirm    { token, password }  -> session

Webhook alerts

Alert webhooks are POSTed as JSON. When you set a webhook secret, every delivery carries X-Nectar-Timestamp (epoch milliseconds) and X-Nectar-Signature: v1=…, an HMAC-SHA256 over the timestamp, a dot and the raw body. Verify it against the exact bytes you received and reject deliveries older than five minutes, so a captured request can't be replayed.

Receiver (Node)javascript
import crypto from 'node:crypto';

function verifyNectar(req, rawBody, secret) {
  const ts = req.headers['x-nectar-timestamp'];
  const sig = req.headers['x-nectar-signature'] || '';
  if (!ts || Math.abs(Date.now() - Number(ts)) > 5 * 60 * 1000) return false;
  const want = 'v1=' + crypto.createHmac('sha256', secret).update(ts + '.' + rawBody).digest('hex');
  return sig.length === want.length && crypto.timingSafeEqual(Buffer.from(sig), Buffer.from(want));
}

Real-time SSE

Browsertypescript
const es = new EventSource('/api/stream/arb');
es.addEventListener('opportunity', (e) => {
  const opp = JSON.parse(e.data);
  console.log('new arb', opp.spreadPct, opp.title);
});

Rate limits

A shared fair-use limit of 240 requests / minute per IP applies to all tiers today. Sensitive actions have their own per-user caps (order execution and trades 30/min, withdrawals 10/min, AI briefs and alert tests throttled). Exceeding a limit returns 429; back off and retry. Per-tier API quotas arrive with the Power API tier.