API overview
The HardBasis API is a sats-native perpetual-futures API built for algorithmic and AI-agent traders: an agent can sign up, fund, trade, and withdraw over one Bitcoin rail with no human in the loop. This section documents the public surface.
Start with the Quickstart: the zero-human-step loop, end to end, copy-pasteable. Then the REST reference (generated from the spec) and the WebSocket protocol.
Using an agent? See Agents: the hardbasis CLI and MCP server.
Environments
Testnet is the only public environment today; production is gated. Test sats have no value.
| Environment | Base URL |
|---|---|
| Testnet | https://testnet.hardbasis.com |
| Local dev | http://localhost:8787 |
Do not hardcode the environment from the hostname. GET /deployment returns {"deployment":"testnet"} or {"deployment":"prod"}. Use it to drive any "this is testnet, funds have no value" banner your client shows.
Machine-readable spec
The API is generated from typed contracts, and so is this reference. The canonical machine-readable description is served at /openapi.json (OpenAPI 3.1): point an SDK generator or a try-it tool at that URL. An llms.txt index (and a full-text llms-full.txt) is served for agents. Every operation in the spec carries x-hardbasis-effect: read (a GET), quote (computes a price and changes nothing), write (changes orders or account state), credential (mints or revokes a key), or funds (moves sats in or out).
Every operation that takes an Idempotency-Key also carries x-hardbasis-idempotency-key, which says what the key must be: order-id (the client order id; it becomes the order's id: POST /v1/orders), quote-id (the body's quoteId, any other value is refused: usdhb.mint, usdhb.redeem), or any (any fresh unique key: everything else, withdrawals included). A quote that expires carries x-hardbasis-quote-ttl-ms, naming the response field with its expiry (expiresAtMs on usdhb.quote), and a write that accepts one carries x-hardbasis-consumes-quote with the quote's operationId.
The public-surface promise
Everything here describes the public API: the /v1/* account and market endpoints, plus /healthz and /deployment. Admin and operational surfaces are not part of this reference and are not reachable from it; the reference is generated from the public spec alone, enforced by test.
Money is never a JS number
Every monetary value (balances, prices, funding rates, timestamps, contract counts) crosses the wire as a decimal string, never a JSON number, because a double cannot hold a satoshi-precise integer. Read Wire encoding before you parse anything: it is the one thing a client must get right.