ArbitrumBlockchainTokensDEX Trades

Arbitrum DEX APIs - A Comprehensive Guide to Bitquery's Arbitrum DEX APIs

Query and stream Arbitrum DEX data with Bitquery GraphQL: live trades with USD prices, trading pairs, pools, OHLC, token trade history, first buyers and per-address trades, with every query run on the current API.

Cover Image for Arbitrum DEX APIs - A Comprehensive Guide to Bitquery's Arbitrum DEX APIs

The Ethereum mainnet has long faced heavy traffic, expensive gas and slow confirmation, and "Layer 2" networks exist to take that load off it. Arbitrum is one of the largest, and its DEXs, Uniswap v3 and v4, PancakeSwap, Camelot, SushiSwap and the aggregators that route across them, see a large share of L2 trading.

DEX trading data promotes transparency, accessibility and innovation in the market, and it is the raw material for charts, bots, screeners and research. This article shows how to use Bitquery APIs to get data from DEXs on Arbitrum: trades, pairs, pools, addresses and more. Every query below was run against the live API before this update.

Bitquery APIs

Bitquery provides historical and real-time indexed data for the major chains through GraphQL APIs, WebSocket subscriptions, Kafka streams and bulk exports. On Arbitrum that includes:

  • Transfers
  • Token trades and transfers
  • Holders
  • Transactions
  • Address balances
  • Smart contract events and calls
  • NFT trades and transfers

This access lets developers build multi-chain solutions for compliance, DEX trading, NFT marketplaces, analytics and more. If you have an issue with any of the queries, the Arbitrum DEX trades docs carry the maintained versions.

Live Arbitrum DEX trades with USD prices

For anything real-time or within the last month, the Crypto Trades API is the quickest route: every Arbitrum swap with the trader, both legs, a USD price and the token's market cap, MEV-filtered, in one stream. Change subscription to query and add limit and orderBy for a snapshot; add a Protocol filter under Market to follow one DEX.

subscription {
  Trading {
    Trades(where: { Pair: { Market: { NetworkBid: { is: "bid:arbitrum" } } } }) {
      Block {
        Time
      }
      Side
      Trader {
        Address
      }
      Pair {
        Token {
          Symbol
          Address
        }
        QuoteToken {
          Symbol
        }
        Market {
          Protocol
          ProtocolFamily
        }
        Pool {
          Address
        }
      }
      PriceInUsd
      AmountsInUsd {
        Quote
      }
      Supply {
        MarketCap
      }
    }
  }
}

The chain-level queries that follow add the full archive, pool-level detail and the raw buy and sell legs.

Analyze DEXes on Arbitrum with Bitquery APIs

Note: the examples use the Arbitrum governance token ARB (0x912CE59144191C1204E64559FE8253a0e49E6548); change the address to the token you need.

Trading pairs API on Arbitrum DEX

If you want all trades of a token, you first want to know its trading pairs. Protocols like Uniswap have pairs or pools. We are using the V2 IDE here.

All Pairs for a Token on any Arbitrum DEX

This takes every trade where ARB was bought in the last week and keeps one row per counter-token, which gives the token's pairs across every DEX Bitquery indexes on Arbitrum, with the pool address and the factory that deployed it.

{
  EVM(dataset: combined, network: arbitrum) {
    DEXTrades(
      where: {
        Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}}
        Block: {Time: {since_relative: {days_ago: 7}}}
      }
      limit: {count: 10}
      limitBy: {by: Trade_Sell_Currency_SmartContract, count: 1}
    ) {
      Trade {
        Dex {
          ProtocolName
          OwnerAddress
          SmartContract
        }
        Buy {
          Currency {
            Name
            SmartContract
          }
        }
        Sell {
          Currency {
            Name
            SmartContract
          }
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link. Dex.SmartContract is the pool contract on every protocol version.

All Pairs on a Specific Arbitrum DEX

To restrict the list to one DEX, filter on the factory that deployed the pools. Here we get the ARB pairs on Uniswap v3 by passing the Uniswap v3 factory address, which is the same on Arbitrum as on Ethereum.

{
  EVM(dataset: combined, network: arbitrum) {
    DEXTrades(
      where: {
        Trade: {
          Buy: {
            Currency: {
              SmartContract: {
                is: "0x912CE59144191C1204E64559FE8253a0e49E6548"
              }
            }
          }
          Dex: {
            OwnerAddress: { is: "0x1f98431c8ad98523631ae4a59f267346ea31f984" }
          }
        }
      }
      limit: { count: 10 }
      limitBy: { by: Trade_Sell_Currency_SmartContract, count: 1 }
    ) {
      Trade {
        Dex {
          ProtocolName
          OwnerAddress
        }
        Buy {
          Currency {
            Name
            SmartContract
          }
        }
        Sell {
          Currency {
            Name
            SmartContract
          }
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

Trade Metrics for a Token Pair

This query returns trade metrics for a pair (ARB/USDT here) over the last 24 hours: unique buyers and sellers, transaction count and the amounts bought and sold.

query {
  EVM(network: arbitrum, dataset: combined) {
    Unique_Buyers: DEXTrades(
      where: {Block: {Time: {since_relative: {hours_ago: 24}}}, Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Sell: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}}}
    ) {
      count(distinct: Trade_Buy_Buyer)
    }
    Unique_Sellers: DEXTrades(
      where: {Block: {Time: {since_relative: {hours_ago: 24}}}, Trade: {Sell: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Buy: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}}}
    ) {
      count(distinct: Trade_Sell_Seller)
    }
    Total_Transactions: DEXTrades(
      where: {Block: {Time: {since_relative: {hours_ago: 24}}}, Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Sell: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}}}
    ) {
      count(distinct: Transaction_Hash)
    }
    Total_Buy_Amount: DEXTrades(
      where: {Block: {Time: {since_relative: {hours_ago: 24}}}, Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Sell: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}}}
    ) {
      sum(of: Trade_Buy_Amount)
    }
    Total_Sell_Amount: DEXTrades(
      where: {Block: {Time: {since_relative: {hours_ago: 24}}}, Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Sell: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}}}
    ) {
      sum(of: Trade_Sell_Amount)
    }
  }
}

