Build
API reference
Read HALFKEY from any backend: pairs, limits, indicative quotes, swap status, makers and totals, straight from chain. No key needed.
Overview
A read-only HTTP API over the HALFKEY program. Every number comes from chain (the program's config, the maker registry, the escrow accounts) or from a maker's own /v1/info. Responses are JSON. Amounts are decimal strings in whole coins, exact to the coin's decimals. Times are unix seconds.
| Base URL | https://halfkey.xyz/api/v1 |
| Format | JSON, UTF-8. CORS open (*) for every read. |
| Versioning | The path carries the version. Fields are only added within v1, never renamed or removed. |
| Description | OpenAPI 3.1 document |
firm: false. The firm, signed quote comes from the maker at lock time, through the widget or the SDK, and the program checks the maker's signature over it.Authentication
None for reads. Integrator keys arrive with the order API (next): they carry an integrator fee share, paid on chain at settlement, and a budget for unfunded orders.
Currencies
GET/api/v1/currencies
Currencies, pairs, and which pairs this gateway quotes. Any Solana coin can be the input: the widget and the SDK route it through Jupiter into SOL in the same transaction as the lock, so the gateway quotes the SOL leg and you add the Jupiter quote for the coin on your side.
curl
curl -s 'https://halfkey.xyz/api/v1/currencies'
JavaScript
const r = await fetch('https://halfkey.xyz/api/v1/currencies');
const { currencies, pairs, spl_input } = await r.json();
Example response
{
"network": {
"cluster": "mainnet-beta",
"program_id": "9BbjkoRkb9K4tFjZJsUEVkikRNYWC9wpLtqD3rmicCr6",
"monero_network": "mainnet",
"zec_network": "mainnet"
},
"currencies": [
{
"ticker": "SOL",
"name": "Solana",
"network": "solana",
"decimals": 9,
"address": "Solana address (base58)"
},
{
"ticker": "XMR",
"name": "Monero",
"network": "monero",
"decimals": 12,
"address": "Monero mainnet address (standard or subaddress)"
},
{
"ticker": "ZEC",
"name": "ZEC",
"network": "zec",
"decimals": 8,
"address": "transparent t-address; shield it in your wallet",
"status": "test networks"
}
],
"pairs": [
{
"from": "SOL",
"to": "XMR",
"gateway_quote": true,
"status": "live"
},
{
"from": "XMR",
"to": "SOL",
"gateway_quote": true,
"status": "live"
},
{
"from": "SOL",
"to": "ZEC",
"gateway_quote": false,
"status": "test networks",
"quoted_by": "the maker ZEC desk, through the widget or the SDK"
},
{
"from": "ZEC",
"to": "SOL",
"gateway_quote": false,
"status": "test networks",
"quoted_by": "the maker ZEC desk, through the widget or the SDK"
}
],
"spl_input": {
"supported": true,
"route": "jupiter",
"where": "client",
"note": "Any Solana coin can be the input: the widget and the SDK route it through Jupiter into SOL in the same transaction as the lock. This gateway quotes the SOL leg; add the Jupiter quote for the coin to SOL on your side."
}
}
Limits
GET/api/v1/limits
Smallest and largest amount you can send now, in the from currency. The max is the lowest of the program's per-swap cap, the headroom under its cap on open value, and the best online maker's own max. sol_leg gives the same bounds in SOL.
| Parameter | In | Required | Meaning |
|---|---|---|---|
from | query | yes | SOL or XMR |
to | query | yes | XMR or SOL |
curl
curl -s 'https://halfkey.xyz/api/v1/limits?from=SOL&to=XMR'
JavaScript
const r = await fetch('https://halfkey.xyz/api/v1/limits?from=SOL&to=XMR');
if (!r.ok) throw new Error((await r.json()).message);
const { min, max, available } = await r.json();
Example response
{
"from": "SOL",
"to": "XMR",
"currency": "SOL",
"min": "0.01",
"max": "5",
"available": true,
"sol_leg": {
"min_sol": "0.01",
"max_sol": "5"
},
"protocol": {
"max_swap_sol": "5",
"open_value_cap_sol": "100",
"open_value_sol": "3.4",
"headroom_sol": "96.6",
"paused": false
},
"maker": {
"authority": "9hY85VUcpmX2459PgXVHCRk4yKPk7FcyiNrLNUXPxiaV",
"endpoint_host": "maker.example",
"spread_percent": 0.8,
"completed": 4,
"completion_rate": 0.1818
},
"makers_online": 4,
"updated_at": 1793850194
}
Quote
GET/api/v1/quote
An indicative quote from the best online maker for this size: the amount out after the maker's spread and the protocol fee, the rate, the fee split, the typical time, and the maker. Pass exactly one of amount_from or amount_to. Valid for 60 seconds as a guide; the price you sign comes from the maker.
| Parameter | In | Required | Meaning |
|---|---|---|---|
from | query | yes | SOL or XMR |
to | query | yes | XMR or SOL |
amount_from | query | no | Amount you send, decimal |
amount_to | query | no | Amount you want to receive, decimal |
curl
curl -s 'https://halfkey.xyz/api/v1/quote?from=SOL&to=XMR&amount_from=1'
JavaScript
const q = new URLSearchParams({ from: 'SOL', to: 'XMR', amount_from: '1' });
const r = await fetch('https://halfkey.xyz/api/v1/quote?' + q);
const quote = await r.json();
// quote.firm === false: sign the maker's firm quote in the widget or SDK
Example response
{
"firm": false,
"quote_id": null,
"from": "SOL",
"to": "XMR",
"amount_from": "1",
"amount_to": "0.149832671999",
"rate": 0.14983267,
"maker_mid_rate_xmr_per_sol": 0.1518,
"fees": {
"protocol_fee_percent": 0.5,
"spread_percent": 0.8,
"total_percent": 1.3,
"protocol_fee": {
"amount": "0.005",
"currency": "SOL"
},
"network": "Solana and Monero network fees are separate and small."
},
"sol_leg_sol": "1",
"eta_secs": 120,
"spendable_secs": 1200,
"quote_expires_at": 1793850254,
"maker": {
"authority": "9hY85VUcpmX2459PgXVHCRk4yKPk7FcyiNrLNUXPxiaV",
"endpoint_host": "maker.example",
"spread_percent": 0.8,
"completed": 4,
"completion_rate": 0.1818
},
"note": "Indicative. The firm, signed quote comes from the maker at lock time through the widget or the SDK; the program checks the maker signature over it."
}
eta_secs is the typical time until the coins are on their way; spendable_secs includes Monero's 10-block lock for XMR. Solana and Monero network fees are separate.
Swap status
GET/api/v1/status/{id}
One swap, by its escrow account address: the raw on-chain state, the mapped status, amounts, maker, the times (t0 closes the ready and cancel window, t1 opens the refund), and explorer links. proof is always null on mainnet, where every claim needs a ready. Works for XMR escrows and ZEC hash-locked escrows.
| Parameter | In | Required | Meaning |
|---|---|---|---|
id | path | yes | Escrow account address (base58) |
curl
curl -s 'https://halfkey.xyz/api/v1/status/ESCROW_ADDRESS'
JavaScript
const r = await fetch('https://halfkey.xyz/api/v1/status/' + escrowAddress);
const { status, status_detail } = await r.json();
Example response
{
"id": "4XTJEkn2mfdpe65u8GL2DLrs6ng2PGg8ak4qHzGPiMs4",
"kind": "escrow",
"from": "SOL",
"to": "XMR",
"state": "claimed",
"status": "COMPLETE",
"status_detail": "The maker claimed the SOL. That claim published its key half, so the XMR is the taker's.",
"amounts": {
"sol": "0.5",
"xmr": "0.000123456789"
},
"protocol_fee_percent": 0.5,
"maker": "9hY85VUcpmX2459PgXVHCRk4yKPk7FcyiNrLNUXPxiaV",
"locker": "6Z9VEDfeWdURdsKJLKHfvWuzJ97PtBViKW2bwLmd4GaL",
"claimer": "9hY85VUcpmX2459PgXVHCRk4yKPk7FcyiNrLNUXPxiaV",
"flags": [],
"times": {
"created_at": 1793849338,
"t0": 1793849339,
"t1": 1793849369,
"settled_at": 1793849342,
"chain_now": 1793849699
},
"secret_published": true,
"proof": null,
"explorer": {
"account": "https://solscan.io/account/4XTJEkn2mfdpe65u8GL2DLrs6ng2PGg8ak4qHzGPiMs4"
}
}
Makers
GET/api/v1/makers
The on-chain maker registry: bond, spread, size range, directions and the counters the program keeps (completed, aborted, declined, expired), plus a live check. online means the maker answered /v1/info for this program with its own identity in the last 30 seconds. completion_rate is completed over completed + aborted + declined + expired, and null before the first settled swap.
curl
curl -s 'https://halfkey.xyz/api/v1/makers'
JavaScript
const { makers, online } = await (await fetch('https://halfkey.xyz/api/v1/makers')).json();
Example response
{
"network": {
"cluster": "mainnet-beta",
"program_id": "9BbjkoRkb9K4tFjZJsUEVkikRNYWC9wpLtqD3rmicCr6",
"monero_network": "mainnet",
"zec_network": "mainnet"
},
"registered": 4,
"active": 4,
"online": 4,
"makers": [
{
"authority": "9hY85VUcpmX2459PgXVHCRk4yKPk7FcyiNrLNUXPxiaV",
"address": "A1ziEAkdQ3iodn366CmHHmnrUPtQnGdyBrNxKgE3Q8VK",
"active": true,
"online": true,
"directions": [
"SOL->XMR",
"XMR->SOL"
],
"spread_percent": 0.8,
"min_sol": "0.01",
"max_sol": "5",
"bond_sol": "3",
"staked_halfkey": "0",
"completed": 4,
"aborted": 3,
"declined": 6,
"expired": 9,
"cancelled": 3,
"volume_sol": "2",
"completion_rate": 0.1818,
"open_swaps": 1,
"endpoint_host": "maker.example",
"rate_xmr_per_sol": 0.1518,
"posted_rate": null,
"registered_at": 1793849217
}
],
"updated_at": 1793850195
}
One of four makers shown.
Stats
GET/api/v1/stats
Protocol totals from the config account: swaps, volume and fees; open value and the caps; the fee vault and the burn auction; the $HALFKEY staking pool; and makers registered and online. committee is null on mainnet: no Monero header signers exist there, and every claim needs a ready. On a network without the program, program.deployed is false and the rest is absent.
curl
curl -s 'https://halfkey.xyz/api/v1/stats'
JavaScript
const s = await (await fetch('https://halfkey.xyz/api/v1/stats')).json();
console.log(s.swaps.total, s.makers?.online);
Example response
{
"network": {
"cluster": "mainnet-beta",
"program_id": "9BbjkoRkb9K4tFjZJsUEVkikRNYWC9wpLtqD3rmicCr6",
"monero_network": "mainnet",
"zec_network": "mainnet"
},
"program": {
"deployed": true,
"initialized": true,
"paused": false
},
"swaps": {
"total": 11,
"volume_sol": "17.05",
"fees_sol": "0.08525"
},
"open_value_sol": "3.4",
"caps": {
"max_swap_sol": "5",
"open_value_cap_sol": "100"
},
"fees": {
"protocol_fee_percent": 0.5,
"holder_fee_percent": 0.25
},
"fee_vault": {
"balance_sol": "0.07614088",
"burn_auction": null
},
"staking": {
"total_staked_halfkey": "0",
"distributed_sol": "0",
"claimed_sol": "0",
"pool_balance_sol": "0.00155904"
},
"makers": {
"registered": 4,
"active": 4,
"online": 4
},
"committee": null,
"updated_at": 1793849692
}
OpenAPI
The full description, including the order endpoints, is at /api/v1/openapi.json (OpenAPI 3.1). Generate a client from it, or load it into any OpenAPI viewer.
Rate limits
Per IP, fixed one-minute windows. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (seconds until the window resets). Over the limit you get 429 with Retry-After.
| Endpoints | Limit | Cached for |
|---|---|---|
/quote | 10 per minute | 5 s |
/limits | 60 per minute (shared with other reads) | 10 s |
/status/{id} | 60 per minute (shared) | 5 s |
/makers, /stats | 60 per minute (shared) | 20 s, 15 s |
/currencies, /openapi.json | 60 per minute (shared) | 5 min, 1 h |
Need more for a production integration? Tell us what you are building.
Errors
Every error has the same shape: { "error": code, "message": text }, sometimes with extra fields (min_sol, problems, retry_after_secs). Switch on error, show message.
{
"error": "amount_out_of_range",
"message": "No online maker takes this size. The SOL leg must be between 0.01 and 5 SOL.",
"min_sol": "0.01",
"max_sol": "5"
}
| Code | HTTP | Meaning | What to do |
|---|---|---|---|
missing_parameter | 400 | A required parameter is absent (from, to, or the amount). | Add it; see the endpoint's table. |
unsupported_pair | 400 | The pair is not a HALFKEY pair. | Use a pair from /currencies. |
pair_not_quoted | 400 | SOL and ZEC pairs are quoted by the maker's ZEC desk, not by the gateway. | Quote them in the widget or the SDK. |
invalid_amount | 400 | Not a positive decimal, or too many decimal places. | SOL takes 9 places, XMR 12, ZEC 8. |
invalid_id | 400 | The status id is not a Solana address. | Pass the escrow account address. |
invalid_order | 400 | Order body failed validation; every problem is listed in problems. | Fix the listed fields. |
not_found | 404 | No escrow at this address, or no such endpoint. Closed escrows leave the chain. | Check the address and the network. |
order_not_found | 404 | No order with this id. | Orders exist only once deposit mode is live. |
method_not_allowed | 405 | Wrong HTTP method. | Read endpoints take GET. |
amount_out_of_range | 422 | No online maker takes this size; min_sol and max_sol give the range. | Call /limits and stay inside it. |
rate_limited | 429 | Too many requests from your IP in this window. | Wait Retry-After seconds. |
order_api_not_enabled | 501 | Deposit-address orders are off on this network (the default). | Use the widget or the SDK today. |
deposit_mode_unavailable | 501 | A valid order on a network whose program has no deposit mode yet. Nothing was created. | Wait for the program round that adds it. |
upstream_unavailable | 502 | The Solana RPC behind the gateway did not answer. | Retry with backoff. |
no_liquidity | 503 | No maker is online for this direction right now. | Retry later; /makers shows who is online. |
paused | 503 | New swaps are paused on this network. Open swaps still settle or refund. | Retry later. |
not_deployed | 503 | The program or its config is not on this network. | Check the network in /stats. |
internal | 500 | Something failed on our side. | Retry; tell us if it persists. |
Status mapping
One vocabulary for swaps read from chain (/status) and for orders (next). The aggregator columns show where each HALFKEY status lands in the status names Trocador returns and in Cake Wallet's TradeState (the raw names in cake_wallet/lib/exchange/trade_state.dart). Every swap ends in COMPLETE or REFUNDED, or EXPIRED when nothing arrived; nothing in between can hold funds forever.
| HALFKEY | Meaning | Trocador | Cake TradeState |
|---|---|---|---|
AWAITING_DEPOSIT | Waiting for your coins (an order), or for your XMR after the maker locked SOL (XMR to SOL). | waiting | waiting, created, pending |
DEPOSIT_DETECTED | The deposit is seen and confirming. | confirming | confirming |
LOCKED | Your SOL is locked in the program; the maker is locking XMR to the shared address. | sending | exchanging |
SENDING | The other side is on its way: XMR confirmations (n/10), or the SOL claim is open. | sending | sending |
COMPLETE | Done. The claim published the key half; the coins are yours. | finished | finished, complete |
REFUNDING | Cancelled, or the claim window closed. A refund is open to the refund address. | failed | refund |
REFUNDED | Your coins went back to the refund address. | refunded | refunded |
EXPIRED | Nothing arrived before the deposit deadline. No funds were moved. | expired | expired, TIMED_OUT |
UNDERPAID | Order only: less than the quoted amount arrived. Resolved by the refund rules: it ends as REFUNDED. | failed | UNDERPAID |
OVERPAID | Order only: more than the quoted amount arrived. The swap fills; the excess goes to the refund address. | confirming | confirming |
From chain, the mapping reads the escrow: locked before t0 is LOCKED (SOL to XMR) or AWAITING_DEPOSIT (XMR to SOL); released, or past t0, is SENDING; claimed is COMPLETE; aborted, or past t1 unclaimed, is REFUNDING; refunded is REFUNDED. The gateway does not watch Monero, so confirmation counts appear only on orders.
Orders (next)
501 order_api_not_enabled. Deposit-address mode needs a program change that is not deployed yet; the gateway validates requests in full but never creates an order the chain cannot back.Deposit-address mode is for wallets, aggregators and bots whose users only "send to an address". The shape follows the provider interface Trocador and Cake already speak: quote, create with a payout and a refund address, then status by id.
- SOL to XMR: one program-controlled deposit address per order, with the refund address fixed at quote time. If no fill happens before the deadline, anyone can trigger the refund, and it pays only the refund address.
- XMR to SOL: the deposit address is the 2-of-2 Monero address; the SOL claim pays only the payout address bound in the escrow. Fixed rate only.
| Endpoint | Body | Returns |
|---|---|---|
POST /api/v1/order | quote_id, payout_address, refund_address, optional integrator {pubkey, fee_percent up to 2}, partner_ref | order_id, deposit_address, deposit amount (fixed) or min and max (float), deposit_deadline, status_url |
GET /api/v1/order/{id} | status, deposit, lock, claim and refund transactions, xmr_txid, confirmations "n/10", amounts, updated_at | |
POST /api/v1/order/{id}/deposit | tx_hash | A speed-up hint: the gateway looks for the deposit at once |
curl -s -X POST 'https://halfkey.xyz/api/v1/order' \
-H 'content-type: application/json' \
-d '{"quote_id":"q_…","payout_address":"5…","refund_address":"9…"}'
Response on this network
{
"error": "order_api_not_enabled",
"message": "Deposit-address orders are not enabled on this network. Swaps today are signed in the widget or the SDK; see /docs/api#orders.",
"docs": "/docs/api#orders"
}