PancakeSwap GraphQL API (v3)

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

Background

PancakeSwap is an automated market maker(AMM) that allows two tokens to be exchanged on the BNB Chain. Millions of trades are being made on PancakeSwap every week. 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.

2872

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-v3/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

Factory
  • id: ID!
  • poolCount: BigInt!
  • txCount: BigInt!
  • totalVolumeETH: BigDecimal!
  • totalVolumeUSD: BigDecimal!
  • totalFeesUSD: BigDecimal!
  • totalFeesETH: BigDecimal!
  • totalValueLockedUSD: BigDecimal!
  • totalValueLockedETH: BigDecimal!
  • totalValueLockedUSDUntracked: BigDecimal!
  • totalValueLockedETHUntracked: BigDecimal!
  • totalProtocolFeesUSD: BigDecimal!
  • totalProtocolFeesETH: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • owner: ID!
Bundle
  • id: ID!
  • ethPriceUSD: BigDecimal!
Token
  • id: ID!
  • name: String!
  • symbol: String!
  • decimals: BigInt!
  • totalSupply: BigInt!
  • txCount: BigInt!
  • volume: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • poolCount: BigInt!
  • totalValueLocked: BigDecimal!
  • totalValueLockedUSD: BigDecimal!
  • totalValueLockedUSDUntracked: BigDecimal!
  • derivedETH: BigDecimal
  • derivedUSD: BigDecimal
  • whitelistPools: [Pool!]!
Pool
  • id: ID!
  • createdAtBlockNumber: BigInt!
  • token0: Token!
  • token1: Token!
  • feeTier: BigInt!
  • feeProtocol: BigInt!
  • liquidity: BigInt!
  • sqrtPrice: BigInt!
  • feeGrowthGlobal0X128: BigInt!
  • feeGrowthGlobal1X128: BigInt!
  • tick: BigInt
  • observationIndex: BigInt!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • collectedFeesToken0: BigDecimal!
  • collectedFeesToken1: BigDecimal!
  • collectedFeesUSD: BigDecimal!
  • totalValueLockedToken0: BigDecimal!
  • totalValueLockedToken1: BigDecimal!
  • totalValueLockedETH: BigDecimal!
  • totalValueLockedUSD: BigDecimal!
  • totalValueLockedUSDUntracked: BigDecimal!
  • totalValueLockedETHUntracked: BigDecimal!
  • token0Price: BigDecimal!
  • token1Price: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • txCount: BigInt!
  • createdAtTimestamp: BigInt!
  • liquidityProviderCount: BigInt!
Swap
  • id: ID!
  • pool: Pool!
  • token0: Token!
  • token1: Token!
  • sender: Bytes!
  • origin: Bytes!
  • recipient: String!
  • amount0: BigDecimal!
  • amount1: BigDecimal!
  • amountUSD: BigDecimal!
  • amountFeeUSD: BigDecimal!
  • sqrtPriceX96: BigInt!
  • tick: BigInt!
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
Burn
  • id: ID!
  • pool: Pool!
  • token0: Token!
  • token1: Token!
  • owner: Bytes
  • origin: Bytes!
  • amount: BigInt!
  • amount0: BigDecimal!
  • amount1: BigDecimal!
  • amountUSD: BigDecimal
  • tickLower: BigInt!
  • tickUpper: BigInt!
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
Mint
  • id: ID!
  • pool: Pool!
  • token0: Token!
  • token1: Token!
  • owner: Bytes!
  • sender: Bytes
  • origin: Bytes!
  • amount: BigInt!
  • amount0: BigDecimal!
  • amount1: BigDecimal!
  • amountUSD: BigDecimal
  • tickLower: BigInt!
  • tickUpper: BigInt!
  • logIndex: BigInt
  • transaction: Transaction!
  • timestamp: BigInt!
Tick
  • id: ID!
  • poolAddress: String
  • tickIdx: BigInt!
  • pool: Pool!
  • liquidityGross: BigInt!
  • liquidityNet: BigInt!
  • price0: BigDecimal!
  • price1: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • collectedFeesToken0: BigDecimal!
  • collectedFeesToken1: BigDecimal!
  • collectedFeesUSD: BigDecimal!
  • createdAtTimestamp: BigInt!
  • createdAtBlockNumber: BigInt!
  • liquidityProviderCount: BigInt!
  • feeGrowthOutside0X128: BigInt!
  • feeGrowthOutside1X128: BigInt!
