メインコンテンツへスキップ

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 分

前提条件

始める前に、次を用意してください。
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 上の最新 10 件の DEX 取引を取得し、ブロック時刻、トランザクションハッシュ、買い/売りトークン情報、数量、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 を参照してください。

クエリを変えてみる

動作するクエリが得られたら、次の変更を試してください。
Solana の代わりに EVM(network: 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 } }
  }
}

次のステップ

スキーマとデータモデル

25 の Cube、フィールド型、フィルタ演算子、集約関数を確認。

クエリ例

DEX 取引、転送、OHLC、ホルダーなどの実践的なクエリ例を参照。

GraphQL IDE ガイド

IDE の使い方 — クエリテンプレート、保存クエリ、Variables パネル、コードエクスポート。

課金とクレジット

クエリクレジットの計算方法とコスト最適化。