Uniswap GraphQL API

This document introduces how to send your first GraphQL request to fetch PancakeSwap data on NodeReal

Background

Uniswap is an automated market maker(AMM) that allows two tokens to be exchanged on EVM-compatible blockchains, it allows users anywhere in the world to trade crypto without an intermediary. Uniswap is the first and largest decentralized finance (or DeFi) application on Ethereum. As of April 2021, Uniswap had processed over $10 billion in weekly trading volume. NodeReal, a one-stop Web3 infrastructure service provider, has enabled JSON-RPC and enhanced APIs to help Web3 developers get the data they need. Now, we’re more than happy to share with you, NodeReal officially supports GraphQL queries with Uniswap data.

Get started

NodeReal MegaNode is a multi-chain infrastructure service provider. We indexed the Uniswap data and made it accessible to all Web3 users on the MegaNode platform. So, the first thing you need to do is Create a MegaNode account.

Once you created your MegaNode account and created your app on MegaNode, you can find your API key via this doc.

Lastly, you can find the latest GraphQL endpoint on our API marketplace.

2872

Find the API endpoint for the Uniswap project

Or, you can simply find the endpoint below, and then you can start to send requests to retrieve the PancakeSwap data you need:

https://open-platform.nodereal.io/{API-KEY}/uniswap/graphql/

📘

How do I get the API key?

You can get the API key from your MegaNode app. Please refer to this link.
Also, you will need to replace the {API-KEY} here with your API key.

Let me recap what you will need to access the data:

  • Get a MegaNode account and create an app
  • Copy the API key
  • Start sending GraphQL requests with the endpoint

Scope

🚧

BETA notice

In this phase, we enabled the PancakeSwap GraphQL with a BETA version. It means only some specific fields and filters are available when sending requests.

📘

Where can I find the detailed schema?

You can unfold the detailed scheme by clicking the filed name below.

Fields

UniswapFactory
  • id: ID!
  • pairCount: Int!
  • txCount: BigInt!
  • totalVolumeETH: BigDecimal!
  • totalVolumeUSD: BigDecimal!
  • totalLiquidityETH: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
Bundle
  • id: ID!
  • ethPrice: BigDecimal!
Token
  • id: ID!
  • name: String!
  • symbol: String!
  • decimals: BigInt!
  • totalSupply: BigInt!
  • txCount: BigInt!
  • tradeVolume: BigDecimal!
  • tradeVolumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • totalLiquidity: BigDecimal!
  • derivedETH: BigDecimal
Pair
  • id: ID!
  • createdAtBlockNumber: BigInt!
  • token0: Token!
  • token1: Token!
  • reserve0: BigDecimal!
  • reserve1: BigDecimal!
  • totalSupply: BigDecimal!
  • reserveETH: BigDecimal!
  • reserveUSD: BigDecimal!
  • trackedReserveETH: BigDecimal!
  • token0Price: BigDecimal!
  • token1Price: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • txCount: BigInt!
  • createdAtTimestamp: BigInt!
  • liquidityProviderCount: BigInt!
Swap
  • id: ID!
  • pair: Pair!
  • sender: String!
  • from: String!
  • to: String!
  • amount0In: BigDecimal!
  • amount1In: BigDecimal!
  • amount0Out: BigDecimal!
  • amount1Out: BigDecimal!
  • amountUSD: BigDecimal!
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
Burn
  • id: ID!
  • pair: Pair!
  • sender: String
  • to: String
  • liquidity: BigDecimal!
  • amount0: BigDecimal
  • amount1: BigDecimal
  • amountUSD: BigDecimal
  • logIndex: BigInt
  • feeTo: String
  • feeLiquidity: BigDecimal!
  • needsComplete: Boolean!
  • transaction: Transaction!
  • timestamp: BigInt!
Mint
  • id: ID!
  • pair: Pair!
  • sender: String
  • to: String!
  • liquidity: BigDecimal!
  • amount0: BigDecimal
  • amount1: BigDecimal
  • amountUSD: BigDecimal
  • feeTo: String
  • feeLiquidity: BigDecimal
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
UniswapDayData
  • id: ID!
  • date: Int!
  • dailyVolumeETH: BigDecimal!
  • dailyVolumeUSD: BigDecimal!
  • dailyVolumeUntracked: BigDecimal!
  • totalVolumeETH: BigDecimal!
  • totalLiquidityETH: BigDecimal!
  • totalVolumeUSD: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • txCount: BigInt!
