Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PancakeSwap API / Swaping BNB with Binance Smart Chain's API

I was wondering if there's a PancakeSwap API, that allows me to swap BNB for a token, and if it isn't possible, can I do it with Binance Smart Chain's API?

Thank you!

like image 455
Blaschuko Avatar asked Apr 11 '21 19:04

Blaschuko


People also ask

What API does PancakeSwap use?

The PancakeSwap API is a set of endpoints used by market aggregators (e.g. coinmarketcap.com) to surface PancakeSwap liquidity and volume information. All information is fetched from the underlying subgraphs.

Does PancakeSwap have API?

PancakeSwap is a popular decentralized exchange built on the Binance Smart Chain (BSC). We can use the PancakeSwap API to obtain liquidity and volume information from the PancakeSwap platform.


1 Answers

pancakeswap currently doesn't have APIs or sdk as Uniswap sdk. Best solution is connect to binance smart chain and connect to the pancakeswap router contract through web3.

function swapExactTokensForTokens(
    uint amountIn,
    uint amountOutMin,
    address[] calldata path,
    address to,
    uint deadline
)

This is the function for swap tokens. You can refer the uniswap doc to get more information.

like image 124
Emindu Avatar answered Nov 13 '22 09:11

Emindu