Uniswap API: Get Pools Data, Tokens and Create Charts

ยท

The decentralized finance (DeFi) landscape continues to expand, and Uniswap remains one of the most influential protocols powering on-chain trading. For developers, analysts, and crypto enthusiasts, accessing real-time and historical data from Uniswap is essential for building dashboards, conducting market research, or analyzing liquidity trends. This guide walks you through using GraphQL APIs to extract key information such as newly created pools, token details, initial liquidity, and live token balances โ€” all critical for creating insightful visualizations and analytics tools.

Whether you're building a DeFi analytics platform or simply exploring how automated market makers (AMMs) function under the hood, understanding how to query Uniswap V2 data will give you a competitive edge.

๐Ÿ‘‰ Discover how to power your DeFi analytics with real-time blockchain data

Understanding Uniswap Pools and Pair Creation

In Uniswap V2, anyone can create a liquidity pool between two ERC20 tokens. When a user deploys a new pool, they must provide initial liquidity for both assets to establish a starting price. This process triggers the PairCreated event, which is emitted by the Uniswap Factory smart contract.

Each pool itself functions as an ERC20 token โ€” often referred to as LP (liquidity provider) tokens โ€” representing ownership shares in the pool. These tokens are minted upon deposit and burned when liquidity is withdrawn.

To retrieve information about newly created pools, we leverage blockchain data via GraphQL queries that tap directly into Ethereum event logs. The core of this process lies in monitoring the PairCreated event from the Uniswap V2 Factory contract.

Core Keywords

Querying Newly Created Uniswap Pools

To fetch the latest pool creations, use the following GraphQL query targeting the Uniswap V2 Factory address (0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f) and filtering for the PairCreated event:

{
  ethereum {
    arguments(
      smartContractAddress: {is: "0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f"}
      smartContractEvent: {is: "PairCreated"}
      options: {desc: "block.height", limit: 3}
    ) {
      block {
        height
      }
      argument {
        name
      }
      reference {
        address
      }
    }
  }
}

This returns three key pieces of data per event:

By sorting results by block height in descending order, you get the most recent pools at the top.

Retrieving Token Information

Once you have the token addresses from a pool creation event, you can query their metadata โ€” including symbol, name, decimals, and token standard.

For example, to get details about token0 (0x930ed81ad809603baf727117385d01f04354612e), run:

{
  ethereum {
    address(address: {is: "0x930ed81ad809603baf727117385d01f04354612e"}) {
      annotation
      address
      smartContract {
        contractType
        currency {
          symbol
          name
          decimals
          tokenType
        }
      }
      balance
    }
  }
}

This reveals that the token is named SOLARITE, uses 18 decimals, and conforms to the ERC20 standard โ€” crucial details for accurate charting and valuation.

๐Ÿ‘‰ Build advanced DeFi dashboards with seamless API access

Analyzing Initial Liquidity in New Pools

Initial liquidity determines a poolโ€™s trading depth and slippage characteristics. You can determine how much of each token was deposited at launch by identifying the first two incoming transfers to the pool address.

Using the pair address (0x7bc3a77b1b8daa4bf4b38c710119b932c5b27925), query the earliest positive transfers:

{
  ethereum {
    transfers(
      options: {asc: "block.timestamp.time", limit: 2}
      amount: {gt: 0}
      receiver: {is: "0x7bc3a77b1b8daa4bf4b38c710119b932c5b27925"}
    ) {
      block {
        timestamp {
          time(format: "%Y-%m-%d %H:%M:%S")
        }
        height
      }
      sender {
        address
        annotation
      }
      currency {
        address
        symbol
      }
      amount
      transaction {
        hash
      }
      external
    }
  }
}

Results show that 0.08 SOLARITE and 200 yDAI+yUSDC+yUSDT+yTUSD were deposited in the same transaction โ€” confirming initial liquidity provisioning.

Checking Current Token Balances in a Pool

Pools accumulate trades over time, altering their internal reserves. To monitor current holdings, query the balance state of the pool address:

{
  ethereum {
    address(address: {is: "0x7bc3a77b1b8daa4bf4b38c710119b932c5b27925"}) {
      balances {
        currency {
          symbol
        }
        value
      }
    }
  }
}

Output includes:

These values reflect post-trade accumulation and are vital for calculating price trends and impermanent loss.

FAQ: Frequently Asked Questions

Q: What is the difference between a token pair and a liquidity pool?
A: A token pair defines which two assets are tradable against each other. The liquidity pool is the actual smart contract holding reserves of both tokens, enabling automated trading via algorithmic pricing.

Q: Can I track all Uniswap V2 pools with this method?
A: Yes. Since every pool creation emits a PairCreated event from the same factory contract, you can paginate through historical events to index all pools ever created.

Q: How often should I poll for new pools?
A: For near real-time updates, polling every 10โ€“15 seconds is sufficient. Alternatively, consider streaming APIs for instant notifications.

Q: Why does the pool show a balance of โ€œUNI-V2โ€?
A: Every Uniswap V2 pool mints its own LP tokens (named UNI-V2 by default). This balance typically reflects total supply or individual holdings if queried for specific users.

Q: Is this approach applicable to other DEXs?
A: Yes. Most AMMs like SushiSwap or PancakeSwap use similar event-driven architectures. Adjusting the factory address and event name allows cross-protocol analysis.

๐Ÿ‘‰ Access powerful tools to analyze DEX activity across chains

Creating Charts and Visualizations

With structured data on pool creation, token metadata, and reserve balances, you can now build dynamic charts:

Combine this with volume and trade data (available via extended queries) to create comprehensive DeFi dashboards.

Final Thoughts

GraphQL provides a flexible, efficient way to extract granular insights from Ethereum-based protocols like Uniswap. By focusing on event logs and token transfers, you gain full visibility into liquidity dynamics โ€” empowering developers, researchers, and investors alike.

As DeFi evolves, having direct access to raw blockchain data becomes increasingly valuable. Whether you're monitoring emerging tokens or auditing pool health, mastering these queries equips you with real-time intelligence straight from the source.

Remember to clean and normalize data before visualization โ€” especially handling decimal precision and filtering out test or spam deployments.

With the right tools and approach, building your own analytics engine around Uniswap and other DEX platforms is not only possible but highly scalable.