PancakeSwap – Querying DEXs on Binance Smart Chain using GraphQL APIs

With more than $900 million in trade volume and 1.9 million trades, PancakeSwap is one of the most popular DEX on the Binance smart chain. Today we will show you how to get PancakeSwap data and create charts using Bitquery GraphQL APIs.

If you don’t know about Pancake swap, it’s a fork of Uniswap protocol, a popular DEX protocol on Ethereum.

The way PancakeSwap works is that it allows liquidity providers to create token pairs/pools and provide liquidity to them, which will be used to enable trades on the DEX. In return, liquidity providers earn a fee in every trade.

To show the stats about the DEX, pairs tokens, Pancake has forked Uniswap’s analytical dashboard. However, to maintain this dashboard, they need to dedicate dev and infra resources. Because they need to change the code according to their own protocol and run a Binance node to extract, store, and index data to build analytics.

We at Bitquery solves these types of problems for DApp developers and blockchain companies. This article will show you how to replicate and go beyond the current Pancake dashboard using our APIs.

No need to write code, no need to host an application, no need to run Binance node, just HTML and JS and our GraphQL queries. So let’s start.

Note: If you are not familiar with GraphQL APIs, then you can start from here.

Pancake Volume and Trades

Let’s start small and query Pancake’s total trade volume and trades. For this, you can use the following query.

If you tweak the above query a little, you will get this volume monthly. For example, check the following query. 

Using our flexible date functionality, you can now get our data for any timeframe.

You can use simple Javascript and HTML and turn the above data into a chart. For example, check this JSFiddle.

All Latest Trades on Pancake

To get all the latest trades on the PancakeSwap, you can use our DEX Trade APIs, which makes is easy to query any trade-related data for any DEX on the blockchain. For example, check the following query.

We also provide market data with our blockchain APIs. As you can see, you will get USD value for different trade attributes, such as buy amount, sell amount, and transaction fee.

Pancake OHLC data

Let’s say you want to show charting for a particular pair on Pancake DEX. For this, you will need OHLC (Open High Low Close) data to create candles. We support OHLC data for different time frames. For example, in the following example, we are getting WBNB, and BUSD currency pair’s OHLC data for the 5-minute timeframe.

Latest PancakeSwap Pairs/Pools

As we discussed before, liquidity providers create token pairs/pools on DEX and provide liquidity.

Using the following API, you can pull all newly created Pancake pools. For this, we will use our arguments API, which will extract the pair argument from the PairCreated event of the PancakeFactory contract.

Information about a specific Pool

Pool’s are essentially BEP20 tokens. You will get these tokens when you add liquidity to the pool. Similarly, you can get your liquidity back by depositing these tokens back.

Let’s see how to get about a specific Pancake pool.

Note: We will take this Pancake pool as an example throughout the example.

Pool’s Volume and other stats

You can use our DEX APIs and just pass the pool’s smart contract address to get the data for a specific pool, as shown below.

Pool’s information date wise

If you tweak the above API slightly, you can also get this above data for different timeframes. For example, check the query below; it gets the same data as the above query but for every day.

All Trades of a Pool

Using our DEX APIs, you can get a Pancake pool’s trade just by providing the pool’s smart contract address. For example, we are passing WBNB-BUSD pair’s smart contract address.

Pool’s Mint

You can use our SmartContractEvent API to get data for any smart contract’s event. For example, whenever someone adds liquidity to a pool, the contract emits a Mint event. Similarly, you can use Burn events to get data whenever liquidity is removed from the pool.

Total Pooled Tokens in a Pool

You can use our balance API to get the total pooled token of a pool.

Trades for a specific token on the Pancake DEX

Let’s say you want to get all the trades for a specific token (ex- WBNB) on the Pancake DEX; you need to pass that token’s smart contract address as baseCurrency in the API. For example, check the following query.

PancakeSwap Active Users

You can use our APIs to analyze different properties of the PancakeSwap protocol. For example, let’s say you want to know the active users and the total smart contract calls on Pancake protocol; you can use the following query.

Building Charts and Dashboards

As we have shown above (check this and this), you can use our APIs for the data source and build charts using simple JS and HTML and combine them to create dashboards as we show in our previous article Offline dashboards.

This will reduce the existing burden from the DApps teams and help them analyze protocols further using our simple GraphQL APIs.

You don’t need to run any Binance node and extract and store data and build applications to show stats to your users. Just use our APIs and save your time and money.

Join our Telegram if you have any questions or looking to analyze DEX protocols and building DEX-specific tools.

Also Read

About Bitquery

Bitquery is a set of software tools that parse, index, access, search, and use information across blockchain networks in a unified way. Our products are:

  • Digital Assets API provides index information related to all major cryptocurrencies, coins, and tokens.
  • DEX API provides real-time deposits and transactions, trades, and other related data on different DEX protocols like Uniswap, Kyber Network, Airswap, Matching Network, etc.

If you have any questions about our products, ask them on our Telegram channel or email us at Also, subscribe to our newsletter below, we will keep you updated with the latest in the cryptocurrency world.