Transaction
  • id: ID!
  • blockNumber: BigInt!
  • timestamp: BigInt!
  • gasUsed: BigInt!
  • gasPrice: BigInt!
  • mints: [Mint!]!
  • burns: [Burn!]!
  • swaps: [Swap!]!
Collect
  • id: ID!
  • transaction: Transaction!
  • timestamp: BigInt!
  • pool: Pool!
  • owner: String
  • amount0: BigDecimal!
  • amount1: BigDecimal!
  • amountUSD: BigDecimal
  • tickLower: BigInt!
  • tickUpper: BigInt!
  • logIndex: BigInt
Flash
  • id: ID!
  • transaction: Transaction!
  • timestamp: BigInt!
  • pool: Pool!
  • sender: String!
  • recipient: String!
  • amount0: BigDecimal!
  • amount1: BigDecimal!
  • amountUSD: BigDecimal!
  • amount0Paid: BigDecimal!
  • amount1Paid: BigDecimal!
  • logIndex: BigInt
PancakeDayData
  • id: ID!
  • date: Int!
  • volumeETH: BigDecimal!
  • volumeUSD: BigDecimal!
  • volumeUSDUntracked: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • txCount: BigInt!
  • tvlUSD: BigDecimal!
PoolDayData
  • id: ID!
  • date: Int!
  • pool: Pool!
  • liquidity: BigInt!
  • sqrtPrice: BigInt!
  • token0Price: BigDecimal!
  • token1Price: BigDecimal!
  • tick: BigInt
  • feeGrowthGlobal0X128: BigInt!
  • feeGrowthGlobal1X128: BigInt!
  • tvlUSD: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • txCount: BigInt!
  • open: BigDecimal!
  • high: BigDecimal!
  • low: BigDecimal!
  • close: BigDecimal!
PoolHourData
  • id: ID!
  • periodStartUnix: Int!
  • pool: Pool!
  • liquidity: BigInt!
  • sqrtPrice: BigInt!
  • token0Price: BigDecimal!
  • token1Price: BigDecimal!
  • tick: BigInt
  • feeGrowthGlobal0X128: BigInt!
  • feeGrowthGlobal1X128: BigInt!
  • tvlUSD: BigDecimal!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • txCount: BigInt!
  • open: BigDecimal!
  • high: BigDecimal!
  • low: BigDecimal!
  • close: BigDecimal!
TickDayData
  • id: ID!
  • date: Int!
  • pool: Pool!
  • tick: Tick!
  • liquidityGross: BigInt!
  • liquidityNet: BigInt!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • feeGrowthOutside0X128: BigInt!
  • feeGrowthOutside1X128: BigInt!
TickHourData
  • id: ID!
  • periodStartUnix: Int!
  • pool: Pool!
  • tick: Tick!
  • liquidityGross: BigInt!
  • liquidityNet: BigInt!
  • volumeToken0: BigDecimal!
  • volumeToken1: BigDecimal!
  • volumeUSD: BigDecimal!
  • feesUSD: BigDecimal!
TokenDayData
  • id: ID!
  • date: Int!
  • token: Token!
  • volume: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • totalValueLocked: BigDecimal!
  • totalValueLockedUSD: BigDecimal!
  • priceUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • open: BigDecimal!
  • high: BigDecimal!
  • low: BigDecimal!
  • close: BigDecimal!
TokenHourData
  • id: ID!
  • periodStartUnix: Int!
  • token: Token!
  • volume: BigDecimal!
  • volumeUSD: BigDecimal!
  • untrackedVolumeUSD: BigDecimal!
  • totalValueLocked: BigDecimal!
  • totalValueLockedUSD: BigDecimal!
  • priceUSD: BigDecimal!
  • feesUSD: BigDecimal!
  • protocolFeesUSD: BigDecimal!
  • open: BigDecimal!
  • high: BigDecimal!
  • low: BigDecimal!
  • close: BigDecimal!
