THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Core JSON-RPC Explained: Methods, Requests, and Responses

permalink THAMER
#bitcoin-core-rpc#developer-api#getblockchaininfo#json-rpc

Bitcoin Core exposes a JSON-RPC interface for querying a node and, when wallet functionality is enabled, operating loaded wallets. It is an administrative interface, not a public blockchain explorer API. Developers should keep it behind a trusted boundary.

How a JSON-RPC request works

A client sends an authenticated HTTP POST containing a JSON object with a method name, parameters, and an identifier. For example, a read-only node query can request getblockchaininfo:

curl --user "USER:PASSWORD" \
  --data-binary '{"jsonrpc":"1.0","id":"chain-check","method":"getblockchaininfo","params":[]}' \
  -H 'content-type: text/plain;' \
  http://127.0.0.1:8332/

The credentials are placeholders. Avoid putting real passwords directly into shell history or process arguments; for local scripts prefer cookie-based authentication with appropriately restricted access. Mainnet commonly uses RPC port 8332, but the port is configurable and differs by network.

What is returned?

A successful response includes a result value and an error field that is null. A failed method call may return an RPC error object containing a numeric code and a message. The HTTP status and the JSON-RPC error must both be checked. Do not assume an HTTP response alone proves that the requested operation succeeded.

Node methods and wallet methods

Node methods such as getblockchaininfo, getnetworkinfo, and getrawmempool describe chain state, peer/network information, and the local mempool. Wallet methods such as getbalances, listunspent, and sendtoaddress act on a loaded wallet and can require the wallet-specific URL path /wallet/<wallet-name> (with the name URL-encoded).

getrawtransaction availability depends on whether the transaction is in the mempool, whether a block hash is supplied, and the node's transaction indexing and retained block data. A pruned node should not be treated as an unlimited historical transaction archive.

Integration checklist

Validate input types and network selection. Set HTTP timeouts and response-size limits. Treat errors as structured data. Avoid automatic retries for wallet-mutating operations unless the application has an idempotency or reconciliation strategy. Keep RPC credentials out of logs, and do not expose the RPC listener to untrusted networks.

Primary references

Bitcoin Core RPC reference: https://bitcoincore.org/en/doc/

Bitcoin Core JSON-RPC documentation: https://github.com/bitcoin/bitcoin/blob/master/doc/JSON-RPC-interface.md

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects