BEPs icon indicating copy to clipboard operation
BEPs copied to clipboard

How to access the API

Open stychu opened this issue 4 years ago • 1 comments

How can I consume the API?? I would like to retrieve the data of the account addresses (balance/tokens held/amounts) in the NodeJs app. Can someone point me?

stychu avatar Apr 26 '21 11:04 stychu

I use web3js with NodeJS. Depending on if you use testnet or mainnet, the RPC endpoint is different.

mainnet: https://bsc-dataseed.binance.org/ testnet: https://data-seed-prebsc-1-s1.binance.org:8545/

Some API methods require WebSockets, so just replace "https" with "wss" in the RPC address and create new WebSocket provider.

For example:

var web3 = new Web3("https://bsc-dataseed.binance.org/");

or

var web3 = new Web3(new Web3.providers.WebsocketProvider("wss://bsc-dataseed.binance.org/"));

After that you can just look up in the API documentation to see how to pass parameters to the web3 object and its functions.

mtl1979 avatar Jun 07 '21 08:06 mtl1979