Position
  • id: ID!
  • owner: Bytes!
  • pool: Pool!
  • token0: Token!
  • token1: Token!
  • tickLower: Tick!
  • tickUpper: Tick!
  • liquidity: BigInt!
  • depositedToken0: BigDecimal!
  • depositedToken1: BigDecimal!
  • withdrawnToken0: BigDecimal!
  • withdrawnToken1: BigDecimal!
  • collectedFeesToken0: BigDecimal!
  • collectedFeesToken1: BigDecimal!
  • transaction: Transaction!
  • feeGrowthInside0LastX128: BigInt!
  • feeGrowthInside1LastX128: BigInt!
PositionSnapshot
  • id: ID!
  • owner: Bytes!
  • pool: Pool!
  • position: Position!
  • blockNumber: BigInt!
  • timestamp: BigInt!
  • liquidity: BigInt!
  • depositedToken0: BigDecimal!
  • depositedToken1: BigDecimal!
  • withdrawnToken0: BigDecimal!
  • withdrawnToken1: BigDecimal!
  • collectedFeesToken0: BigDecimal!
  • collectedFeesToken1: BigDecimal!
  • transaction: Transaction!
  • feeGrowthInside0LastX128: BigInt!
  • feeGrowthInside1LastX128: BigInt!

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
factory(block: Block_height): Factory

factories(
block: Block_height
skip: Int
first: Int
): [Factory!]!
bundle(
id: ID!
block: Block_height
): Bundle

bundles(
block: Block_height
first: Int
where: Bundle_filter
): [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: [totalValueLockedUSD]

OrderDirection: [asc, desc]

Token_filter:
id_in: [ID!]
symbol_contains: String
name_contains: String
id: ID
pool(
id: ID!
block: Block_height
): Pool

pools(
block: Block_height
skip: Int
first: Int
orderBy: Pool_orderBy
orderDirection: OrderDirection
where: Pool_filter
): [Pool!]!

Pool_orderBy: [totalValueLockedUSD]

OrderDirection: [asc, desc]

Pool_filter:
txCount_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]

OrderDirection: [asc, desc]

Swap_filter:
pool: String
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
token0: String
token1: 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]

OrderDirection: [asc, desc]

Burn_filter:
pool: String
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
token0: String
token1: 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]

OrderDirection: [asc, desc]

Mint_filter:
pool: String
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
token0: String
token1: String
tick(
id: ID!
block: Block_height
): Tick

ticks(
block: Block_height
skip: Int
first: Int
where: Tick_filter
orderBy: Tick_orderBy
orderDirection: OrderDirection
): [Tick!]!

Tick_orderBy: [id]

OrderDirection: [asc, desc]

Tick_filter:
poolAddress: String
tickIdx_lte: BigInt
tickIdx_gte: BigInt
transaction(
id: ID!
block: Block_height
): Transaction

transactions(
block: Block_height
skip: Int
first: Int
orderBy: Transaction_orderBy
orderDirection: OrderDirection
where: Transaction_filter
): [Transaction!]!

Transaction_orderBy: [timestamp]

OrderDirection: [asc, desc]

Transaction_filter:
timestamp_gt: BigInt
collect(
id: ID!
block: Block_height
): Collect

collects(
block: Block_height
skip: Int
first: Int
where: Collect_filter
): [Collect!]!

Collect_filter:
pool: ID
timestamp: BigInt
timestamp_gt: BigInt
timestamp_lt: BigInt
flash(
id: ID!
block: Block_height
): Flash

flashes(
block: Block_height
skip: Int
first: Int
): [Flash!]!
pancakeDayData(id: ID!): PancakeDayData

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

PancakeDayData_orderBy: [date]

OrderDirection: [asc, desc]

PancakeDayData_filter:
date_gt: Int
date_lt: Int
date: Int
poolDayData(id: ID!): PoolDayData

poolDayDatas(
skip: Int = 0
first: Int = 100
orderBy: PoolDayData_orderBy
orderDirection: OrderDirection
where: PoolDayData_filter
): [PoolDayData!]!

PoolDayData_orderBy:
date
volumeUSD

OrderDirection: [asc, desc]

