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

# WebSocket API

> WebSocket API 실시간 데이터 구독 서비스

## 개요

ChainStream DEX WebSocket API는 다음 데이터 유형을 지원하는 실시간 데이터 구독 서비스를 제공합니다:

* 캔들 데이터 (Candles)
* 토큰 관련 (Token Series)
* 지갑 관련 (Wallet Series)
* 랭킹 관련 (Ranking Series)
* 거래 관련 (Trade Series)
* DEX 풀 관련 (DexPool Series)

**기본 URL**

```bash theme={null}
wss://realtime-dex.chainstream.io/connection/websocket
```

## 빠른 시작

### 1. 연결 설정

먼저 WebSocket 연결을 생성합니다. WebSocket 연결은 URL의 `token` 쿼리 매개변수를 통한 인증이 필요합니다.

<Tabs>
  <Tab title="SDK 사용 (권장)">
    Go 또는 JavaScript SDK를 사용하는 경우, 인증이 자동으로 처리됩니다:

    ```typescript theme={null}
    import { ChainStreamClient } from '@chainstream-io/sdk';
    import { Resolution } from '@chainstream-io/sdk/openapi';

    const client = new ChainStreamClient('YOUR_ACCESS_TOKEN');

    // 바로 구독하면 됩니다. SDK가 WebSocket 연결과 인증을 자동 처리합니다
    client.stream.subscribeTokenCandles({
      chain: 'sol',
      tokenAddress: '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN',
      resolution: Resolution._1m,
      callback: (data) => {
        console.log('수신 데이터:', data);
      }
    });
    ```

    <Note>
      `subscribeXXX` 메서드를 호출할 때, SDK는 자동으로 연결 상태를 확인하고 연결되지 않은 경우 자동으로 연결을 설정합니다. 수동으로 `connect()`를 호출할 필요가 없습니다.
    </Note>

    SDK 설치:

    * **TypeScript/JavaScript**: `npm install @chainstream-io/sdk` ([npm](https://www.npmjs.com/package/@chainstream-io/sdk))
    * **Python**: `pip install chainstream-sdk` ([PyPI](https://pypi.org/project/chainstream-sdk))
    * **Go**: `go get github.com/chainstream-io/chainstream-go-sdk` ([GitHub](https://github.com/chainstream-io/chainstream-go-sdk))
    * **Rust**: `Cargo.toml`에 `chainstream-sdk` 추가 ([crates.io](https://crates.io/crates/chainstream-sdk))
  </Tab>

  <Tab title="네이티브 WebSocket 사용">
    브라우저 네이티브 WebSocket 또는 기타 WebSocket 라이브러리를 사용할 때, URL에 `token` 매개변수를 추가합니다:

    ```typescript theme={null}
    // 브라우저와 Node.js 모두에서 사용 가능
    const token = 'YOUR_ACCESS_TOKEN';
    const ws = new WebSocket(
      `wss://realtime-dex.chainstream.io/connection/websocket?token=${token}`
    );

    ws.onopen = () => {
      console.log('연결 성공');
    };

    ws.onmessage = (event) => {
      const data = JSON.parse(event.data);
      console.log('수신 데이터:', data);
    };
    ```

    <Note>
      URL 매개변수로 token을 전달하면, 브라우저 네이티브 WebSocket과 다양한 서드파티 라이브러리를 특별한 헤더 처리 없이 사용할 수 있습니다.
    </Note>
  </Tab>

  <Tab title="커맨드 라인 테스트">
    `wscat`을 사용한 테스트:

    ```bash theme={null}
    $ wscat -c "wss://realtime-dex.chainstream.io/connection/websocket?token=YOUR_ACCESS_TOKEN"
    ```
  </Tab>
</Tabs>

### 2. 데이터 구독

구독할 데이터 유형을 선택합니다:

```typescript theme={null}
// 캔들 데이터 구독 예제
ws.send(JSON.stringify({
  type: "subscribe",
  channel: "dex-candle:sol_6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN_1m"
}));
```

### 3. 데이터 처리

```typescript theme={null}
ws.onmessage = (event) => {
  const data = JSON.parse(event.data);
  console.log('수신 데이터:', data);
};
```

## 데이터 구독

### 캔들

#### 캔들 데이터

토큰의 가격 변동 데이터를 실시간으로 가져옵니다.

**구독 형식**

```text theme={null}
dex-candle:{chain}_{tokenAddress}_{resolution}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소, 예: 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
</ParamField>

<ParamField query="resolution" type="string" required>
  캔들 주기, 지원: 1m, 5m, 15m, 1h, 4h, 1d
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: volume > 1000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "o": number,    // Open price
      "c": number,    // Close price
      "h": number,    // High price
      "l": number,    // Low price
      "v": number,    // Volume
      "r": string,    // Resolution
      "t": number     // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "open": number,       // Open price
      "close": number,      // Close price
      "high": number,       // High price
      "low": number,        // Low price
      "volume": number,     // Volume
      "resolution": string, // Resolution
      "time": number       // Timestamp
    }
    ```
  </Tab>
</Tabs>

### 토큰 관련

#### 토큰 통계

토큰의 실시간 시장 통계 데이터를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-stats:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소, 예: 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: price > 0.01
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,      // Token address
      "t": number,      // Timestamp
      "b1m": number,    // Buys in 1m
      "s1m": number,    // Sells in 1m
      "be1m": number,   // Buyers in 1m
      "se1m": number,   // Sellers in 1m
      "bviu1m": number, // Buy volume in USD 1m
      "sviu1m": number, // Sell volume in USD 1m
      "p1m": number,    // Price 1m
      "oiu1m": number,  // Open price in USD 1m
      "ciu1m": number,  // Close price in USD 1m
      "b5m": number,    // Buys in 5m
      "s5m": number,    // Sells in 5m
      "be5m": number,   // Buyers in 5m
      "se5m": number,   // Sellers in 5m
      "bviu5m": number, // Buy volume in USD 5m
      "sviu5m": number, // Sell volume in USD 5m
      "p5m": number,    // Price 5m
      "oiu5m": number,  // Open price in USD 5m
      "ciu5m": number,  // Close price in USD 5m
      "b15m": number,   // Buys in 15m
      "s15m": number,   // Sells in 15m
      "be15m": number,  // Buyers in 15m
      "se15m": number,  // Sellers in 15m
      "bviu15m": number,// Buy volume in USD 15m
      "sviu15m": number,// Sell volume in USD 15m
      "p15m": number,   // Price 15m
      "oiu15m": number, // Open price in USD 15m
      "ciu15m": number, // Close price in USD 15m
      "b30m": number,   // Buys in 30m
      "s30m": number,   // Sells in 30m
      "be30m": number,  // Buyers in 30m
      "se30m": number,  // Sellers in 30m
      "bviu30m": number,// Buy volume in USD 30m
      "sviu30m": number,// Sell volume in USD 30m
      "p30m": number,   // Price 30m
      "oiu30m": number, // Open price in USD 30m
      "ciu30m": number, // Close price in USD 30m
      "b1h": number,    // Buys in 1h
      "s1h": number,    // Sells in 1h
      "be1h": number,   // Buyers in 1h
      "se1h": number,   // Sellers in 1h
      "bviu1h": number, // Buy volume in USD 1h
      "sviu1h": number, // Sell volume in USD 1h
      "p1h": number,    // Price 1h
      "oiu1h": number,  // Open price in USD 1h
      "ciu1h": number,  // Close price in USD 1h
      "b4h": number,    // Buys in 4h
      "s4h": number,    // Sells in 4h
      "be4h": number,   // Buyers in 4h
      "se4h": number,   // Sellers in 4h
      "bviu4h": number, // Buy volume in USD 4h
      "sviu4h": number, // Sell volume in USD 4h
      "p4h": number,    // Price 4h
      "oiu4h": number,  // Open price in USD 4h
      "ciu4h": number,  // Close price in USD 4h
      "b24h": number,   // Buys in 24h
      "s24h": number,   // Sells in 24h
      "be24h": number,  // Buyers in 24h
      "se24h": number,  // Sellers in 24h
      "bviu24h": number,// Buy volume in USD 24h
      "sviu24h": number,// Sell volume in USD 24h
      "p24h": number,   // Price 24h
      "oiu24h": number, // Open price in USD 24h
      "ciu24h": number, // Close price in USD 24h
      "p": number       // Current price
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "address": string,           // Token address
      "timestamp": number,         // Timestamp
      "buys1m": number,           // Buys in 1m
      "sells1m": number,          // Sells in 1m
      "buyers1m": number,         // Buyers in 1m
      "sellers1m": number,        // Sellers in 1m
      "buyVolumeInUsd1m": number, // Buy volume in USD 1m
      "sellVolumeInUsd1m": number,// Sell volume in USD 1m
      "price1m": number,          // Price 1m
      "openInUsd1m": number,      // Open price in USD 1m
      "closeInUsd1m": number,     // Close price in USD 1m
      "buys5m": number,           // Buys in 5m
      "sells5m": number,          // Sells in 5m
      "buyers5m": number,         // Buyers in 5m
      "sellers5m": number,        // Sellers in 5m
      "buyVolumeInUsd5m": number, // Buy volume in USD 5m
      "sellVolumeInUsd5m": number,// Sell volume in USD 5m
      "price5m": number,          // Price 5m
      "openInUsd5m": number,      // Open price in USD 5m
      "closeInUsd5m": number,     // Close price in USD 5m
      "buys15m": number,          // Buys in 15m
      "sells15m": number,         // Sells in 15m
      "buyers15m": number,        // Buyers in 15m
      "sellers15m": number,       // Sellers in 15m
      "buyVolumeInUsd15m": number,// Buy volume in USD 15m
      "sellVolumeInUsd15m": number,// Sell volume in USD 15m
      "price15m": number,         // Price 15m
      "openInUsd15m": number,     // Open price in USD 15m
      "closeInUsd15m": number,    // Close price in USD 15m
      "buys30m": number,          // Buys in 30m
      "sells30m": number,         // Sells in 30m
      "buyers30m": number,        // Buyers in 30m
      "sellers30m": number,       // Sellers in 30m
      "buyVolumeInUsd30m": number,// Buy volume in USD 30m
      "sellVolumeInUsd30m": number,// Sell volume in USD 30m
      "price30m": number,         // Price 30m
      "openInUsd30m": number,     // Open price in USD 30m
      "closeInUsd30m": number,    // Close price in USD 30m
      "buys1h": number,           // Buys in 1h
      "sells1h": number,          // Sells in 1h
      "buyers1h": number,         // Buyers in 1h
      "sellers1h": number,        // Sellers in 1h
      "buyVolumeInUsd1h": number, // Buy volume in USD 1h
      "sellVolumeInUsd1h": number,// Sell volume in USD 1h
      "price1h": number,          // Price 1h
      "openInUsd1h": number,      // Open price in USD 1h
      "closeInUsd1h": number,     // Close price in USD 1h
      "buys4h": number,           // Buys in 4h
      "sells4h": number,          // Sells in 4h
      "buyers4h": number,         // Buyers in 4h
      "sellers4h": number,        // Sellers in 4h
      "buyVolumeInUsd4h": number, // Buy volume in USD 4h
      "sellVolumeInUsd4h": number,// Sell volume in USD 4h
      "price4h": number,          // Price 4h
      "openInUsd4h": number,      // Open price in USD 4h
      "closeInUsd4h": number,     // Close price in USD 4h
      "buys24h": number,          // Buys in 24h
      "sells24h": number,         // Sells in 24h
      "buyers24h": number,        // Buyers in 24h
      "sellers24h": number,       // Sellers in 24h
      "buyVolumeInUsd24h": number,// Buy volume in USD 24h
      "sellVolumeInUsd24h": number,// Sell volume in USD 24h
      "price24h": number,         // Price 24h
      "openInUsd24h": number,     // Open price in USD 24h
      "closeInUsd24h": number,    // Close price in USD 24h
      "price": number            // Current price
    }
    ```
  </Tab>
</Tabs>

#### 토큰 보유자 통계

토큰 보유자의 실시간 통계 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-holding:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소, 예: 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: holders > 200
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,      // Token address
      "h": number,      // Number of holders
      "t100a": number,  // Top 100 holders total amount
      "t10a": number,   // Top 10 holders total amount
      "t100h": number,  // Top 100 holders count
      "t10h": number,   // Top 10 holders count
      "t100r": number,  // Top 100 holders ratio
      "t10r": number,   // Top 10 holders ratio
      "ch": number,     // Creators holders count
      "ca": number,     // Creators amount
      "cr": number,     // Creators ratio
      "ts": number      // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,    // Token address
      "holders": number,         // Number of holders
      "top100Amount": number,    // Top 100 holders total amount
      "top10Amount": number,     // Top 10 holders total amount
      "top100Holders": number,   // Top 100 holders count
      "top10Holders": number,    // Top 10 holders count
      "top100Ratio": number,     // Top 100 holders ratio
      "top10Ratio": number,      // Top 10 holders ratio
      "creatorsHolders": number, // Creators holders count
      "creatorsAmount": number,  // Creators amount
      "creatorsRatio": number,   // Creators ratio
      "timestamp": number        // Timestamp
    }
    ```
  </Tab>
</Tabs>

#### 신규 토큰 메타데이터

신규 상장 토큰의 실시간 메타데이터를 가져옵니다.

**구독 형식**

```text theme={null}
dex-new-tokens-metadata:{chain}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: name == "USDC"
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,      // Token address
        "n": string,      // Name
        "s": string,      // Symbol
        "iu": string,     // Image URL
        "de": string,     // Description
        "sm": {           // Social media
          "tw": string,   // Twitter
          "tg": string,   // Telegram
          "w": string,    // Website
          "tt": string,   // TikTok
          "dc": string,   // Discord
          "fb": string,   // Facebook
          "gh": string,   // GitHub
          "ig": string,   // Instagram
          "li": string,   // LinkedIn
          "md": string,   // Medium
          "rd": string,   // Reddit
          "yt": string,   // YouTube
          "bb": string    // BitBucket
        },
        "cts": number     // Created timestamp (ms)
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "tokenAddress": string,     // Token address
        "name": string,             // Name
        "symbol": string,           // Symbol
        "imageUrl": string,         // Image URL
        "description": string,      // Description
        "socialMedia": {            // Social media
          "twitter": string,        // Twitter
          "telegram": string,       // Telegram
          "website": string,        // Website
          "tiktok": string,         // TikTok
          "discord": string,        // Discord
          "facebook": string,       // Facebook
          "github": string,         // GitHub
          "instagram": string,      // Instagram
          "linkedin": string,       // LinkedIn
          "medium": string,         // Medium
          "reddit": string,         // Reddit
          "youtube": string,        // YouTube
          "bitbucket": string       // BitBucket
        },
        "createdAtMs": number       // Created timestamp (ms)
      }
    ]
    ```
  </Tab>
</Tabs>

#### 신규 토큰

새로 생성된 토큰의 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-new-token:{chain}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,      // Token address
      "n": string,      // Name
      "s": string,      // Symbol
      "dec": number,    // Decimals
      "cts": number,    // Created timestamp (ms)
      "lf": {           // Launch from information
        "pa": string,   // Program address
        "pf": string,   // Protocol family
        "pn": string    // Protocol name
      }
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,     // Token address
      "name": string,             // Name
      "symbol": string,           // Symbol
      "decimals": number,         // Decimals
      "createdAtMs": number,      // Created timestamp (ms)
      "launchFrom": {             // Launch from information
        "programAddress": string, // Program address
        "protocolFamily": string, // Protocol family
        "protocolName": string    // Protocol name
      }
    }
    ```
  </Tab>
</Tabs>

#### 토큰 공급량

토큰의 공급량과 시가총액 실시간 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-supply:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소, 예: 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: supply > 1000000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,    // Token address
      "s": number,    // Supply
      "mc": number,   // Market cap in USD
      "ts": number    // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,    // Token address
      "supply": number,          // Supply
      "marketCapInUsd": number,  // Market cap in USD
      "timestamp": number        // Timestamp
    }
    ```
  </Tab>
</Tabs>

#### 토큰 유동성

토큰의 실시간 유동성 통계를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-general-stat-num:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: value > 1000000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,    // Token address
      "t": string,    // Metric type
      "v": number,    // Value
      "ts": number    // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,  // Token address
      "metricType": string,    // Metric type
      "value": number,         // Value
      "timestamp": number      // Timestamp
    }
    ```
  </Tab>
</Tabs>

#### 토큰 최대 유동성

단일 풀에서의 토큰 실시간 최대 유동성 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-liquidity:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: liquidityInUsd > 10000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,     // Token address
      "p": string,     // Pool address
      "liu": string,   // Liquidity in USD
      "lin": string,   // Liquidity in native token
      "ts": number     // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,       // Token address
      "poolAddress": string,        // Pool address
      "liquidityInUsd": string,     // Liquidity in USD
      "liquidityInNative": string,  // Liquidity in native token
      "timestamp": number           // Timestamp
    }
    ```
  </Tab>
</Tabs>

#### 토큰 총 유동성

모든 풀에 걸친 토큰의 실시간 총 유동성 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-token-total-liquidity:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: liquidityInUsd > 50000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,     // Token address
      "liu": string,   // Total liquidity in USD
      "lin": string,   // Total liquidity in native token
      "pc": number,    // Pool count
      "ts": number     // Timestamp
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,       // Token address
      "liquidityInUsd": string,     // Total liquidity in USD
      "liquidityInNative": string,  // Total liquidity in native token
      "poolCount": number,          // Pool count
      "timestamp": number           // Timestamp
    }
    ```
  </Tab>
</Tabs>

### 랭킹 관련

#### 랭킹 토큰 통계

랭킹 토큰의 실시간 시장 통계 데이터를 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-token-stats-list:{chain}_{channelType}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="channelType" type="string" required>
  채널 유형, 지원: new、trending、us\_stocks、completed、graduated
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,      // Token address
        "t": number,      // Timestamp
        "b1m": number,    // Buys in 1m
        "s1m": number,    // Sells in 1m
        "be1m": number,   // Buyers in 1m
        "se1m": number,   // Sellers in 1m
        "bviu1m": number, // Buy volume in USD 1m
        "sviu1m": number, // Sell volume in USD 1m
        "p1m": number,    // Price 1m
        "oiu1m": number,  // Open price in USD 1m
        "ciu1m": number,  // Close price in USD 1m
        "b5m": number,    // Buys in 5m
        "s5m": number,    // Sells in 5m
        "be5m": number,   // Buyers in 5m
        "se5m": number,   // Sellers in 5m
        "bviu5m": number, // Buy volume in USD 5m
        "sviu5m": number, // Sell volume in USD 5m
        "p5m": number,    // Price 5m
        "oiu5m": number,  // Open price in USD 5m
        "ciu5m": number,  // Close price in USD 5m
        "b15m": number,   // Buys in 15m
        "s15m": number,   // Sells in 15m
        "be15m": number,  // Buyers in 15m
        "se15m": number,  // Sellers in 15m
        "bviu15m": number,// Buy volume in USD 15m
        "sviu15m": number,// Sell volume in USD 15m
        "p15m": number,   // Price 15m
        "oiu15m": number, // Open price in USD 15m
        "ciu15m": number, // Close price in USD 15m
        "b30m": number,   // Buys in 30m
        "s30m": number,   // Sells in 30m
        "be30m": number,  // Buyers in 30m
        "se30m": number,  // Sellers in 30m
        "bviu30m": number,// Buy volume in USD 30m
        "sviu30m": number,// Sell volume in USD 30m
        "p30m": number,   // Price 30m
        "oiu30m": number, // Open price in USD 30m
        "ciu30m": number, // Close price in USD 30m
        "b1h": number,    // Buys in 1h
        "s1h": number,    // Sells in 1h
        "be1h": number,   // Buyers in 1h
        "se1h": number,   // Sellers in 1h
        "bviu1h": number, // Buy volume in USD 1h
        "sviu1h": number, // Sell volume in USD 1h
        "p1h": number,    // Price 1h
        "oiu1h": number,  // Open price in USD 1h
        "ciu1h": number,  // Close price in USD 1h
        "b4h": number,    // Buys in 4h
        "s4h": number,    // Sells in 4h
        "be4h": number,   // Buyers in 4h
        "se4h": number,   // Sellers in 4h
        "bviu4h": number, // Buy volume in USD 4h
        "sviu4h": number, // Sell volume in USD 4h
        "p4h": number,    // Price 4h
        "oiu4h": number,  // Open price in USD 4h
        "ciu4h": number,  // Close price in USD 4h
        "b24h": number,   // Buys in 24h
        "s24h": number,   // Sells in 24h
        "be24h": number,  // Buyers in 24h
        "se24h": number,  // Sellers in 24h
        "bviu24h": number,// Buy volume in USD 24h
        "sviu24h": number,// Sell volume in USD 24h
        "p24h": number,   // Price 24h
        "oiu24h": number, // Open price in USD 24h
        "ciu24h": number, // Close price in USD 24h
        "p": number       // Current price
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "address": string,           // Token address
        "timestamp": number,         // Timestamp
        "buys1m": number,           // Buys in 1m
        "sells1m": number,          // Sells in 1m
        "buyers1m": number,         // Buyers in 1m
        "sellers1m": number,        // Sellers in 1m
        "buyVolumeInUsd1m": number, // Buy volume in USD 1m
        "sellVolumeInUsd1m": number,// Sell volume in USD 1m
        "price1m": number,          // Price 1m
        "openInUsd1m": number,      // Open price in USD 1m
        "closeInUsd1m": number,     // Close price in USD 1m
        "buys5m": number,           // Buys in 5m
        "sells5m": number,          // Sells in 5m
        "buyers5m": number,         // Buyers in 5m
        "sellers5m": number,        // Sellers in 5m
        "buyVolumeInUsd5m": number, // Buy volume in USD 5m
        "sellVolumeInUsd5m": number,// Sell volume in USD 5m
        "price5m": number,          // Price 5m
        "openInUsd5m": number,      // Open price in USD 5m
        "closeInUsd5m": number,     // Close price in USD 5m
        "buys15m": number,          // Buys in 15m
        "sells15m": number,         // Sells in 15m
        "buyers15m": number,        // Buyers in 15m
        "sellers15m": number,       // Sellers in 15m
        "buyVolumeInUsd15m": number,// Buy volume in USD 15m
        "sellVolumeInUsd15m": number,// Sell volume in USD 15m
        "price15m": number,         // Price 15m
        "openInUsd15m": number,     // Open price in USD 15m
        "closeInUsd15m": number,    // Close price in USD 15m
        "buys30m": number,          // Buys in 30m
        "sells30m": number,         // Sells in 30m
        "buyers30m": number,        // Buyers in 30m
        "sellers30m": number,       // Sellers in 30m
        "buyVolumeInUsd30m": number,// Buy volume in USD 30m
        "sellVolumeInUsd30m": number,// Sell volume in USD 30m
        "price30m": number,         // Price 30m
        "openInUsd30m": number,     // Open price in USD 30m
        "closeInUsd30m": number,    // Close price in USD 30m
        "buys1h": number,           // Buys in 1h
        "sells1h": number,          // Sells in 1h
        "buyers1h": number,         // Buyers in 1h
        "sellers1h": number,        // Sellers in 1h
        "buyVolumeInUsd1h": number, // Buy volume in USD 1h
        "sellVolumeInUsd1h": number,// Sell volume in USD 1h
        "price1h": number,          // Price 1h
        "openInUsd1h": number,      // Open price in USD 1h
        "closeInUsd1h": number,     // Close price in USD 1h
        "buys4h": number,           // Buys in 4h
        "sells4h": number,          // Sells in 4h
        "buyers4h": number,         // Buyers in 4h
        "sellers4h": number,        // Sellers in 4h
        "buyVolumeInUsd4h": number, // Buy volume in USD 4h
        "sellVolumeInUsd4h": number,// Sell volume in USD 4h
        "price4h": number,          // Price 4h
        "openInUsd4h": number,      // Open price in USD 4h
        "closeInUsd4h": number,     // Close price in USD 4h
        "buys24h": number,          // Buys in 24h
        "sells24h": number,         // Sells in 24h
        "buyers24h": number,        // Buyers in 24h
        "sellers24h": number,       // Sellers in 24h
        "buyVolumeInUsd24h": number,// Buy volume in USD 24h
        "sellVolumeInUsd24h": number,// Sell volume in USD 24h
        "price24h": number,         // Price 24h
        "openInUsd24h": number,     // Open price in USD 24h
        "closeInUsd24h": number,    // Close price in USD 24h
        "price": number            // Current price
      }
    ]
    ```
  </Tab>
</Tabs>

#### 랭킹 토큰 보유자 통계

랭킹 토큰의 실시간 보유자 통계 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-token-holding-list:{chain}_{channelType}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="channelType" type="string" required>
  채널 유형, 지원: new、trending、us\_stocks、completed、graduated
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,      // Token address
        "h": number,      // Number of holders
        "t100a": number,  // Top 100 holders total amount
        "t10a": number,   // Top 10 holders total amount
        "t100h": number,  // Top 100 holders count
        "t10h": number,   // Top 10 holders count
        "t100r": number,  // Top 100 holders ratio
        "t10r": number,   // Top 10 holders ratio
        "ts": number      // Timestamp
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "tokenAddress": string,    // Token address
        "holders": number,         // Number of holders
        "top100Amount": number,    // Top 100 holders total amount
        "top10Amount": number,     // Top 10 holders total amount
        "top100Holders": number,   // Top 100 holders count
        "top10Holders": number,    // Top 10 holders count
        "top100Ratio": number,     // Top 100 holders ratio
        "top10Ratio": number,      // Top 10 holders ratio
        "timestamp": number        // Timestamp
      }
    ]
    ```
  </Tab>
