Skip to main content

API reference

Epic exposes seven programmable surfaces across three pieces of software. Which one you want depends on whether you need chain data or key operations.

At a glance

SurfaceWhereProtocolDefault portCan spend
Node /v1/*nodeREST, chain reads and administration3413No
Node /v2/ownernodeJSON-RPC 2.0, node administration3413No
Node /v2/foreignnodeJSON-RPC 2.0, chain reads and tx submission3413No
Wallet Owner /v3/ownerwalletJSON-RPC 2.0, encrypted3420Yes
Wallet Owner /v2/ownerwalletJSON-RPC 2.0, unencrypted3420Yes
Wallet Foreign /v2/foreignwalletJSON-RPC 2.03415No
Epicbox relayrelayWebSocket over TLS443No

Documented against node 4.0.3 and wallet 4.0.0.

The node serves /v1 and /v2 from one listener on one port, as two interface styles rather than two generations. Both are live and that page maps every v1 route onto its JSON-RPC method.

The wallet serves its two owner surfaces from one listener too, and the unencrypted /v2/owner is the older of the pair.

Choosing a surface

Reading chain data. JSON-RPC on the node: /v2/foreign for blocks, kernels and outputs, /v2/owner for node status and peers. No keys involved. Start at node queries.

Anything involving balances, keys or transfers. Wallet Owner API. It requires an ECDH handshake and a wallet token, which is covered step by step in connect and read.

Receiving a payment. Running epic-wallet listen handles this automatically via the epicbox protocol or HTTP. To process a slate programmatically, the Foreign API method is receive_tx.

Operating relay infrastructure. The epicbox protocol.

The response envelope

Every Epic JSON-RPC method returns HTTP 200 with a JSON-RPC result, and inside that result is a second Ok or Err envelope. A request can succeed at both the HTTP and JSON-RPC layers and still have failed:

{"id": 1, "jsonrpc": "2.0", "result": {"Ok": {"...": "data"}}}
{"id": 1, "jsonrpc": "2.0", "result": {"Err": {"NotEnoughFunds": {"available": 0}}}}

One function unwraps both layers. _unwrap in examples/python/epic_wallet.py raises on Err and returns the value on Ok, and every call in that client goes through it.

Amounts

Every amount is an integer count of freemans, and 1 EPIC is 100,000,000 of them. The wallet Owner API serialises its u64 fields as JSON strings, so retrieve_summary_info returns total and every amount_ field as a string, and node_height returns height as one. Parse before doing arithmetic. The node's JSON-RPC returns bare integers, including supply and max_supply on get_status.

Next