BNB Smart Chain
API Overview
Architecture
TheRPC exposes BNB Smart Chain through the JSON-RPC 2.0 specification, the same wire protocol a geth-equivalent node speaks, so existing Ethereum tooling works against chainId 56 unchanged. Four traits define the surface: standard HTTP and WebSocket endpoints for request/reply and streaming respectively, API-key authentication carried in the request, a unified response envelope that always returns either a result or an error, and cross-network compatibility so the same client shape targets any chain TheRPC fronts.
Communication Protocols
The HTTP endpoint suits one-off reads and straightforward integrations on BNB Smart Chain: a balance check, a single eth_call, or a script that runs and exits. Each call is a self-contained POST that opens, gets its answer, and closes again. For copy-paste request examples, see the HTTP/Curl guide.
HTTP Endpoint
The WebSocket endpoint is the better fit for subscriptions and live BNB Smart Chain data. It holds one connection open so new blocks (arriving roughly every three seconds) and contract logs stream to you without repeated polling. See eth_subscribe for the available subscription types and example payloads.
WebSocket Endpoint
JSON-RPC Format
Every BNB Smart Chain call is a JSON-RPC 2.0 object with four required fields: jsonrpc, fixed at the string "2.0"; method, the RPC name such as eth_blockNumber; params, an array of arguments (empty when the method takes none); and id, a client-chosen value the gateway echoes so you can match each reply to its request.
Request Structure
Response Format
Responses from the BNB Smart Chain endpoint follow one consistent shape: the jsonrpc version, the same id you sent, and then exactly one of result on success or error on failure. Branch on which key is present and you have a reliable handler for any method.
Success Response
Error Response
Authentication
Every BNB Smart Chain request must present your API key, either embedded in the https://bsc.therpc.io/YOUR_API_KEY path or via the Authorization header with the Bearer scheme shown below. For key generation and env-var setup, along with the auth error response, read the full Authentication guide.
Authorization Header
Method Categories
BNB Smart Chain methods group by namespace prefix. The standard set covers eth_ for core protocol calls like balances and blocks and contract reads, net_ for network status, and web3_ for utility helpers. The advanced set adds debug_ for low-level debugging, trace_ for transaction and block tracing, and txpool_ for inspecting the pending pool. Each prefix links through to the individual method docs where you will find parameters and examples.
Error Handling
The BNB Smart Chain gateway uses the five standard JSON-RPC error codes: -32700 for a parse error on malformed JSON, -32600 for an invalid request envelope, -32601 when the method name is not recognized, -32602 for invalid params, and -32603 for an internal error. For retry and logging strategies, plus timeout handling built around these codes, see the FAQ.
Implementation Examples
- JavaScript / TypeScript — wire web3.js or ethers.js to the bsc endpoint.
- Python — connect web3.py to BNB Smart Chain with a single provider line.
- HTTP / curl — issue raw JSON-RPC POSTs from the shell.
- All SDKs — browse every supported client in the Tools & SDKs reference.