PancakeSwap GraphQL API

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

Background

PancakeSwap is an automated market maker(AMM) that allows two tokens to be exchanged on the BNB Chain. 23 million trades have been made on PancakeSwap in the past 30 days and more than 1.9 million monthly active users are trading on PancakeSwap. It generated tremendous transaction data on BNB Chain, it is highly time-consuming to retrieve those data for any analyzing purpose. 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 PancakeSwap data.

Get started

NodeReal MegaNode is a multi-chain infrastructure service provider. We indexed the PancakeSwap 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 BNB Smart Chain (BSC) app on MegaNode, you can find your API key via this doc.

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

28722872

Find the API endpoint for the PancakeSwap 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}/pancakeswap/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.

📘

How do I see the detailed schema?

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

Fields

PancakeFactory
  • id: ID!
  • totalPairs: BigInt!
  • totalTransactions: BigInt!
  • totalVolumeBNB: BigDecimal!
  • totalVolumeUSD: BigDecimal!
  • totalLiquidityBNB: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
Bundle
  • id: ID!
  • bnbPrice: BigDecimal!
Token
  • id: ID!
  • name: String!
  • symbol: String!
  • decimals: BigInt!
  • totalTransactions: BigInt!
  • tradeVolume: BigDecimal!
  • tradeVolumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • totalLiquidity: BigDecimal!
  • derivedBNB: BigDecimal
  • derivedUSD: BigDecimal
Pair
  • id: ID!
  • block: BigInt!
  • name: String!
  • token0: Token!
  • token1: Token!
  • reserve0: BigDecimal!
  • reserve1: BigDecimal!
  • totalSupply: BigDecimal!
  • reserveBNB: BigDecimal!
  • reserveUSD: BigDecimal!
  • trackedReserveBNB: BigDecimal!
  • token0Price: BigDecimal!
  • token1Price: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • totalTransactions: BigInt!
  • timestamp: BigInt!
Swap
  • id: ID!
  • pair: Pair!
  • sender: String!
  • from: String!
  • to: String!
  • amount0In: BigDecimal!
  • amount1In: BigDecimal!
  • amount0Out: BigDecimal!
  • amount1Out: BigDecimal!
  • amountUSD: BigDecimal!
  • token0: Token!
  • token1: Token!
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
Burn
  • id: ID!
  • pair: Pair!
  • sender: String
  • to: String
  • liquidity: BigDecimal!
  • amount0: BigDecimal
  • amount1: BigDecimal
  • amountUSD: BigDecimal
  • token0: Token!
  • token1: Token!
  • 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
  • token0: Token!
  • token1: Token!
  • feeTo: String
  • feeLiquidity: BigDecimal
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
PancakeDayData
  • id: ID!
  • date: Int!
  • dailyVolumeBNB: BigDecimal!
  • dailyVolumeUSD: BigDecimal!
  • dailyVolumeUntracked: BigDecimal!
  • totalVolumeBNB: BigDecimal!
  • totalLiquidityBNB: BigDecimal!
  • totalVolumeUSD: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • totalTransactions: 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!
  • dailyVolumeBNB: BigDecimal!
  • dailyVolumeUSD: BigDecimal!
  • dailyTxns: BigInt!
  • totalLiquidityToken: BigDecimal!
  • totalLiquidityBNB: BigDecimal!
  • totalLiquidityUSD: BigDecimal!
  • priceUSD: 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
pancakeFactory(block: Block_height): PancakeFactory

pancakeFactories(
    block: Block_height
    skip: Int
    first: Int
): [PancakeFactory!]!
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!]!

Token_orderBy:[tradeVolumeUSD]

Token_filter:
id_in: [ID!]
symbol_contains: String
name_contains: String
id: ID
pair(id: ID!block: Block_height): Pair

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

Pair_orderBy: [trackedReserveBNB]

