Skip to main content

Client Initialization

import { KaleidoClient, LogLevel } from 'kaleido-sdk';

const client = KaleidoClient.create({
  baseUrl: 'https://api.regtest.kaleidoswap.com',
  nodeUrl: 'http://localhost:3001',
  apiKey: process.env.KALEIDO_API_KEY,
  timeout: 30,
  logLevel: LogLevel.INFO,
});

client.hasMaker(); // boolean
client.hasNode();  // boolean
client.maker;      // MakerClient
client.rln;        // RlnClient

MakerClient (client.maker)

Market Data

TypeScriptPythonNotes
listAssets()list_assets()List all assets
listPairs()list_pairs()List all trading pairs
getQuote(body)get_quote(body)Request a quote
getPairRoutes(body)get_pair_routes(pair_ticker)TS accepts a request body; Python accepts a pair ticker like "BTC/USDT"
getMarketRoutes(body)get_market_routes(body)Discover market routes
import { KaleidoClient, Layer } from 'kaleido-sdk';

const client = KaleidoClient.create();

const assets = await client.maker.listAssets();
const pairs = await client.maker.listPairs();
const quote = await client.maker.getQuote({
  from_asset: { asset_id: 'BTC', layer: Layer.BTC_LN, amount: 100000 },
  to_asset: { asset_id: 'USDT', layer: Layer.RGB_LN },
});

Swap Orders

TypeScriptPythonNotes
createSwapOrder(body)create_swap_order(body)Create a swap order from a quote
getSwapOrderStatus(body)get_swap_order_status(body)Fetch current order status
getOrderHistory(params?)get_order_history(...)History with optional filters
getOrderAnalytics()get_order_analytics()Aggregate order analytics
submitRateDecision(body)submit_rate_decision(body)Accept or reject a refreshed rate
waitForSwapCompletion(orderId, options)wait_for_swap_completion(order_id, options)Poll until terminal state
waitForSwapCompletion in TypeScript requires accessToken inside options. The Python helper currently polls with just order_id.
const order = await client.maker.createSwapOrder({
  rfq_id: quote.rfq_id,
  from_asset: quote.from_asset,
  to_asset: quote.to_asset,
  receiver_address: {
    address: 'demo-receiver-address',
    format: 'BOLT11',
  },
});

const status = await client.maker.getSwapOrderStatus({
  order_id: order.id,
  access_token: order.access_token,
});

const completed = await client.maker.waitForSwapCompletion(order.id, {
  accessToken: order.access_token,
  timeout: 300000,
  pollInterval: 2000,
  onStatusUpdate: (next) => console.log(next),
});

Atomic Swaps

TypeScriptPythonNotes
initSwap(body)init_swap(body)Initialize an atomic swap
executeSwap(body)execute_swap(body)Confirm or execute the swap
getAtomicSwapStatus(body)get_atomic_swap_status(body)Query swap status
getSwapNodeInfo()get_swap_node_info()Maker swap node details

LSPS1

TypeScriptPythonNotes
getLspInfo()get_lsp_info()LSP metadata
getLspNetworkInfo()get_lsp_network_info()LSP network info
createLspOrder(body)create_lsp_order(body)Create LSPS1 order
getLspOrder(body)get_lsp_order(body)Fetch LSPS1 order
estimateLspFees(body)estimate_lsp_fees(body)Estimate order fees
submitLspRateDecision(body)submit_lsp_rate_decision(body)Rate-decision endpoint

WebSocket and Streaming

TypeScriptPythonNotes
enableWebSocket(wsUrl)enable_websocket(ws_url, user_id=None)Create a WSClient
streamQuotes(...)stream_quotes(...)Polling quote stream over WebSocket
streamQuotesByTicker(...)stream_quotes_by_ticker(...)Auto-select routes
streamQuotesForAllRoutes(...)stream_quotes_for_all_routes(...)Stream all routes
getAvailableRoutes(...)get_available_routes(...)Route helper

RlnClient (client.rln)

Wallet and BTC

TypeScriptPython
getNodeInfo()get_node_info()
getNetworkInfo()get_network_info()
initWallet(body)init_wallet(body)
unlockWallet(body)unlock_wallet(body)
lockWallet()lock_wallet()
changePassword(body)change_password(body)
backup(body)backup(body)
restore(body)restore(body)
shutdown()shutdown()
getAddress()get_address()
getBtcBalance(skipSync?)get_btc_balance(skip_sync=False)
sendBtc(body)send_btc(body)
listTransactions(request?)list_transactions(...)
listUnspents()list_unspents(...)
createUtxos(body)create_utxos(body)
estimateFee(body)estimate_fee(body)

RGB Assets

TypeScriptPython
listAssets(filterAssetSchemas?)list_assets(filter_asset_schemas=...)
getAssetBalance(body)get_asset_balance(body)
getAssetMetadata(body)get_asset_metadata(body)
getAssetMedia(body)get_asset_media(body)
issueAssetNIA(body)issue_asset_nia(body)
issueAssetCFA(body)issue_asset_cfa(body)
issueAssetUDA(body)issue_asset_uda(body)
sendRgb(body)send_rgb(body)
listTransfers(body)list_transfers(body)
refreshTransfers(body?)refresh_transfers(body=None)
syncRgbWallet()sync_rgb_wallet()
failTransfers(body)fail_transfers(body)

Channels, Peers, Invoices, and Payments

TypeScriptPython
listChannels()list_channels()
openChannel(body)open_channel(body)
closeChannel(body)close_channel(body)
getChannelId(body)get_channel_id(body)
listPeers()list_peers()
connectPeer(body)connect_peer(body)
disconnectPeer(body)disconnect_peer(body)
createLNInvoice(body)create_ln_invoice(body)
createRgbInvoice(body)create_rgb_invoice(body)
decodeLNInvoice(body)decode_ln_invoice(body)
decodeRgbInvoice(body)decode_rgb_invoice(body)
getInvoiceStatus(body)get_invoice_status(body)
sendPayment(body)send_payment(body)
keysend(body)keysend(body)
listPayments()list_payments()
getPayment(body)get_payment(body)

Swap Coordination and Utilities

TypeScriptPythonNotes
getTakerPubkey()get_taker_pubkey()Returns node pubkey
whitelistSwap(body)whitelist_swap(body)Accepts request object or raw swapstring
makerInit(body)maker_init(body)Maker-side swap init
makerExecute(body)maker_execute(body)Maker-side execution
listSwaps()list_swaps()List swaps
getSwap(body)get_swap(body)Fetch a swap
signMessage(body)sign_message(body)Utility
sendOnionMessage(body)send_onion_message(body)Utility
checkIndexerUrl(body)check_indexer_url(body)Utility
checkProxyEndpoint(body)check_proxy_endpoint(body)Utility
revokeToken(body)revoke_token(body)Utility

Closing the Client

await client.close();