Introduction
Bitcoin Core provides an unauthenticated REST interface for querying blockchain data and network information. The REST API offers a simple HTTP-based alternative to the JSON-RPC interface for read-only operations.Enabling the REST Interface
The REST API is disabled by default. Enable it using the-rest configuration option:
bitcoin.conf file:
Network Configuration
The REST interface runs on the same port as the JSON-RPC interface:| Network | Port |
|---|---|
| Mainnet | 8332 |
| Testnet | 18332 |
| Testnet4 | 48332 |
| Signet | 38332 |
| Regtest | 18443 |
Authentication
The REST interface is unauthenticated. Unlike the JSON-RPC interface, REST endpoints do not require credentials. This makes the interface simpler to use but means you should be careful about exposing it to untrusted networks.Response Formats
Most REST endpoints support multiple output formats specified by the file extension:| Format | Extension | Content-Type |
|---|---|---|
| Binary | .bin | application/octet-stream |
| Hexadecimal | .hex | text/plain |
| JSON | .json | application/json |
Some endpoints like
/rest/chaininfo only support JSON output format.Consistency Guarantees
The REST interface provides the same consistency guarantees as the JSON-RPC interface:- All endpoints operate on a consistent view of the blockchain state
- Queries may return stale data during reorgs or when the node is catching up
- For critical applications, verify block confirmations independently
Limitations and Warnings
File Descriptor Exhaustion
To mitigate this:- Increase system file descriptor limits: Adjust your OS settings to allow more open files
- Rate limit connections: If you control the clients, avoid opening hundreds of simultaneous connections
- Use connection pooling: Reuse HTTP connections instead of creating new ones for each request
Cross-Site Scripting (XSS) Risk
Malicious websites could potentially:- Execute requests like
<script src="http://127.0.0.1:8332/rest/tx/TXID.json"> - Read transaction and block data from your node
- Compromise your privacy by learning which transactions you’re interested in
Transaction Index Requirement
Some endpoints require the transaction index to be enabled:Enable the transaction index to query historical transactions via
/rest/tx/txindex=1:
/rest/tx/only searches the mempool- Confirmed transactions cannot be queried
Next Steps
- Explore REST Endpoints for detailed endpoint documentation
- Learn about specific data formats for blocks, transactions, and UTXO queries
- See complete examples with curl commands