Pair_filter:
totalTransactions_gt: BigInt
token0: String
token1: String
token1_in: [String!]
token0_in: [String!]
token1_not_in: [String!]
token0_not_in: [String!]
id_in: [ID!]
id: ID
swap(id: ID!block: Block_height): Swap

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

Swap_orderBy: [timestamp]

Swap_filter:
pair: ID
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
timestamp_gte: BigInt
timestamp_lte: BigInt
token0: String
token1: String
from_in: [String!]
burn(id: ID!block: Block_height): Burn

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

Burn_orderBy:[timestamp]

Burn_filter:
pair: ID
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
timestamp_gte: BigInt
timestamp_lte: BigInt
token0: String
token1: String
from_in: [String!]
mint(id: ID!block: Block_height): Mint

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

Mint_orderBy:[timestamp]

Mint_filter:
pair: ID
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
timestamp_gte: BigInt
timestamp_lte: BigInt
token0: String
token1: String
from_in: [String!]
pancakeDayData(id: ID!block: Block_height): PancakeDayData

pancakeDayDatas(
    block: Block_height
    skip: Int = 0
    first: Int = 100
    orderBy: PancakeDayData_orderBy
    orderDirection: OrderDirection
    where: PancakeDayData_filter
): [PancakeDayData!]!

PancakeDayData_orderBy:[date]

PancakeDayData_filter:
date_gt: Int
date_lt: Int
date: Int
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!]!

PairDayData_orderBy:
date
dailyVolumeUSD

PairDayData_filter:
pairAddress: Bytes
date_gt: Int
date_lt: Int
date: Int
dailyTxns_gt: BigInt
token1_not_in: [String!]
token0_not_in: [String!]
id_in: [ID!]
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!]!

PairHourData_orderBy:[hourStartUnix]

PairHourData_filter:
pair: String
id_in: [ID!]
hourStartUnix: Int
hourStartUnix_gt: Int
hourStartUnix_lt: Int
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!]!

TokenDayData_orderBy:
dailyVolumeUSD
date

TokenDayData_filter:
dailyTxns_gt: BigInt
id_not_in: [ID!]
date_gt: Int
date_lt: Int
date: Int
token: String
id_in: [ID!]

Example

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

{
   pairDayDatas( first: 2, skip: 0,  
   where: { date_gt: 1659312000,
           pairAddress: "0xfffEEb211f1595C9f8f009e3C25E9d20FCd3ce12"})
    { 
      pairAddress{
          id
          name
      }
      date
      dailyVolumeUSD
      dailyTxns
      dailyVolumeToken0
      dailyVolumeToken1
      reserve0
      reserve1
      reserveUSD
      totalSupply
   }
}

And you will get response like below:

{
    "data": {
        "pairDayDatas": [
            {
                "pairAddress": {
                    "id": "0xfffEEb211f1595C9f8f009e3C25E9d20FCd3ce12",
                    "name": "USDT-Fur"
                },
                "date": 1668988800,
                "dailyVolumeUSD": "745.7557594185595978648444826447389",
                "dailyTxns": "27",
                "dailyVolumeToken0": "746.306139700233418245",
                "dailyVolumeToken1": "5466465.243069333075185868",
                "reserve0": "22406.423472981004263245",
                "reserve1": "163717180.433436002579366878",
                "reserveUSD": "44745.50632988952446193094223780751",
                "totalSupply": "1904539.902635980320022535"
            },
            {
                "pairAddress": {
                    "id": "0xfffEEb211f1595C9f8f009e3C25E9d20FCd3ce12",
                    "name": "USDT-Fur"
                },
                "date": 1668902400,
                "dailyVolumeUSD": "1796.24199764574073717592429106566",
                "dailyTxns": "72",
                "dailyVolumeToken0": "1795.972432838066686666",
                "dailyVolumeToken1": "13137270.761319455264442373",
                "reserve0": "22404.72961268123768149",
                "reserve1": "163715909.978576818478552746",
                "reserveUSD": "44774.54132879345571480305392559092",
                "totalSupply": "1904539.902635980320022535"
            }
        ]
    }
}

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.