BNB Smart Chain API: What You Can Build
What a BNB Smart Chain (BSC) API provides: wallets, BNB and BEP-20 transfers, balances and webhooks, with request examples and the limits of public RPC.
Reviewed by Maurice Sobiera
A BNB Smart Chain API is a web interface for BNB Smart Chain (BSC), formerly Binance Smart Chain. It lets an application create wallets, send BNB and BEP-20 tokens, read balances and receive deposit notifications without running a BSC node. Your backend sends HTTPS requests, and the provider handles signing, broadcasting and chain access.
This article lists what such an API covers, shows two requests against the Chaingateway BSC endpoints, and explains when public RPC endpoints are enough.
What does a BSC API cover?
A BSC API covers the operations a payment or wallet backend needs. The Chaingateway endpoints, as listed in the OpenAPI file, fall into five groups:
| Group | Endpoints |
|---|---|
| Addresses | POST /api/v2/bsc/addresses creates a wallet, GET lists wallets, POST /api/v2/bsc/addresses/import imports a private key |
| Balances | GET /api/v2/bsc/balances/{address} for BNB, GET /api/v2/bsc/balances/{address}/bep20/{contract_address} for a BEP-20 token |
| Transfers | POST /api/v2/bsc/transactions for BNB, POST /api/v2/bsc/transactions/bep20 for BEP-20 tokens, POST /api/v2/bsc/transactions/bep721 for NFTs |
| Chain data | Latest block, block by number or hash, transaction, receipt, gas price, NFT owner and token URI |
| Webhooks | Create, update and delete webhooks, list notifications, list failed notifications and retry them |
All requests use a bearer token in the Authorization header. Send X-Network: testnet to use the test network. Without the header, the request goes to mainnet.
How do you check a balance and send BNB?
Check the balance with one GET request, then send BNB with one POST request. Both examples use the base URL https://app.chaingateway.io and a token from your dashboard.
curl https://app.chaingateway.io/api/v2/bsc/balances/0x0000000000000000000000000000000000001000 \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN" \ -H "X-Network: testnet"The response contains the balance as a decimal string:
{"status": 200, "ok": true, "message": "Balance fetched", "data": "0.000000000000000000"}To send BNB from a wallet that you created with the API, post the sender, the receiver, the amount and the wallet password. The gas fields are optional.
curl -X POST https://app.chaingateway.io/api/v2/bsc/transactions \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN" \ -H "X-Network: testnet" \ -H "Content-Type: application/json" \ -d '{"from": "0x...", "to": "0x...", "amount": "0.001", "password": "wallet-password"}'If the sender has too little BNB for the amount plus gas, the API returns status 422 with the node’s insufficient funds message. A wrong wallet password returns 401.
How do you read a token balance and a transaction?
Read a BEP-20 token balance with the wallet address and the token contract address in the path. Read a transaction with its hash. Both are GET requests with the same headers as above.
# BEP-20 token balancecurl https://app.chaingateway.io/api/v2/bsc/balances/0xWalletAddress/bep20/0xTokenContract \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN"
# Transaction with decoded datacurl https://app.chaingateway.io/api/v2/bsc/transactions/0xTransactionHash/decoded \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN"
# Current gas pricecurl https://app.chaingateway.io/api/v2/bsc/gasprice \ -H "Authorization: Bearer $CHAINGATEWAY_TOKEN"The balance endpoint returns the token amount as a decimal string, so you do not scale by the token’s decimals yourself. The decoded transaction endpoint returns a transaction in readable fields instead of raw hex data. An unknown hash returns a 422 response with the message transaction not found.
GET /api/v2/bsc/transactions lists your own transaction history. It lists only transactions that were made with the Chaingateway API, because Chaingateway does not index your addresses on its own. Use a webhook to see incoming transfers.
If you already hold a wallet, POST /api/v2/bsc/addresses/import imports its private key. Imported and new wallets use the same send and webhook endpoints.
How do you get notified of deposits?
Create a webhook with POST /api/v2/bsc/webhooks. The url field is required. Filter by to (a receiving address), by from, or by contractaddress for a token, and set type to BNB, BEP20 or BEP721. When a matching transaction is detected, Chaingateway posts the transaction data to your URL.
Webhooks are not retried automatically. A failed delivery appears in GET /api/v2/bsc/webhooks/notifications/failed, and POST /api/v2/bsc/webhooks/notifications/{id}/retry sends it again. Make your receiving endpoint idempotent, keyed on the transaction ID, so that a retry does not credit an account twice.
What is BEP-20?
BEP-20 is the token standard of BNB Smart Chain. According to its specification, it is derived from Ethereum’s ERC-20 and requires the functions symbol(), decimals(), totalSupply(), balanceOf(), transfer(), transferFrom(), approve() and allowance(). This is why the same wallet code works for tokens on BSC and on Ethereum, and why the Chaingateway BSC endpoints mirror the Ethereum ones.
When are public RPC endpoints enough?
BNB Chain publishes public JSON-RPC endpoints for mainnet and testnet. The BNB Chain documentation states a rate limit of 10,000 requests per 5 minutes, and says that eth_getLogs is disabled on the public mainnet endpoints.
For prototypes and occasional reads, that is enough. For a service that watches many addresses, you need either your own node, a provider, or an API that pushes events to you. For the node route, see how to talk to a node with JSON-RPC. More on the Chaingateway side is on the BSC API page.
Ready to build this yourself? Get your API key — 7-day trial, no card required — or see the Binance Smart Chain API for the full endpoint reference.