</Tabs>

#### 랭킹 토큰 공급량 데이터

랭킹 토큰의 공급량과 시가총액 실시간 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-token-supply-list:{chain}_{channelType}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="channelType" type="string" required>
  채널 유형, 지원: new、trending、us\_stocks、completed、graduated
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,    // Token address
        "s": number,    // Supply
        "mc": number,   // Market cap in USD
        "ts": number    // Timestamp
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "tokenAddress": string,    // Token address
        "supply": number,          // Supply
        "marketCapInUsd": number,  // Market cap in USD
        "timestamp": number        // Timestamp
      }
    ]
    ```
  </Tab>
</Tabs>

#### 랭킹 토큰 유동성 데이터

랭킹 토큰의 실시간 유동성 통계를 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-token-general_stat_num-list:{chain}_{channelType}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="channelType" type="string" required>
  채널 유형, 지원: new、trending、us\_stocks、completed、graduated
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,    // Token address
        "t": string,    // Metric type
        "v": number,    // Value
        "ts": number    // Timestamp
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "tokenAddress": string,  // Token address
        "metricType": string,    // Metric type
        "value": number,         // Value
        "timestamp": number      // Timestamp
      }
    ]
    ```
  </Tab>
</Tabs>

#### 랭킹 토큰 리스트