PairDayData
  • id: ID!
  • date: Int!
  • pairAddress: Pair!
  • token0: Token!
  • token1: Token!
  • reserve0: BigDecimal!
  • reserve1: BigDecimal!
  • totalSupply: BigDecimal!
  • reserveUSD: BigDecimal!
  • dailyVolumeToken0: BigDecimal!
  • dailyVolumeToken1: BigDecimal!
  • dailyVolumeUSD: BigDecimal!
  • dailyTxns: BigInt!
PairHourData
  • id: ID!
  • hourStartUnix: Int!
  • pair: Pair!
  • reserve0: BigDecimal!
  • reserve1: BigDecimal!
  • totalSupply: BigDecimal!
  • reserveUSD: BigDecimal!
  • hourlyVolumeToken0: BigDecimal!
  • hourlyVolumeToken1: BigDecimal!
  • hourlyVolumeUSD: BigDecimal!
  • hourlyTxns: BigInt!
TokenDayData
  • id: ID!
  • date: Int!
  • token: Token!
  • dailyVolumeToken: BigDecimal!
  • dailyVolumeETH: BigDecimal!
  • dailyVolumeUSD: BigDecimal!
  • dailyTxns: BigInt!
  • totalLiquidityToken: BigDecimal!
  • totalLiquidityETH: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • priceUSD: BigDecimal!
User
  • id: ID!
  • usdSwapped: BigDecimal!
LiquidityPosition
  • id: ID!
  • user: User!
  • pair: Pair!
  • liquidityTokenBalance: BigDecimal!
LiquidityPositionSnapshot
  • id: ID!
  • liquidityPosition: LiquidityPosition!
  • timestamp: Int!
  • block: Int!
  • user: User!
  • pair: Pair!
  • token0PriceUSD: BigDecimal!
  • token1PriceUSD: BigDecimal!
  • reserve0: BigDecimal!
  • reserve1: BigDecimal!
  • reserveUSD: BigDecimal!
  • liquidityTokenTotalSupply: BigDecimal!
  • liquidityTokenBalance: BigDecimal!

Arguments, Filters & Sorts

As you can use different filters and sorts in your GraphQL query, here we outlined the arguments, filters, and sorts.

🚧

Limitation of first & skip

To ensure the overall performance, we limit the usage of the first and skip range to be below:

  • first: 1 - 1000
  • skip: 0 - 2000
uniswapFactory(block: Block_height): UniswapFactory

uniswapFactories(
    block: Block_height
    skip: Int
    first: Int
): [UniswapFactory!]!
bundle(
    id: ID!
    block: Block_height
): Bundle

bundles(block: Block_height): [Bundle!]!
token(
    id: ID!
    block: Block_height
): Token

tokens(
    block: Block_height
    skip: Int
    first: Int
    orderBy: Token_orderBy
    orderDirection: OrderDirection
    where: Token_filter
): [Token!]!
pair(
    id: ID!
    block: Block_height
): Pair

pairs(
    block: Block_height
    skip: Int
    first: Int
    orderBy: Pair_orderBy
    orderDirection: OrderDirection
    where: Pair_filter
): [Pair!]!
swap(
    id: ID!
    block: Block_height
): Swap

swaps(
    block: Block_height
    skip: Int
    first: Int
    orderBy: Swap_orderBy
    orderDirection: OrderDirection
    where: Swap_filter
): [Swap!]!
burn(
    id: ID!
    block: Block_height
): Burn

burns(
    block: Block_height
    skip: Int
    first: Int
    orderBy: Burn_orderBy
    orderDirection: OrderDirection
    where: Burn_filter
): [Burn!]!
mint(
    id: ID!
    block: Block_height
): Mint

mints(
    block: Block_height
    skip: Int
    first: Int
    orderBy: Mint_orderBy
    orderDirection: OrderDirection
    where: Mint_filter
): [Mint!]!
uniswapDayData(
    id: ID!
    block: Block_height
): UniswapDayData