PoolDayData_filter:
pool: Bytes
date_gt: Int
date_lt: Int
date: Int
txCount_gt: BigInt
token1_not_in: [String!]
token0_not_in: [String!]
id_in: [ID!]
poolHourData(id: ID!): PoolHourData

poolHourDatas(
skip: Int = 0
first: Int = 100
orderBy: PoolHourData_orderBy
orderDirection: OrderDirection
where: PoolHourData_filter
): [PoolHourData!]!

PoolHourData_orderBy: [periodStartUnix]

OrderDirection: [asc, desc]

PoolHourData_filter:
pool: String
id_in: [ID!]
periodStartUnix: Int
periodStartUnix_gt: Int
periodStartUnix_lt: Int
tickDayData(id: ID!): TickDayData

tickDayDatas(
skip: Int = 0
first: Int = 100
orderBy: TickDayData_orderBy
orderDirection: OrderDirection
where: TickDayData_filter
): [TickDayData!]!

TickDayData_orderBy: [date]

OrderDirection: [asc, desc]

TickDayData_filter:
tick: String
date_gt: Int
date_lt: Int
date: Int
id_in: [ID!]
pool: String
tickHourData(id: ID!): TickHourData

tickHourDatas(
skip: Int = 0
first: Int = 100
orderBy: TickHourData_orderBy
orderDirection: OrderDirection
where: TickHourData_filter
): [TickHourData!]!

TickHourData_orderBy: [periodStartUnix]

OrderDirection: [asc, desc]

TickHourData_filter:
tick: String
id_in: [ID!]
periodStartUnix: Int
periodStartUnix_gt: Int
periodStartUnix_lt: Int
tokenDayData(id: ID!): TokenDayData

tokenDayDatas(
skip: Int = 0
first: Int = 100
orderBy: TokenDayData_orderBy
orderDirection: OrderDirection
where: TokenDayData_filter
): [TokenDayData!]!

TokenDayData_orderBy: [date]

OrderDirection: [asc, desc]

TokenDayData_filter:
id_not_in: [ID!]
date_gt: Int
date_lt: Int
date: Int
token: String
id_in: [ID!]
tokenHourData(id: ID!): TokenHourData

tokenHourDatas(
skip: Int = 0
first: Int = 100
orderBy: TokenHourData_orderBy
orderDirection: OrderDirection
where: TokenHourData_filter
): [TokenHourData!]!

TokenHourData_orderBy: [periodStartUnix]

OrderDirection: [asc, desc]

TokenHourData_filter:
token: String
periodStartUnix: Int
periodStartUnix_gt: Int
periodStartUnix_lt: Int
id_in: [ID!]
position(
id: ID!
block: Block_height
): Position

positions(
skip: Int = 0
first: Int = 100
block: Block_height
where: Position_filter
): [Position!]!

Position_filter:
poolAddress: String
id_in: [ID!]
positionSnapshot(
id: ID!
block: Block_height
): PositionSnapshot

positionSnapshots(
skip: Int = 0
first: Int = 100
block: Block_height
orderBy: PositionSnapshot_orderBy
orderDirection: OrderDirection
where: PositionSnapshot_filter
): [PositionSnapshot!]!

PositionSnapshot_orderBy: [timestamp] 

OrderDirection: [asc, desc]

PositionSnapshot_filter:
poolAddress: String
id_in: [ID!]
position: String
timestamp: BigInt

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.

{
	pancakeDayDatas(
      first: 1000
      skip: 0
      where: { date_gt: 1682137785}
      orderBy: date
      orderDirection: asc
    ) {
      id
      date
      volumeUSD
      tvlUSD
    }
  }

And you will get a response like the one below:

{
  "data": {
    "pancakeDayDatas": [
      {
        "id": "19470",
        "date": 1682208000,
        "volumeUSD": "27668950.65082369018456667274557251",
        "tvlUSD": "195296131.5364152111428771303537669"
      }
    ]
  }
}

Rate limit

To ensure the overall performance of the entire service, we set a daily rate limit for all users. For free trial users, the rate limit would be up to 200 queries per day. Meanwhile, we also provide a much higher rate limit of 20,000 queries per day or a customized rate limit for paid customers.

Please reach out on our Discord channel if you're interested in even higher throughput.