랭킹 토큰의 메타데이터, 보유자 통계, 공급량, 시장 데이터를 포함한 완전한 정보 목록을 실시간으로 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-list:{chain}_{ranking_type}
# 또는 DEX 지정
dex-ranking-list:{chain}_{ranking_type}_{dex}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="ranking_type" type="string" required>
  랭킹 유형, 지원: new、trending、us\_stocks、completed、graduated
</ParamField>

<ParamField query="dex" type="string" required={false}>
  선택적 DEX 플랫폼, 지원: pump\_fun、raydium\_launchpad、meteora\_dynamic\_bounding\_curve、bonk\_fun、boop\_fun、moonit\_fun
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        // TokenMetadata (t)
        "t": {
          "a": string,      // Token address
          "n": string,      // Name
          "s": string,      // Symbol
          "iu": string,     // Image URL
          "de": string,     // Description
          "dec": number,    // Decimals
          "cts": number,    // Created timestamp (ms)
          "lf": {           // Launch from information
            "pa": string,   // Program address
            "pf": string,   // Protocol family
            "pn": string    // Protocol name
          },
          "mt": {           // Migrated to information
            "pa": string,   // Program address
            "pf": string,   // Protocol family
            "pn": string    // Protocol name
          },
          "sm": {           // Social media
            "tw": string,   // Twitter
            "tg": string,   // Telegram
            "w": string,    // Website
            "tt": string,   // TikTok
            "dc": string,   // Discord
            "fb": string,   // Facebook
            "gh": string,   // GitHub
            "ig": string,   // Instagram
            "li": string,   // LinkedIn
            "md": string,   // Medium
            "rd": string,   // Reddit
            "yt": string,   // YouTube
            "bb": string    // BitBucket
          }
          },
        // TokenBondingCurve (bc)
        "bc": {
          "pr": number      // Progress ratio
        },
        // TokenHolder (h)
        "h": {
          "a": string,      // Token address
          "h": number,      // Number of holders
          "t100a": number,  // Top 100 holders total amount
          "t10a": number,   // Top 10 holders total amount
          "t100h": number,  // Top 100 holders count
          "t10h": number,   // Top 10 holders count
          "t100r": number,  // Top 100 holders ratio
          "t10r": number,   // Top 10 holders ratio
          "ts": number      // Timestamp
        },
        // TokenSupply (s)
        "s": {
          "a": string,    // Token address
          "s": number,    // Supply
          "mc": number,   // Market cap in USD
          "ts": number    // Timestamp
        },
        // TokenStat (ts)
        "ts": {
          "a": string,      // Token address
          "t": number,      // Timestamp
          "b1m": number,    // Buys in 1m
          "s1m": number,    // Sells in 1m
          "be1m": number,   // Buyers in 1m
          "se1m": number,   // Sellers in 1m
          "bviu1m": number, // Buy volume in USD 1m
          "sviu1m": number, // Sell volume in USD 1m
          "p1m": number,    // Price 1m
          "oiu1m": number,  // Open price in USD 1m
          "ciu1m": number,  // Close price in USD 1m
          "b5m": number,    // Buys in 5m
          "s5m": number,    // Sells in 5m
          "be5m": number,   // Buyers in 5m
          "se5m": number,   // Sellers in 5m
          "bviu5m": number, // Buy volume in USD 5m
          "sviu5m": number, // Sell volume in USD 5m
          "p5m": number,    // Price 5m
          "oiu5m": number,  // Open price in USD 5m
          "ciu5m": number,  // Close price in USD 5m
          "b15m": number,   // Buys in 15m
          "s15m": number,   // Sells in 15m
          "be15m": number,  // Buyers in 15m
          "se15m": number,  // Sellers in 15m
          "bviu15m": number,// Buy volume in USD 15m
          "sviu15m": number,// Sell volume in USD 15m
          "p15m": number,   // Price 15m
          "oiu15m": number, // Open price in USD 15m
          "ciu15m": number, // Close price in USD 15m
          "b30m": number,   // Buys in 30m
          "s30m": number,   // Sells in 30m
          "be30m": number,  // Buyers in 30m
          "se30m": number,  // Sellers in 30m
          "bviu30m": number,// Buy volume in USD 30m
          "sviu30m": number,// Sell volume in USD 30m
          "p30m": number,   // Price 30m
          "oiu30m": number, // Open price in USD 30m
          "ciu30m": number, // Close price in USD 30m
          "b1h": number,    // Buys in 1h
          "s1h": number,    // Sells in 1h
          "be1h": number,   // Buyers in 1h
          "se1h": number,   // Sellers in 1h
          "bviu1h": number, // Buy volume in USD 1h
          "sviu1h": number, // Sell volume in USD 1h
          "p1h": number,    // Price 1h
          "oiu1h": number,  // Open price in USD 1h
          "ciu1h": number,  // Close price in USD 1h
          "b4h": number,    // Buys in 4h
          "s4h": number,    // Sells in 4h
          "be4h": number,   // Buyers in 4h
          "se4h": number,   // Sellers in 4h
          "bviu4h": number, // Buy volume in USD 4h
          "sviu4h": number, // Sell volume in USD 4h
          "p4h": number,    // Price 4h
          "oiu4h": number,  // Open price in USD 4h
          "ciu4h": number,  // Close price in USD 4h
          "b24h": number,   // Buys in 24h
          "s24h": number,   // Sells in 24h
          "be24h": number,  // Buyers in 24h
          "se24h": number,  // Sellers in 24h
          "bviu24h": number,// Buy volume in USD 24h
          "sviu24h": number,// Sell volume in USD 24h
          "p24h": number,   // Price 24h
          "oiu24h": number, // Open price in USD 24h
          "ciu24h": number, // Close price in USD 24h
          "p": number       // Current price
        }
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        // Token metadata
        "metadata": {
        "tokenAddress": string,     // Token address
        "name": string,             // Name
        "symbol": string,           // Symbol
        "imageUrl": string,         // Image URL
        "description": string,      // Description
          "decimals": number,         // Decimals
          "createdAtMs": number,      // Created timestamp (ms)
          "launchFrom": {             // Launch from information
            "programAddress": string, // Program address
            "protocolFamily": string, // Protocol family
            "protocolName": string    // Protocol name
          },
          "migratedTo": {             // Migrated to information
            "programAddress": string, // Program address
            "protocolFamily": string, // Protocol family
            "protocolName": string    // Protocol name
          },
        "socialMedia": {            // Social media
          "twitter": string,        // Twitter
          "telegram": string,       // Telegram
          "website": string,        // Website
          "tiktok": string,         // TikTok
          "discord": string,        // Discord
          "facebook": string,       // Facebook
          "github": string,         // GitHub
          "instagram": string,      // Instagram
          "linkedin": string,       // LinkedIn
          "medium": string,         // Medium
          "reddit": string,         // Reddit
          "youtube": string,        // YouTube
          "bitbucket": string       // BitBucket
          }
        },
        
        // Bonding curve information
        "bondingCurve": {
          "progressRatio": number     // Progress ratio
        },
        
        // Holder statistics
        "holder": {
          "tokenAddress": string,     // Token address
          "timestamp": number,        // Timestamp
        "holders": number,          // Number of holders
        "top100Amount": number,     // Top 100 holders total amount
        "top10Amount": number,      // Top 10 holders total amount
        "top100Holders": number,    // Top 100 holders count
        "top10Holders": number,     // Top 10 holders count
        "top100Ratio": number,      // Top 100 holders ratio
          "top10Ratio": number        // Top 10 holders ratio
        },
        
        // Supply information
        "supply": {
          "tokenAddress": string,     // Token address
          "timestamp": number,        // Timestamp
        "supply": number,           // Supply
          "marketCapInUsd": number    // Market cap in USD
        },
        
        // Market statistics
        "stat": {
          "address": string,          // Token address
          "timestamp": number,        // Timestamp
        "buys1m": number,           // Buys in 1m
        "sells1m": number,          // Sells in 1m
        "buyers1m": number,         // Buyers in 1m
        "sellers1m": number,        // Sellers in 1m
        "buyVolumeInUsd1m": number, // Buy volume in USD 1m
        "sellVolumeInUsd1m": number,// Sell volume in USD 1m
        "price1m": number,          // Price 1m
        "openInUsd1m": number,      // Open price in USD 1m
        "closeInUsd1m": number,     // Close price in USD 1m
          "buys5m": number,           // Buys in 5m
          "sells5m": number,          // Sells in 5m
          "buyers5m": number,         // Buyers in 5m
          "sellers5m": number,        // Sellers in 5m
          "buyVolumeInUsd5m": number, // Buy volume in USD 5m
          "sellVolumeInUsd5m": number,// Sell volume in USD 5m
          "price5m": number,          // Price 5m
          "openInUsd5m": number,      // Open price in USD 5m
          "closeInUsd5m": number,     // Close price in USD 5m
          "buys15m": number,          // Buys in 15m
          "sells15m": number,         // Sells in 15m
          "buyers15m": number,        // Buyers in 15m
          "sellers15m": number,       // Sellers in 15m
          "buyVolumeInUsd15m": number,// Buy volume in USD 15m
          "sellVolumeInUsd15m": number,// Sell volume in USD 15m
          "price15m": number,         // Price 15m
          "openInUsd15m": number,     // Open price in USD 15m
          "closeInUsd15m": number,    // Close price in USD 15m
          "buys30m": number,          // Buys in 30m
          "sells30m": number,         // Sells in 30m
          "buyers30m": number,        // Buyers in 30m
          "sellers30m": number,       // Sellers in 30m
          "buyVolumeInUsd30m": number,// Buy volume in USD 30m
          "sellVolumeInUsd30m": number,// Sell volume in USD 30m
          "price30m": number,         // Price 30m
          "openInUsd30m": number,     // Open price in USD 30m
          "closeInUsd30m": number,    // Close price in USD 30m
          "buys1h": number,           // Buys in 1h
          "sells1h": number,          // Sells in 1h
          "buyers1h": number,         // Buyers in 1h
          "sellers1h": number,        // Sellers in 1h
          "buyVolumeInUsd1h": number, // Buy volume in USD 1h
          "sellVolumeInUsd1h": number,// Sell volume in USD 1h
          "price1h": number,          // Price 1h
          "openInUsd1h": number,      // Open price in USD 1h
          "closeInUsd1h": number,     // Close price in USD 1h
          "buys4h": number,           // Buys in 4h
          "sells4h": number,          // Sells in 4h
          "buyers4h": number,         // Buyers in 4h
          "sellers4h": number,        // Sellers in 4h
          "buyVolumeInUsd4h": number, // Buy volume in USD 4h
          "sellVolumeInUsd4h": number,// Sell volume in USD 4h
          "price4h": number,          // Price 4h
          "openInUsd4h": number,      // Open price in USD 4h
          "closeInUsd4h": number,     // Close price in USD 4h
          "buys24h": number,          // Buys in 24h
          "sells24h": number,         // Sells in 24h
          "buyers24h": number,        // Buyers in 24h
          "sellers24h": number,       // Sellers in 24h
          "buyVolumeInUsd24h": number,// Buy volume in USD 24h
          "sellVolumeInUsd24h": number,// Sell volume in USD 24h
          "price24h": number,         // Price 24h
          "openInUsd24h": number,     // Open price in USD 24h
          "closeInUsd24h": number,    // Close price in USD 24h
          "price": number             // Current price
        }
      }
    ]
    ```
  </Tab>
</Tabs>

#### 랭킹 토큰 본딩 커브

신규 상장 토큰의 실시간 본딩 커브 진행률을 가져옵니다.

**구독 형식**

```text theme={null}
dex-ranking-token-bounding-curve-list:{chain}_new
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,    // Token address
        "pr": string    // Progress ratio (0-1)
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "tokenAddress": string,   // Token address
        "progressRatio": string   // Progress ratio (0-1)
      }
    ]
    ```
  </Tab>
</Tabs>

### 지갑 관련

#### 지갑 잔액

지갑의 실시간 잔액 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-wallet-balance:{chain}_{walletAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="walletAddress" type="string" required>
  지갑 주소, 예: HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: balance > 1000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,      // Wallet address
        "ta": string,     // Token address
        "tpiu": number,   // Token price in USD
        "b": number,      // Balance
        "t": number       // Timestamp
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "walletAddress": string,    // Wallet address
        "tokenAddress": string,     // Token address
        "tokenPriceInUsd": number, // Token price in USD
        "balance": number,          // Balance
        "timestamp": number         // Timestamp
      }
    ]
    ```
  </Tab>
