DEX API | Blockchain Data API (V2)

·

Decentralized exchanges (DEXs) are reshaping the landscape of digital asset trading by enabling peer-to-peer transactions without intermediaries. To harness the full potential of DEX data—such as trade volumes, token pairs, top traders, and real-time market activity—you need a powerful, reliable blockchain data API. This guide explores how to use the DEX API (V2) to extract actionable insights from Ethereum-based decentralized exchanges using structured queries and real-time analytics.

Whether you're building a market intelligence dashboard, tracking DeFi trends, or analyzing trading behavior, this API provides granular access to on-chain DEX activity.

👉 Discover real-time blockchain trading insights with advanced query tools

Understanding the Core DEX APIs

The DEX API offers two primary endpoints for retrieving decentralized exchange data:

These APIs are part of the broader EVM (Ethereum Virtual Machine) schema, allowing seamless integration across Ethereum and EVM-compatible networks. For a detailed comparison between DEXTrades and DEXTradeByTokens, refer to the official schema documentation.


Retrieve All DEXs on the Ethereum Network

To get a comprehensive overview of all active decentralized exchanges on Ethereum, use the following query:

query DexMarkets($network: evm_network) {
  EVM(network: $network) {
    DEXTradeByTokens {
      Trade {
        Dex {
          ProtocolFamily
        }
      }
      buyers: uniq(of: Trade_Buyer)
      sellers: uniq(of: Trade_Sender)
      count(if: {Trade: {Side: {Type: {is: buy}}}})
    }
  }
}

Variables:

{
  "network": "eth"
}

This query returns key metrics such as:

You can test this query in the Bitquery IDE or visualize results via DEXrabbit. This is ideal for market researchers assessing platform adoption and liquidity distribution across DEXs.


Fetch Statistics for a Specific DEX

Need performance metrics for a single decentralized exchange like Uniswap or SushiSwap? Use this targeted query:

query DexMarkets($network: evm_network, $market: String) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Trade: {Dex: {ProtocolFamily: {is: $market}}}}
    ) {
      Block {
        Time(interval: {count: 1, in: hours})
      }
      trades: count
      buyers: uniq(of: Trade_Buyer)
      sellers: uniq(of: Trade_Sender)
      tokens: uniq(of: Trade_Currency_SmartContract)
    }
  }
}

Variables:

{
  "market": "Uniswap",
  "network": "eth"
}

This returns hourly-aggregated data including:

Ideal for monitoring protocol health over time, detecting user engagement spikes, or benchmarking against competitors.

👉 Access live DEX analytics with high-performance blockchain queries


Get All Trading Pairs on a Specific DEX

To analyze which token pairs are actively traded on a given DEX (e.g., Uniswap), run this query:

query DexMarkets(
  $network: evm_network
  $market: String
  $time_10min_ago: DateTime
  $time_1h_ago: DateTime
  $time_3h_ago: DateTime
) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "usd"}
      where: {
        Trade: {Dex: {ProtocolFamily: {is: $market}}}
        Block: {Time: {after: $time_3h_ago}}
      }
      limit: {count: 200}
    ) {
      Trade {
        Currency {
          Symbol
          Name
          SmartContract
          Fungible
        }
        Side {
          Currency {
            Symbol
            Name
            SmartContract
          }
        }
        price_usd: PriceInUSD(maximum: Block_Number)
        price_last: Price(maximum: Block_Number)
        price_10min_ago: Price(
          maximum: Block_Number
          if: {Block: {Time: {before: $time_10min_ago}}}
        )
        price_1h_ago: Price(
          maximum: Block_Number
          if: {Block: {Time: {before: $time_1h_ago}}}
        )
        price_3h_ago: PriceInUSD(minimum: Block_Number)
      }
      usd: sum(of: Trade_AmountInUSD)
      count
    }
  }
}

Variables Example:

{
  "market": "Uniswap",
  "network": "eth",
  "time_10min_ago": "2025-04-05T10:00:00Z",
  "time_1h_ago": "2025-04-05T09:10:00Z",
  "time_3h_ago": "2025-04-05T07:10:00Z"
}

This returns:

Useful for identifying trending pairs, arbitrage opportunities, or sudden price deviations.


Identify Top Traders on a DEX

Understanding whale activity and influential traders enhances market prediction accuracy. Use this query to find top traders by trading volume:

query DexMarkets($network: evm_network, $market: String) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "volumeUsd"}
      limit: {count: 100}
      where: {Trade: {Dex: {ProtocolFamily: {is: $market}}}}
    ) {
      Trade {
        Buyer
        Dex {
          OwnerAddress
          ProtocolFamily
          ProtocolName
        }
        Currency {
          SmartContract
          Symbol
          Name
        }
        Side {
          Currency {
            SmartContract
            Symbol
            Name
          }
        }
      }
      volumeUsd: sum(of: Trade_Side_AmountInUSD)
    }
  }
}

Variables:

{
  "market": "Uniswap",
  "network": "eth"
}

Results include:

This data supports social trading strategies, influencer tracking, and anomaly detection in DeFi markets.


Retrieve Latest Trades on a DEX

For real-time monitoring and event-driven applications, fetch the most recent trades:

query LatestTrades($network: evm_network, $market: String) {
  EVM(network: $network) {
    DEXTradeByTokens(
      orderBy: {descending: Block_Time}
      limit: {count: 50}
      where: {Trade: {Dex: {ProtocolFamily: {is: $market}}}}
    ) {
      Block {
        Time
      }
      Transaction {
        Hash
      }
      Trade {
        Dex {
          OwnerAddress
          ProtocolFamily
          ProtocolName
        }
        AmountInUSD
        Price
        Amount
        Side {
          Type
          Currency {
            Symbol
            SmartContract
            Name
          }
          AmountInUSD
          Amount
        }
        Currency {
          Symbol
          SmartContract
          Name
        }
      }
    }
  }
}

Variables:

{
  "market": "Uniswap",
  "network": "eth"
}

Returns:

Perfect for live dashboards, alert systems, or front-running detection models.


Frequently Asked Questions (FAQ)

Q1: What is the difference between DEXTrades and DEXTradeByTokens?
A1: DEXTrades returns raw trade events individually, while DEXTradeByTokens aggregates trades by token pairs and enables statistical analysis like volume sums and unique user counts.

Q2: Can I use this API for non-Ethereum EVM chains?
A2: Yes. While examples focus on Ethereum ("network": "eth"), the same queries work across EVM-compatible blockchains like BSC, Polygon, Arbitrum, and Optimism by changing the network parameter.

Q3: How often is the data updated?
A3: Data is indexed in near real-time, typically within seconds of block confirmation, ensuring up-to-date insights for time-sensitive applications.

Q4: Is there rate limiting on these APIs?
A4: API usage depends on your plan tier. Free plans have limited requests per minute; enterprise plans offer higher throughput and SLAs.

Q5: Can I filter trades by specific tokens?
A5: Absolutely. Add conditions in the where clause using Trade.Currency.SmartContract to filter by token address.

Q6: How can I detect new token listings on DEXs?
A6: Monitor DEXTradeByTokens with a time window filter. A sudden appearance of a new token pair with rising volume indicates a fresh listing or launch.


Core Keywords

With these tools and insights, developers and analysts can unlock deep visibility into decentralized finance ecosystems—empowering smarter decisions through transparent, queryable blockchain data.

👉 Unlock advanced blockchain analytics with scalable API solutions