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

Blaschuko picture Blaschuko · Apr 11, 2021 · Viewed 8.2k times · Source

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!

Answer

Emindu picture Emindu · Apr 20, 2021

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.