</Tabs>

#### 지갑 PnL 데이터 (토큰 레벨)

지갑의 실시간 손익(PnL) 통계를 가져옵니다.

**구독 형식**

```text theme={null}
dex-wallet-token-pnl:{chain}_{walletAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="walletAddress" type="string" required>
  지갑 주소
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: buyAmount > 1000
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,      // Wallet address
      "ta": string,     // Token address
      "tpiu": number,   // Token price in USD
      "t": number,      // Timestamp
      "ot": number,     // Open time
      "lt": number,     // Last time
      "ct": number,     // Close time
      "ba": number,     // Buy amount
      "baiu": number,   // Buy amount in USD
      "bs": number,     // Buy count
      "bs30d": number,  // Buy count 30d
      "bs7d": number,   // Buy count 7d
      "sa": number,     // Sell amount
      "saiu": number,   // Sell amount in USD
      "ss": number,     // Sell count
      "ss30d": number,  // Sell count 30d
      "ss7d": number,   // Sell count 7d
      "hdts": number,   // Held duration timestamp
      "abpiu": number,  // Average buy price in USD
      "aspiu": number,  // Average sell price in USD
      "upiu": number,   // Unrealized profit in USD
      "upr": number,    // Unrealized profit ratio
      "rpiu": number,   // Realized profit in USD
      "rpr": number,    // Realized profit ratio
      "trpiu": number,  // Total realized profit in USD
      "trr": number     // Total realized profit ratio
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "walletAddress": string,         // Wallet address
      "tokenAddress": string,          // Token address
      "tokenPriceInUsd": number,       // Token price in USD
      "timestamp": number,             // Timestamp
      "opentime": number,              // Open time
      "lasttime": number,              // Last time
      "closetime": number,             // Close time
      "buyAmount": number,             // Buy amount
      "buyAmountInUsd": number,        // Buy amount in USD
      "buyCount": number,              // Buy count
      "buyCount30d": number,           // Buy count 30d
      "buyCount7d": number,            // Buy count 7d
      "sellAmount": number,            // Sell amount
      "sellAmountInUsd": number,       // Sell amount in USD
      "sellCount": number,             // Sell count
      "sellCount30d": number,          // Sell count 30d
      "sellCount7d": number,           // Sell count 7d
      "heldDurationTimestamp": number, // Held duration timestamp
      "averageBuyPriceInUsd": number,  // Average buy price in USD
      "averageSellPriceInUsd": number, // Average sell price in USD
      "unrealizedProfitInUsd": number, // Unrealized profit in USD
      "unrealizedProfitRatio": number, // Unrealized profit ratio
      "realizedProfitInUsd": number,   // Realized profit in USD
      "realizedProfitRatio": number,   // Realized profit ratio
      "totalRealizedProfitInUsd": number, // Total realized profit in USD
      "totalRealizedProfitRatio": number  // Total realized profit ratio
    }
    ```
  </Tab>
