Skip to content

API overview & authentication

The Hub’s public API is served at https://testnet-rpc.necter.network. The endpoint reference is generated from its OpenAPI specification and lists every public /v1 operation with its parameters, request bodies and responses.

Terminal window
curl -s https://testnet-rpc.necter.network/ # network descriptor: contracts, hosts, versions
curl -s https://testnet-rpc.necter.network/v1/status # validators, indexer, relay connections
  • Every response is application/json; charset=utf-8, including errors and unknown paths (JSON 404). The only binary responses are GET /v1/modules/{address}/hbc and GET /v1/assets/{sha256}.
  • Field names are snake_case. Timestamps are unix seconds and end in _at. Token amounts are decimal strings in base units (wei); token objects carry decimals. Hashes, ids and addresses are lowercase 0x hex.
  • No cookies, no redirects, no HTML.
Scheme How Used for
none public reads, /v1/execute and task submission to projects with public_tasks (rate-limited per IP), claims lookup by address
session Authorization: Bearer <token> from Sign-In with Ethereum (POST /v1/auth/nonce → sign → POST /v1/auth/siwe), 12 hours everything under /v1/me, subscriptions, developer actions
apiKey Authorization: Bearer nk_test_<id>_<secret>, scoped (tasks:submit, projects:read, projects:write, modules:write, analytics:read) backends: tasks, uploads, analytics
nodeSig signed X-Ndsr-* headers from a node key miners and validators

Walkthrough with code: Sign in and enroll.

From JavaScript or TypeScript apps, @necter/hivejs wraps module calls (Upload and call a module); install it from the HiveKit release.

Lists take ?limit=1..200 (default 50) and ?cursor=<opaque> and answer {"items": [...], "next_cursor": "…" | null}.

{"error": "invalid_field", "message": "wait must be 0..120", "details": {}, "request_id": "65416d30a053d774"}

error codes are stable; message is for humans; include request_id when you report a problem. The codes you will meet most: Troubleshooting.

Every response carries RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds); a 429 adds Retry-After. Budgets are per API key, per session wallet, per node key, and per IP for anonymous calls. The two endpoints browsers can POST to anonymously also have a ceiling across all anonymous callers:

Anonymous call Per IP All anonymous callers
POST /v1/execute 60 / min 600 / min
POST /v1/projects/{id}/tasks (projects with public_tasks) 30 / min 300 / min
any other call 600 / min

A call with an API key uses the key’s budget (1,200 per minute) instead. A refused call does not spend the shared budget. On a 429, wait Retry-After seconds; its RateLimit-* headers describe the budget that refused the call.

Web pages on any origin can call the public API directly:

  • Anonymous GET endpoints (projects, modules, explorer data, network status) answer Access-Control-Allow-Origin: *.
  • POST /v1/execute and POST /v1/projects/{id}/tasks answer Access-Control-Allow-Origin: *. Their preflight returns 204 with Access-Control-Allow-Methods: POST, GET, OPTIONS, Access-Control-Allow-Headers: Authorization, Content-Type, X-Request-Id and Access-Control-Max-Age: 600. RateLimit-*, Retry-After and X-Request-Id are exposed to scripts, and errors (including 429) are readable cross-origin. Anonymous task submission works only for projects whose manifest sets scheduling.public_tasks: true; other projects answer 401 unauthorized. Submit tasks from a browser
  • Other authenticated or state-changing endpoints (sessions, API keys, uploads, project management) accept only the Necter apps’ origins (the store at https://testnet.necter.network and the desktop app). Third-party web apps call them through their own backend.
  • Preflights are cached for 10 minutes (Access-Control-Max-Age: 600).

The API never uses cookies and never sends Access-Control-Allow-Credentials, so call it with fetch’s default credentials and never with credentials: 'include'. Responses carry Vary: Origin.

const res = await fetch('https://testnet-rpc.necter.network/v1/execute', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
module: '0x5b89b7c4f37ab4cf68f30999424ee32775d5c137d35c066e8ce9ce75563887bb',
function: 'multiply',
input: { a: 7, b: 6 },
}),
})
const out = await res.json() // { success: true, output: '{"result":42}', receipt_hash: '0x…', … }

Keep API keys and signing keys out of front-end code: anything in a page is visible to its visitors. Send calls that need a key, or that your app must vouch for, from your backend.

  • Miner relay: wss://testnet-rpc.necter.network/v1/relay, WebSocket subprotocol necter-relay.v1. It is used by the miner apps; its protocol (handshake, offers, leases, votes, acks, resume) is part of the miner.
  • Node routes (/v1/nodes/* and the legacy /api/* node paths) are for validators and are not listed in the reference.