uniswapDayDatas(
    block: Block_height
    skip: Int = 0
    first: Int = 100
    orderBy: UniswapDayData_orderBy
    orderDirection: OrderDirection
    where: UniswapDayData_filter
): [UniswapDayData!]!
pairDayData(
    id: ID!
    block: Block_height
): PairDayData

pairDayDatas(
    skip: Int = 0
    first: Int = 100
    orderBy: PairDayData_orderBy
    orderDirection: OrderDirection
    where: PairDayData_filter
    block: Block_height
): [PairDayData!]!
pairHourData(
    id: ID!
    block: Block_height
): PairHourData

pairHourDatas(
    skip: Int = 0
    first: Int = 100
    orderBy: PairHourData_orderBy
    orderDirection: OrderDirection
    where: PairHourData_filter
    block: Block_height
): [PairHourData!]!
tokenDayData(
    id: ID!
    block: Block_height
): TokenDayData

tokenDayDatas(
    skip: Int = 0
    first: Int = 100
    orderBy: TokenDayData_orderBy
    orderDirection: OrderDirection
    where: TokenDayData_filter
    block: Block_height
): [TokenDayData!]!
user(
    id: ID!
    block: Block_height
): User

users(
    skip: Int = 0
    first: Int = 100
    block: Block_height
): [User!]!
liquidityPosition(
    id: ID!
    block: Block_height
): LiquidityPosition

liquidityPositions(
    skip: Int = 0
    first: Int = 100
    block: Block_height
): [LiquidityPosition!]!
liquidityPositionSnapshot(
    id: ID!
    block: Block_height
): LiquidityPositionSnapshot

liquidityPositionSnapshots(
    skip: Int = 0
    first: Int = 100
    block: Block_height
): [LiquidityPositionSnapshot!]!

Example

As soon as you have a valid API endpoint for Uniswap GraphQL, you can send requests with corresponding fields and filters. Below is an example for pairDayDatas.

{
  pairDayDatas(
    first: 3
    skip: 0
    where: {date_gt: 1659312000, pairAddress: "0xfFE8df2f623BFD954D785809185bEB291330C70d"}
  ) {
    pairAddress
    date
    dailyVolumeUSD
    dailyTxns
    dailyVolumeToken0
    dailyVolumeToken1
    reserve0
    reserve1
    reserveUSD
    totalSupply
  }
}
{
  "data": {
    "pairDayDatas": [
      {
        "pairAddress": "0xfFE8df2f623BFD954D785809185bEB291330C70d",
        "date": 1672272000,
        "dailyVolumeUSD": "3478.132373668739763926004415904876",
        "dailyTxns": "8",
        "dailyVolumeToken0": "1575168.815974852785308661",
        "dailyVolumeToken1": "2.923659623552846833",
        "reserve0": "18590209.751511082571868974",
        "reserve1": "34.611144427234167055",
        "reserveUSD": "82458.44769800005731452228543695124",
        "totalSupply": "11803.697868214186368078"
      },
      {
        "pairAddress": "0xfFE8df2f623BFD954D785809185bEB291330C70d",
        "date": 1672185600,
        "dailyVolumeUSD": "13572.8533926054187736910304722506",
        "dailyTxns": "35",
        "dailyVolumeToken0": "6140831.673535669551067282",
        "dailyVolumeToken1": "11.237651818732179319",
        "reserve0": "19021785.639003238531772195",
        "reserve1": "33.817331185660165406",
        "reserveUSD": "80763.8172000839111710890416586289",
        "totalSupply": "11803.697868214186368078"
      },
      {
        "pairAddress": "0xfFE8df2f623BFD954D785809185bEB291330C70d",
        "date": 1672099200,
        "dailyVolumeUSD": "20909.05954497157355765226511654595",
        "dailyTxns": "57",
        "dailyVolumeToken0": "9960277.066055746995864189",
        "dailyVolumeToken1": "17.338073312290742871",
        "reserve0": "19452251.373932409560106031",
        "reserve1": "33.036698245560457397",
        "reserveUSD": "80050.28893115049934728452923869738",
        "totalSupply": "11803.697868214186368078"
      }
    ]
  }
}

Rate limit

To ensure the overall performance of the entire service, we set a daily rate limit for all users. In this free-trial period, the rate limit would be up to 2,880 queries per day. Please reach out on our Discord channel if you're interested in higher throughput.