</Tabs>

#### 지갑 PnL 데이터 (지갑 레벨)

지갑의 실시간 전체 손익 통계를 가져옵니다.

**구독 형식**

```text theme={null}
dex-wallet-pnl-list:{chain}_{walletAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="walletAddress" type="string" required>
  지갑 주소
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    [
      {
        "a": string,     // Wallet address
        "bs": number,    // Number of buys
        "ba": number,    // Buy amount
        "baiu": number,  // Buy amount in USD
        "abpiu": number, // Average buy price in USD
        "sa": number,    // Sell amount
        "saiu": number,  // Sell amount in USD
        "ss": number,    // Number of sells
        "ws": number,    // Number of wins
        "wr": number,    // Win ratio
        "piu": number,   // PnL in USD
        "apiu": number,  // Average PnL in USD
        "pr": number,    // PnL ratio
        "pd": number,    // Profitable days
        "ld": number,    // Losing days
        "ts": number,    // Number of tokens traded
        "r": string      // Resolution
      }
    ]
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    [
      {
        "walletAddress": string,         // Wallet address
        "buys": number,                  // Number of buys
        "buyAmount": number,             // Buy amount
        "buyAmountInUsd": number,        // Buy amount in USD
        "averageBuyPriceInUsd": number,  // Average buy price in USD
        "sellAmount": number,            // Sell amount
        "sellAmountInUsd": number,       // Sell amount in USD
        "sells": number,                 // Number of sells
        "wins": number,                  // Number of wins
        "winRatio": number,              // Win ratio
        "pnlInUsd": number,              // PnL in USD
        "averagePnlInUsd": number,       // Average PnL in USD
        "pnlRatio": number,              // PnL ratio
        "profitableDays": number,        // Profitable days
        "losingDays": number,            // Losing days
        "tokens": number,                // Number of tokens traded
        "resolution": string             // Resolution
      }
    ]
    ```
  </Tab>
