메인 콘텐츠로 건너뛰기

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.

예상 소요 시간: 약 5분

사전 준비

시작하기 전에 다음을 준비하세요.
  • 등록된 ChainStream 계정 (여기서 가입)
  • API Key (cs_live_...로 시작)
GraphQL API는 REST Data API와 동일한 API Key를 사용합니다. REST API에서 이미 키를 발급받았다면 그대로 재사용할 수 있습니다.

1단계: API Key 발급

  1. ChainStream Dashboard에 로그인합니다.
  2. Applications으로 이동합니다.
  3. Create New App을 클릭하거나(또는 기존 앱 선택) 앱을 선택합니다.
  4. API Key를 복사합니다.

2단계: GraphQL IDE 열기

ChainStream GraphQL IDE에 접속합니다. IDE는 자동 완성, 구문 강조, 인라인 문서, 쿼리 이력을 제공하여 스키마를 탐색하고 쿼리를 만드는 가장 빠른 방법입니다.

3단계: 인증 설정

IDE에서 Headers 패널(왼쪽 하단)을 열고 API Key를 추가합니다.
{
  "X-API-KEY": "your_api_key"
}

4단계: 샘플 쿼리 실행

아래 쿼리를 에디터에 붙여 넣습니다. Solana에서 최신 DEX 거래 10건을 가져오며, 블록 시각, 트랜잭션 해시, 매수/매도 토큰 정보, 수량, USD 가격, DEX 프로토콜 이름을 포함합니다.
query {
  Solana {
    DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Block {
        Time
        Slot
      }
      Transaction {
        Hash
      }
      Trade {
        Buy {
          Currency { MintAddress }
          Amount
          PriceInUSD
        }
        Sell {
          Currency { MintAddress }
          Amount
        }
        Dex { ProtocolName }
      }
    }
  }
}
GraphQL IDE에서 열기 — 위 쿼리를 붙여 넣어 자동 완성과 스키마 탐색으로 대화형 실행할 수 있습니다.
Play 버튼을 클릭하거나 Ctrl+Enter / Cmd+Enter를 눌러 실행합니다.

cURL 예시

터미널에서 동일한 쿼리를 실행할 수 있습니다.
curl -X POST "https://graphql.chainstream.io/graphql" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: your_api_key" \
  -d '{
    "query": "{ Solana { DEXTrades(limit: {count: 10}, orderBy: {descending: Block_Time}) { Block { Time Slot } Transaction { Hash } Trade { Buy { Currency { MintAddress } Amount PriceInUSD } Sell { Currency { MintAddress } Amount } Dex { ProtocolName } } } } }"
  }'

응답 예시

성공 응답은 대략 다음과 같습니다.
{
  "data": {
    "Solana": {
      "DEXTrades": [
        {
          "Block": {
            "Time": "2025-03-27T10:32:18Z",
            "Slot": 325847291
          },
          "Transaction": {
            "Hash": "4vKzR8g...x9bQ"
          },
          "Trade": {
            "Buy": {
              "Currency": { "MintAddress": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
              "Amount": 1523.45,
              "PriceInUSD": 1.0001
            },
            "Sell": {
              "Currency": { "MintAddress": "So11111111111111111111111111111111111111112" },
              "Amount": 10.237
            },
            "Dex": { "ProtocolName": "Raydium" }
          }
        },
        {
          "Block": {
            "Time": "2025-03-27T10:32:17Z",
            "Slot": 325847289
          },
          "Transaction": {
            "Hash": "3mPqW7n...kR2J"
          },
          "Trade": {
            "Buy": {
              "Currency": { "MintAddress": "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263" },
              "Amount": 48291037.12,
              "PriceInUSD": 0.00003152
            },
            "Sell": {
              "Currency": { "MintAddress": "So11111111111111111111111111111111111111112" },
              "Amount": 10.5
            },
            "Dex": { "ProtocolName": "Orca" }
          }
        }
      ]
    }
  },
  "extensions": {
    "credits": {
      "total": 50,
      "cubes": [
        { "cube": "DEXTrades", "credits": 50, "row_count": 10 }
      ]
    }
  }
}

응답 이해하기

응답 구조는 쿼리와 대응합니다.
경로설명
Block.TimeISO 8601 형식의 블록 타임스탬프
Block.SlotSolana 슬롯 번호(Solana 전용)
Transaction.Hash온체인 트랜잭션 해시
Trade.Buy.Currency.MintAddress매수 자산의 토큰 주소
Trade.Buy.Amount매수 토큰 수량
Trade.Buy.PriceInUSD거래 시점 매수 토큰의 USD 가격
Trade.Sell.Currency.MintAddress매도 자산의 토큰 주소
Trade.Sell.Amount매도 토큰 수량
Trade.Dex.ProtocolName거래를 실행한 DEX 프로토콜(예: Raydium, Orca, PancakeSwap)
extensions.credits 객체는 이 쿼리가 소비한 과금 크레딧과 잔여 잔액을 보여 줍니다. 자세한 내용은 Billing & Credits를 참고하세요.

쿼리 수정해 보기

동작하는 쿼리를 얻었다면 아래 수정을 시도해 보세요.
network: solnetwork: eth로 바꾸면 Ethereum DEX 거래(Uniswap, SushiSwap 등)를 조회할 수 있습니다.
where 절을 추가해 지난 1시간 거래만 필터합니다.
Solana {
  DEXTrades(
    limit: {count: 10}
    orderBy: {descending: Block_Time}
    where: {Block: {Time: {after: "2025-03-27T09:00:00Z"}}}
  ) { ... }
}
토큰 mint 주소로 필터해 특정 토큰 거래만 봅니다.
Solana {
  DEXTrades(
    limit: {count: 10}
    orderBy: {descending: Block_Time}
    where: {Trade: {Buy: {Currency: {MintAddress: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}}}}
  ) { ... }
}
DEX 프로토콜별 총 거래 수를 셉니다.
Solana {
  DEXTrades(
    where: {Block: {Time: {after: "2025-03-27T00:00:00Z"}}}
  ) {
    count
    Trade { Dex { ProtocolName } }
  }
}

다음 단계

Schema & Data Model

25개 Cube, 필드 타입, 필터 연산자, 집계 함수를 살펴봅니다.

Query Examples

DEX 거래, 전송, OHLC, 홀더 등 실전 쿼리 예시를 둘러봅니다.

GraphQL IDE Guide

IDE 마스터하기 — 쿼리 템플릿, 저장된 쿼리, Variables 패널, 코드보내기.

Billing & Credits

쿼리 크레딧 계산 방식과 비용 최적화를 이해합니다.