Skip to main content
Estimated time: 5 minutes

Prerequisites

Before you begin, make sure you have:
  • A registered ChainStream account (Register here)
  • An API Key (starts with cs_live_...)
The GraphQL API shares the same API Key as the REST Data API. If you already have a key from the REST API, you can reuse it here.

Step 1: Get Your API Key

  1. Log in to ChainStream Dashboard
  2. Go to Applications
  3. Click Create New App (or select an existing app)
  4. Copy your API Key

Step 2: Open the GraphQL IDE

Visit the ChainStream GraphQL IDE: The IDE provides auto-complete, syntax highlighting, inline documentation, and query history — making it the fastest way to explore the schema and build queries.

Step 3: Configure Authentication

In the IDE, open the Headers panel (bottom-left) and add your API Key:
{
  "X-API-KEY": "your_api_key"
}

Step 4: Run a Sample Query

Paste the following query into the editor. It fetches the latest 10 DEX trades on Solana, including block time, transaction hash, buy/sell token info, amounts, USD price, and the DEX protocol name.
query {
  DEXTrades(
    network: sol
    limit: {count: 10}
    orderBy: Block_Time_DESC
  ) {
    Block {
      Time
      Slot
    }
    Transaction {
      Hash
    }
    Trade {
      Buy {
        Currency { MintAddress }
        Amount
        PriceInUSD
      }
      Sell {
        Currency { MintAddress }
        Amount
      }
      Dex { ProtocolName }
    }
  }
}
Open in GraphQL IDE — paste the query above to run it interactively with auto-complete and schema exploration.
Click the Play button (or press Ctrl+Enter / Cmd+Enter) to execute.

cURL Equivalent

You can run the same query from your terminal:
curl -X POST "https://graphql.chainstream.io/graphql" \
  -H "Content-Type: application/json" \
  -H "X-API-KEY: your_api_key" \
  -d '{
    "query": "{ DEXTrades(network: sol, limit: {count: 10}, orderBy: Block_Time_DESC) { Block { Time Slot } Transaction { Hash } Trade { Buy { Currency { MintAddress } Amount PriceInUSD } Sell { Currency { MintAddress } Amount } Dex { ProtocolName } } } }"
  }'

Response Example

A successful response looks like this:
{
  "data": {
    "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 }
      ]
    }
  }
}

Understanding the Response

The response mirrors the structure of your query:
PathDescription
Block.TimeBlock timestamp in ISO 8601 format
Block.SlotSolana slot number (Solana-specific)
Transaction.HashOn-chain transaction hash
Trade.Buy.Currency.MintAddressToken address of the bought asset
Trade.Buy.AmountAmount of the bought token
Trade.Buy.PriceInUSDUSD price of the bought token at trade time
Trade.Sell.Currency.MintAddressToken address of the sold asset
Trade.Sell.AmountAmount of the sold token
Trade.Dex.ProtocolNameDEX protocol that executed the trade (e.g. Raydium, Orca, PancakeSwap)
The extensions.credits object shows how many billing credits this query consumed and your remaining balance. See Billing & Credits for details.

Try Modifying the Query

Now that you have a working query, try these modifications:
Change network: sol to network: eth to query Ethereum DEX trades (Uniswap, SushiSwap, etc.).
Filter trades from the last hour by adding a where clause:
DEXTrades(
  network: sol
  limit: {count: 10}
  orderBy: Block_Time_DESC
  where: {Block: {Time: {after: "2025-03-27T09:00:00Z"}}}
) { ... }
Filter by token mint address to see trades for a specific token:
DEXTrades(
  network: sol
  limit: {count: 10}
  orderBy: Block_Time_DESC
  where: {Trade: {Buy: {Currency: {MintAddress: {is: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"}}}}}
) { ... }
Count total trades per DEX protocol:
DEXTrades(
  network: sol
  where: {Block: {Time: {after: "2025-03-27T00:00:00Z"}}}
) {
  count
  Trade { Dex { ProtocolName } }
}

Next Steps

Schema & Data Model

Explore all 25 Cubes, field types, filtering operators, and aggregation functions.

Query Examples

Browse real-world query examples for DEX trades, transfers, OHLC, holders, and more.

GraphQL IDE Guide

Master the IDE — query templates, saved queries, variables panel, and code export.

Billing & Credits

Understand how query credits are calculated and how to optimize costs.