</Tabs>

### 거래 관련

#### 토큰 거래

토큰의 실시간 거래 이벤트를 가져옵니다.

**구독 형식**

```text theme={null}
dex-trade:{chain}_{tokenAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="tokenAddress" type="string" required>
  토큰 컨트랙트 주소, 예: 6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN
</ParamField>

<ParamField query="filter" type="string" required={false}>
  선택적 필터 조건. Google Common Expression Language(CEL) 구문 사용. 예: buyAmount > 100
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,      // Token address
      "t": number,      // Timestamp
      "k": string,      // Trade type
      "ba": number,     // Buy amount
      "baiu": number,   // Buy amount in USD
      "btma": string,   // Buy token address
      "btn": string,    // Buy token name
      "bts": string,    // Buy token symbol
      "bwa": string,    // Buy wallet address
      "sa": number,     // Sell amount
      "saiu": number,   // Sell amount in USD
      "stma": string,   // Sell token address
      "stn": string,    // Sell token name
      "sts": string,    // Sell token symbol
      "swa": string,    // Sell wallet address
      "h": string       // Transaction hash
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "tokenAddress": string,    // Token address
      "timestamp": number,       // Timestamp
      "kind": string,            // Trade type
      "buyAmount": number,       // Buy amount
      "buyAmountInUsd": number,  // Buy amount in USD
      "buyTokenAddress": string, // Buy token address
      "buyTokenName": string,    // Buy token name
      "buyTokenSymbol": string,  // Buy token symbol
      "buyWalletAddress": string,// Buy wallet address
      "sellAmount": number,      // Sell amount
      "sellAmountInUsd": number,// Sell amount in USD
      "sellTokenAddress": string,// Sell token address
      "sellTokenName": string,   // Sell token name
      "sellTokenSymbol": string,// Sell token symbol
      "sellWalletAddress": string,// Sell wallet address
      "txHash": string          // Transaction hash
    }
    ```
  </Tab>
