Overview
The Swap APIs implement the atomic swap protocol used by the KaleidoSwap Desktop App. Swaps execute via Hash Time-Locked Contracts (HTLCs) on the Lightning Network — both sides lock assets simultaneously, so either the full exchange completes or funds are returned. There is no counterparty risk. To use these endpoints you need:- A running RGB Lightning Node (RLN) to whitelist and route the HTLC.
- A WebSocket connection to the maker (or the REST
/market/quoteendpoint) for live quotes andrfq_idgeneration.
https://api.signet.kaleidoswap.com/api/v1 (Signet)
Get Node Information
Endpoint
GET /api/v1/swaps/nodeinfo
Description
Retrieve the public identity of the maker’s RGB Lightning Node — its pubkey, the network it runs on, and the current block height. This endpoint is safe to poll.Response Structure
pubkey: The public key of the maker node.network: The Bitcoin network the node runs on (e.g.,Signet,Regtest,Mainnet).block_height: Current blockchain height the node is synced to.
Example Response
Real-time Quotes over WebSocket
WebSocket Endpoint
Description
Establish a WebSocket connection to request live quotes from the maker. The protocol is request/response: the client sends a message and the server replies to that message. There is no subscription mechanism — to keep a price fresh, send a newquote_request whenever you need an updated quote.
Connection
- Replace
{client_id}with a unique identifier for your client.
Message Format
Only two actions are supported:ping— heartbeat; the server replies with apong.quote_request— request a quote for a swap between two assets.
from_asset/to_asset(required): Asset identifiers — a ticker likeBTCor an RGB contract ID.from_amount/to_amount: Amount in the asset’s raw smallest unit. Provide exactly one of the two —from_amountfor a forward quote,to_amountfor a reverse quote.from_layer/to_layer(optional): Explicit settlement layers (e.g.,BTC_LN,RGB_LN). If omitted, the pair’s default route is used.
Response Format
The server replies to eachquote_request with a quote_response message carrying the full quote (the same shape as the REST POST /api/v1/market/quote response) in data:
Field Descriptions
rfq_id: Therequest_for_quotation_id, a unique identifier generated by the maker for this quote. This ID is crucial for initiating swaps and must be passed to theinitendpoint beforeexpires_at.from_asset/to_asset: Complete leg specifications withasset_id,name,ticker,layer,amount(smallest unit), andprecision.price: Price of 1 whole unit offrom_assetexpressed in the smallest unit ofto_asset.fee: Fee breakdown —base_fee,variable_fee,fee_rate,final_fee, plus the asset (fee_asset) and precision (fee_asset_precision) the fee is denominated in.timestamp: When the quote was generated (unix time).expires_at: When therfq_idexpires (unix time).
Additional Notes:
- Failed requests (unknown pair, unsupported route, invalid amounts) return a message with an
errorfield instead of aquote_response. - The WebSocket connection remains open until the client disconnects or a network error occurs; send periodic
pingmessages to keep it healthy.
Initiate Swap
Endpoint
POST /api/v1/swaps/init
Description
Initiate a swap based on a fresh quote. This endpoint locks the price and prepares the swap for execution.Request Body
*If the asset is BTC, the amount should be specified in millisatoshis (msat). For other assets, the amount should be provided in the asset’s native unit without considering precision.
Example Request
Response Structure
swapstring: A string representation of the swap to be executed.payment_hash: The payment hash associated with the swap.access_token: Per-swap token required to poll/swaps/atomic/status. It is returned only once here at initiation — store it alongside the payment hash.
Example Response
Additional Notes
- The precision for an RGB asset can be obtained using the
/assetsAPI on the maker’s node. If the client has the same asset, the precision can also be retrieved via the node API. - The swapstring returned by this endpoint needs to be whitelisted using the
/takerAPI of the RGB Lightning Node (RLN) of the client before executing the swap. - In this example, the user is selling 1,000 sats for 0.5877 USDT (using the RGB asset
rgb:2NZGjyz-pJePUgegh-RLHbpx1Hy-iZMagWiZZ-qY4AxGymW-yCEYwwB).
Execute Swap
Endpoint
POST /api/v1/swaps/execute
Description
Execute the swap after it has been initiated and validated.Request Body
Example Request
Response Structure
status: Status code of the swap execution.message: Additional details about the execution.
Example Response
Get Swap Status
Endpoint
POST /api/v1/swaps/atomic/status
Description
Retrieve the current status of an atomic swap using the associatedpayment_hash and the per-swap access_token returned by /swaps/init.
Request Body
Example Request
Response
swap: An object containing detailed information about the swap.
Example Response
Swap Object Schema
qty_from(integer): The quantity of the asset being swapped from. Example:30qty_to(integer): The quantity of the asset being swapped to. Example:10from_asset(string): The RGB asset ID being swapped from. Example:rgb:2dkSTbr-jFhznbPmo-TQafzswCN-av4gTsJjX-ttx6CNou5-M98k8Zdto_asset(string): The RGB asset ID being swapped to. Example:rgb:2eVw8uw-8G88LQ2tQ-kexM12SoD-nCX8DmQrw-yLMu6JDfK-xx1SCfcpayment_hash(string): The unique payment hash associated with the swap. Example:7c2c95b9c2aa0a7d140495b664de7973b76561de833f0dd84def3efa08941664status(SwapStatus): The current status of the swap. Possible values:WaitingPendingSucceededExpiredFailed
requested_at(integer): Unix timestamp when the swap was requested. Example:1691160765initiated_at(integer): Unix timestamp when the swap was initiated. Example:1691168512expires_at(integer): Unix timestamp when the swap expires. Example:1691172703completed_at(integer): Unix timestamp when the swap was completed. Example:1691171075
Additional Notes
- The
statusfield provides real-time updates on the swap’s progress. - Ensure that the
payment_hashprovided is accurate to retrieve the correct swap status. - A missing or invalid
access_tokenreturns a uniform404 Swap not found, so the endpoint cannot be used to probe for existing payment hashes. - Time-related fields are in Unix timestamp format.
- The
SwapStatusfield in theSwapobject can have one of the following values:Waiting: The swap is awaiting initiation.Pending: The swap has been initiated and is currently in progress.Succeeded: The swap has been successfully completed.Expired: The swap was not completed within the required timeframe.Failed: The swap encountered an error and did not complete successfully.
For error details, refer to Error Handling.