Search code examples
binancebinance-smart-chain

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?


Solution

  • 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.