</Tabs>

#### 지갑 거래

지갑의 실시간 거래 이벤트를 가져옵니다.

**구독 형식**

```text theme={null}
dex-wallet-trade:{chain}_{walletAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="walletAddress" type="string" required>
  지갑 주소, 예: GDekof7TtgeBKJtoVpkvzPin5mvhxSDyoUY2c1FK1T3i
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "bwa": string,     // Maker address
      "ba": number,      // Base token amount
      "sa": number,      // Quote token amount
      "swa": string,     // Quote token address
      "bais": number,    // USD amount
      "t": number,       // Timestamp
      "k": string,       // Event type
      "h": string,       // Transaction hash
      "a": string        // Token address
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "maker": string,        // Maker address
      "baseAmount": number,   // Base token amount
      "quoteAmount": number,  // Quote token amount
      "quoteAddress": string, // Quote token address
      "amountInUsd": number,  // USD amount
      "timestamp": number,    // Timestamp
      "event": string,       // Event type
      "txHash": string,      // Transaction hash
      "tokenAddress": string  // Token address
    }
    ```
  </Tab>
</Tabs>

### DEX 풀 관련

#### DEX 풀 잔액

DEX 풀의 실시간 잔액 정보를 가져옵니다.

**구독 형식**

```text theme={null}
dex-pool-balance:{chain}_{poolAddress}
```