Open the above query on GraphQL IDE using this link.

OHLC API for Arbitrum DEXs

You can build a coin ticker with the DEX APIs at any interval you need. This example returns ten-minute candles for ARB priced in USDT, newest first, built in-query from raw trades. For pre-aggregated candles down to one second with USD prices, the Crypto Price API serves them from the Pairs cube.

{
  EVM(dataset: realtime, network: arbitrum) {
    DEXTradeByTokens(
      orderBy: {descendingByField: "Block_bucket"}
      limit: {count: 100}
      where: {
        Trade: {
          Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}
          Side: {Currency: {SmartContract: {is: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"}}}
          PriceAsymmetry: {lt: 0.1}
        }
      }
    ) {
      Block {
        bucket: Time(interval: {in: minutes, count: 10})
      }
      volume: sum(of: Trade_Amount)
      Trade {
        high: Price(maximum: Trade_Price)
        low: Price(minimum: Trade_Price)
        open: Price(minimum: Block_Number)
        close: Price(maximum: Block_Number)
      }
      count
    }
  }
}

Open the above query on GraphQL IDE using this link. The PriceAsymmetry filter drops trades whose two legs disagree on price, which keeps outliers out of the candles.

Latest trading pairs for DEX

Whenever a new pool is created, the Uniswap v3 factory emits a PoolCreated event with the pool's details, so tracking that event on the factory lists the newest pairs with both tokens, the tick spacing and the pool address. Swap query for subscription to receive them live.

{
  EVM(network: arbitrum) {
    Events(
      orderBy: {descending: Block_Number}
      limit: {count: 10}
      where: {Log: {SmartContract: {is: "0x1f98431c8ad98523631ae4a59f267346ea31f984"}, Signature: {Name: {is: "PoolCreated"}}}}
    ) {
      Log {
        Signature {
          Name
        }
        SmartContract
      }
      Transaction {
        Hash
      }
      Block {
        Time
        Number
      }
      Arguments {
        Name
        Value {
          ... on EVM_ABI_Address_Value_Arg {
            address
          }
          ... on EVM_ABI_BigInt_Value_Arg {
            bigInteger
          }
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

Token Trades API

Historical Token Trades & Price API

This returns trades of WETH routed through the 1inch router over the last month, with the router set as seller on the buy side and buyer on the sell side so that both directions are covered. We are using a Block -> Time filter here; use Block -> Date to filter by date or Block -> Number to filter by block height.

{
  EVM(dataset: combined, network: arbitrum) {
    buyside: DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Buy: {Currency: {SmartContract: {is: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}}, Seller: {is: "0x1111111254eeb25477b68fb85ed929f73a960582"}}}, Block: {Time: {since_relative: {days_ago: 30}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
            SmartContract
          }
          Seller
          Price
        }
        Sell {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Seller
          Price
        }
      }
    }
    sellside: DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Sell: {Currency: {SmartContract: {is: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"}}, Buyer: {is: "0x1111111254eeb25477b68fb85ed929f73a960582"}}}, Block: {Time: {since_relative: {days_ago: 30}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
            SmartContract
          }
          Seller
          Price
        }
        Sell {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Seller
          Price
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

First X Buyers of a Token

This query retrieves the first buyers of a token on Arbitrum, one row per wallet, from the token's first trade onward. Replace the token address in the Currency SmartContract field.

{
  EVM(dataset: combined, network: arbitrum) {
    buyside: DEXTrades(
      limit: {count: 10}
      limitBy: {by: Transaction_From, count: 1}
      orderBy: {ascending: Block_Time}
      where: {Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
          }
          Seller
          Price
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

Get Least Traded Token

The following query gets the least traded tokens over the last week on Arbitrum. By sorting DEX trades by the smallest trade count, it surfaces tokens with minimal trading activity in the period.

query MyQuery {
  EVM(dataset: combined, network: arbitrum) {
    DEXTradeByTokens(
      limit: {count: 10}
      where: {Block: {Time: {since_relative: {days_ago: 7}}}}
      orderBy: {ascendingByField: "count"}
    ) {
      Trade {
        Currency {
          Name
          SmartContract
        }
      }
      count
    }
  }
}

Open the above query on GraphQL IDE using this link.

Token trade from a specific DEX

If you are looking for token trades on a specific Arbitrum DEX, use the following API as an example. Here we get ARB trades from Uniswap v3 by passing uniswap_v3 in the ProtocolName filter. Protocol names describe the pool interface, so this also matches v3-compatible pools from other factories; add the factory to Dex.OwnerAddress when you mean Uniswap's own deployment.

{
  EVM(dataset: archive, network: arbitrum) {
    buyside: DEXTrades(
      limit: {count: 5}
      orderBy: {descending: Block_Time}
      where: {Trade: {Buy: {Currency: {SmartContract: {is: "0x912ce59144191c1204e64559fe8253a0e49e6548"}}}, Dex: {ProtocolName: {is: "uniswap_v3"}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
            SmartContract
          }
          Seller
          Price
        }
        Sell {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Seller
          Price
        }
        Dex {
          ProtocolFamily
          ProtocolName
          SmartContract
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

Address Trades API (Arbitrum Mainnet)

Latest Trades for a given address

This query retrieves the latest ten buy-side and sell-side trades on Arbitrum for a specific address.

{
  EVM(dataset: combined, network: arbitrum) {
    buyside: DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Buy: {Buyer: {is: "0x1f77dfeb0e6fed1ecf0b41d4c81330df6a6fb167"}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
            SmartContract
          }
          Seller
          Price
        }
        Sell {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Seller
          Price
        }
      }
    }
    sellside: DEXTrades(
      limit: {count: 10}
      orderBy: {descending: Block_Time}
      where: {Trade: {Buy: {Seller: {is: "0x1f77dfeb0e6fed1ecf0b41d4c81330df6a6fb167"}}}}
    ) {
      Block {
        Number
        Time
      }
      Transaction {
        From
        To
        Hash
      }
      Trade {
        Buy {
          Amount
          Buyer
          Currency {
            Name
            Symbol
            SmartContract
          }
          Seller
          Price
        }
        Sell {
          Amount
          Buyer
          Currency {
            Name
            SmartContract
            Symbol
          }
          Seller
          Price
        }
      }
    }
  }
}

Open the above query on GraphQL IDE using this link.

Trades Where the Address is Buyer OR Seller

The query below gives you trades where the specified address is either the buyer or the seller, using the any filter as an OR condition across both roles.

query MyQuery {
  EVM(dataset: archive, network: arbitrum) {
    DEXTrades(
      where: {any: [{Trade: {Buy: {Buyer: {is: "0x0938C63109801Ee4243a487aB84DFfA2Bba4589e"}}}},
        {Trade: {Buy: {Seller: {is: "0x0938C63109801Ee4243a487aB84DFfA2Bba4589e"}}}}]}
      limit: {count: 10}
      orderBy: {descending: Block_Time}
    ) {
      Trade {
        Buy {
          Buyer
          Amount
          Currency {
            Name
          }
        }
        Dex {
          ProtocolName
        }
        Sell {
          Buyer
          Price
          Currency {
            Name
          }
        }
      }
      Transaction {
        Hash
      }
    }
  }
}

Open the above query on GraphQL IDE using this link. For wallet-level analytics with USD attribution, leaderboards and PnL-style aggregates, the Traders API on the Trading cube is the shorter route.

Applications

Some of the things teams build with Arbitrum DEX data from these APIs:

  • Monitoring DEX Activity

    • The DEX trades API provides real-time and historical data on trades within the Arbitrum ecosystem. By querying it, you can track trading volumes, liquidity changes and price movements across DEXs.

    • Developers and traders use this data to monitor the health and performance of different DEX protocols: which tokens are most actively traded, which are emerging, and how liquidity pools evolve.

  • Algorithmic Trading Strategies

    • With trade data in hand, you can design and optimise algorithmic strategies that automate decisions on price moves, volume spikes or liquidity imbalances.

    • By integrating the APIs into trading bots, you can execute on Arbitrum DEXs efficiently, for instance rebalancing a portfolio by swapping tokens across DEXs to maintain target weightings.

  • Market Research and Insights

    • Researchers and analysts use the APIs to study the Arbitrum DEX landscape. Token transfers, liquidity pools and trade history reveal trends, anomalies and market behaviour.

    • Those insights inform investment decisions, guide token listings and give context on the health of the Arbitrum DEX ecosystem.

Conclusion

Bitquery's GraphQL APIs open up the data of Arbitrum's DEX ecosystem. As the L2 keeps growing, analysing on-chain activity across protocols like Uniswap, SushiSwap and 1inch is valuable for anyone building on it. With these APIs, developers can build tools to monitor real-time trading, research market dynamics and design algorithmic trading systems, and the ability to query historical trades, pools, smart contract events and other granular data opens up new opportunities. Whether you are an analyst, trader or builder, the queries above give you a working start.

Related reading

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.