> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kaleidoswap.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Node SDK Examples

> Working Node SDK code examples in TypeScript and Python, covering market data queries and live quote streaming over WebSocket

## Market Data

```typescript TypeScript theme={null}
import { KaleidoClient } from 'kaleido-sdk';

const client = KaleidoClient.create({
  baseUrl: 'https://api.signet.kaleidoswap.com',
});

const [assets, pairs] = await Promise.all([
  client.maker.listAssets(),
  client.maker.listPairs(),
]);

console.log(`Assets: ${assets.assets.length}`);
console.log(`Pairs: ${pairs.pairs.length}`);

for (const pair of pairs.pairs.slice(0, 5)) {
  console.log(`${pair.base.ticker}/${pair.quote.ticker}`);
}
```

```python Python theme={null}
from kaleido_sdk import KaleidoClient

client = KaleidoClient.create(
    base_url="https://api.signet.kaleidoswap.com"
)

assets = await client.maker.list_assets()
pairs = await client.maker.list_pairs()

print(f"Assets: {len(assets.assets)}")
print(f"Pairs: {len(pairs.pairs)}")

for pair in pairs.pairs[:5]:
    print(f"{pair.base.ticker}/{pair.quote.ticker}")
```

## Atomic Swaps

A swap is a five-step sequence — quote, init, whitelist on your node, execute, then track settlement — and stopping after `initSwap` leaves a locked swap that never executes. The complete flow in both languages is on [How to Swap](https://docs.kaleidoswap.com/cli/node-sdk/how-to-swap.md).

## WebSocket Streaming

```typescript TypeScript theme={null}
import { KaleidoClient } from 'kaleido-sdk';

const client = KaleidoClient.create({
  baseUrl: 'https://api.signet.kaleidoswap.com',
});

client.maker.enableWebSocket('wss://api.signet.kaleidoswap.com/api/v1/market/ws/my-client-id');

const stop = await client.maker.streamQuotesByTicker(
  'BTC',
  'USDT',
  100000,
  (quote) => console.log(quote.price),
  { pollInterval: 2000 }
);

setTimeout(() => stop(), 10000);
```

```python Python theme={null}
import asyncio

from kaleido_sdk import KaleidoClient

client = KaleidoClient.create(
    base_url="https://api.signet.kaleidoswap.com"
)

client.maker.enable_websocket("wss://api.signet.kaleidoswap.com/api/v1/market/ws/my-client-id")

stop = await client.maker.stream_quotes_by_ticker(
    "BTC",
    "USDT",
    100000,
    lambda quote: print(quote["price"]),
    poll_interval=2.0,
)

await asyncio.sleep(10)
stop()
```

## Node Operations

For the `client.rln` entry point — the `hasNode()` guard and the first node calls — see [Getting Started](https://docs.kaleidoswap.com/cli/node-sdk/getting-started.md#node-configuration-checks). Every available method is listed in the [Client Reference](https://docs.kaleidoswap.com/cli/node-sdk/api-reference.md#rlnclient-clientrln).

## Next Steps

> **[How to Swap](https://docs.kaleidoswap.com/cli/node-sdk/how-to-swap.md)**
>
> The complete atomic swap sequence: init, whitelist, execute, status.

> **[WebSocket](https://docs.kaleidoswap.com/cli/node-sdk/websocket.md)**
>
> Streaming options, events, and the low-level `WSClient`.

> **[Utilities](https://docs.kaleidoswap.com/cli/node-sdk/utilities.md)**
>
> Amount conversion, precision handling, and asset pair mapping.

> **[Client Reference](https://docs.kaleidoswap.com/cli/node-sdk/api-reference.md)**
>
> Every method on `client.maker` and `client.rln`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.