**매개변수**

<ParamField query="chain" type="string" required>
  블록체인 이름, 예: sol
</ParamField>

<ParamField query="poolAddress" type="string" required>
  풀 주소
</ParamField>

**응답 데이터 형식**

<Tip>
  WebSocket API는 전송 효율을 최적화하기 위해 단축 필드명을 반환하고, SDK는 코드 가독성을 높이기 위해 전체 필드명을 반환합니다.
</Tip>

<Tabs>
  <Tab title="WebSocket API">
    ```typescript theme={null}
    {
      "a": string,     // Pool address
      "taa": string,   // Token A address
      "taliu": number, // Token A liquidity in USD
      "tba": string,   // Token B address
      "tbliu": number  // Token B liquidity in USD
    }
    ```
  </Tab>

  <Tab title="SDK">
    ```typescript theme={null}
    {
      "poolAddress": string,           // Pool address
      "tokenAAddress": string,         // Token A address
      "tokenALiquidityInUsd": number,  // Token A liquidity in USD
      "tokenBAddress": string,         // Token B address
      "tokenBLiquidityInUsd": number   // Token B liquidity in USD
    }
    ```
  </Tab>
</Tabs>

## 사용 예제

```typescript theme={null}
import { ChainStreamClient } from '@chainstream-io/sdk';
import { Resolution } from '@chainstream-io/sdk/openapi';

const client = new ChainStreamClient('YOUR_ACCESS_TOKEN');

// 바로 구독하면 됩니다. SDK가 연결 상태를 자동 감지하고 필요시 연결합니다
client.stream.subscribeTokenCandles({
  chain: 'sol',
  tokenAddress: '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN',
  resolution: Resolution._1m,
  callback: (data) => {
    console.log('캔들 데이터:', data);
  }
});

// 지갑 잔액 구독
client.stream.subscribeWalletBalance({
  chain: 'sol',
  walletAddress: 'YOUR_WALLET_ADDRESS',
  callback: (data) => {
    console.log('지갑 잔액:', data);
  }
});
```

### 재연결 전략

지수 백오프를 사용한 재연결을 권장합니다:

```typescript theme={null}
function reconnect(attempt) {
  const delay = Math.min(1000 * Math.pow(2, attempt), 10000);
  setTimeout(() => {
    connect();
  }, delay);
}
```

## 사용 제한

| 제한 항목   | 제한 값   | 설명        |
| ------- | ------ | --------- |
| 최대 구독 수 | 100/연결 | 초과 시 거부됨  |
| 메시지 크기  | 100KB  | 초과 시 잘림   |
| 하트비트 간격 | 30초    | 정기적 전송 필요 |

## 모범 사례

1. **연결 관리**
   * 단일 WebSocket 연결 유지
   * 자동 재연결 구현
   * 정기적 하트비트 전송

2. **오류 처리**
   * 완전한 오류 처리 구현
   * 상세한 오류 정보 로깅
   * 지수 백오프를 사용한 재연결

3. **성능 최적화**
   * 구독 수 제어
   * 메시지 큐 메커니즘 구현
   * 미사용 구독 정리

## 전체 예제

<Tabs>
  <Tab title="SDK 사용 (권장)">
    ```typescript theme={null}
    import { ChainStreamClient } from '@chainstream-io/sdk';
    import { Resolution } from '@chainstream-io/sdk/openapi';

    const client = new ChainStreamClient('YOUR_ACCESS_TOKEN');

    // 바로 구독하면 됩니다. SDK가 연결 상태를 자동 감지하고 필요시 연결합니다
    const subscription = client.stream.subscribeTokenCandles({
      chain: 'sol',
      tokenAddress: '6p6xgHyF7AeE6TZkSmFsko444wqoP15icUSqi2jfGiPN',
      resolution: Resolution._1m,
      callback: (data) => {
        console.log('캔들 데이터:', data);
      }
    });

    // 구독 해제
    subscription.unsubscribe();
    ```

    <Note>
      SDK를 사용하면 인증, 재연결, 하트비트 등이 모두 자동으로 처리됩니다. 프로덕션 환경에서 사용을 권장합니다.

      * **TypeScript/JavaScript SDK**: [@chainstream-io/sdk](https://www.npmjs.com/package/@chainstream-io/sdk)
      * **Python SDK**: [chainstream-sdk](https://pypi.org/project/chainstream-sdk)
      * **Go SDK**: [chainstream-go-sdk](https://github.com/chainstream-io/chainstream-go-sdk)
      * **Rust SDK**: [chainstream-sdk](https://crates.io/crates/chainstream-sdk)
    </Note>
  </Tab>

  <Tab title="네이티브 WebSocket">
    ```typescript theme={null}
    class DexWebSocket {
      private ws: WebSocket;
      private reconnectAttempts = 0;
      private maxReconnectAttempts = 5;
      private subscriptions = new Set<string>();

      constructor(
        private baseUrl: string,
        private accessToken: string
      ) {
        this.connect();
      }

      private connect() {
        // Append token parameter to URL for authentication
        const url = `${this.baseUrl}?token=${this.accessToken}`;
        this.ws = new WebSocket(url);
        
        this.ws.onopen = () => {
          console.log('WebSocket connection established');
          this.reconnectAttempts = 0;
          // Resubscribe to previous channels
          this.resubscribe();
        };

        this.ws.onmessage = (event) => {
          this.handleMessage(JSON.parse(event.data));
        };

        this.ws.onclose = () => {
          console.log('WebSocket connection closed');
          this.reconnect();
        };

        this.ws.onerror = (error) => {
          console.error('WebSocket error:', error);
        };
      }

      private reconnect() {
        if (this.reconnectAttempts < this.maxReconnectAttempts) {
          const delay = Math.min(1000 * Math.pow(2, this.reconnectAttempts), 10000);
          this.reconnectAttempts++;
          console.log(`Attempting reconnection in ${delay}ms...`);
          setTimeout(() => this.connect(), delay);
        }
      }

      private resubscribe() {
        this.subscriptions.forEach(channel => {
          this.send({ type: "subscribe", channel });
        });
      }

      private handleMessage(data: any) {
        // Handle message
      }

      private send(data: any) {
        if (this.ws.readyState === WebSocket.OPEN) {
          this.ws.send(JSON.stringify(data));
        }
      }

      public subscribe(channel: string) {
        this.subscriptions.add(channel);
        this.send({ type: "subscribe", channel });
      }

      public unsubscribe(channel: string) {
        this.subscriptions.delete(channel);
        this.send({ type: "unsubscribe", channel });
      }
    }

    // Usage example
    const client = new DexWebSocket(
      "wss://realtime-dex.chainstream.io/connection/websocket",
      "YOUR_ACCESS_TOKEN"
    );
    ```
  </Tab>
</Tabs>
