Bitcoin (BTC)
Bitcoin Network API Reference for secure and scalable interaction with BTC nodes, enabling peer-to-peer transactions and decentralized finance on the world’s first cryptocurrency block
Overview
Bitcoin is the first and largest decentralized cryptocurrency network, launched in 2009 by the pseudonymous Satoshi Nakamoto. It operates as a peer-to-peer electronic cash system, enabling trustless value transfer without intermediaries.
Key Features
Decentralized Network: Secured by thousands of nodes worldwide with no central authority
Proof of Work Consensus: Mining-based security with SHA-256 hashing algorithm
21 Million Supply Cap: Fixed maximum supply creating digital scarcity
10-Minute Block Time: Average block confirmation every 10 minutes
SegWit & Taproot: Modern protocol upgrades for scalability and privacy
PSBT Support: Partially Signed Bitcoin Transactions for secure multi-party signing
Lightning Network Compatible: Layer 2 scaling solution support
Quickstart
In this section, you will learn how to make your first call with either:
Axios
Python
Quickstart with Axios
Before you begin, you must have already installed npm or yarn on your local machine. If not, check out npm or yarn.
Set up your project using this command:
This creates a project directory named bitcoin-api-quickstart and initialises a Node.js project within it.
Install Axios using this command: Using npm:
Create a new file and name it
index.js. This is where you will make your first call.Set the ES module
"type": "module"in yourpackage.json.Add the following code to the file (
index.js):Replace
<ACCESS_TOKEN>with your actual access token from GetBlock.Run the script:
The sequence number and authentication key log in your console like this:
Quickstart with Python and Requests
Before you begin, you must have installed Python and Pip on your local machine.
Set up your project using this command:
Set up a virtual environment to isolate dependencies:
Install the requests library:
Create a new file called
main.pyand insert the following code:Replace
<ACCESS_TOKEN>with your actual access token from GetBlock.Run the script:
Base URL
Supported Network
Mainnet
Testnet
Available API Methods
GetBlock provides access to 45 Bitcoin RPC endpoints organized into the following categories:
PSBT & Transaction Building (13 methods)
Methods for creating, analyzing, and finalizing Partially Signed Bitcoin Transactions.
analyzepsbt
Analyzes and provides information about a PSBT
combinepsbt
Combines multiple PSBTs into one
combinerawtransaction
Combines multiple partially signed raw transactions
converttopsbt
Converts a raw transaction to PSBT format
createpsbt
Creates a new PSBT with given inputs and outputs
createrawtransaction
Creates a raw transaction
decodepsbt
Decodes a PSBT to JSON
decoderawtransaction
Decodes a raw transaction to JSON
decodescript
Decodes a hex-encoded script
finalizepsbt
Finalizes a PSBT for broadcast
fundrawtransaction
Adds inputs to a raw transaction
joinpsbts
Joins multiple PSBTs with different inputs
utxoupdatepsbt
Updates PSBT with UTXO data
Blockchain & Block Information (13 methods)
Methods for querying blockchain state and block data.
getbestblockhash
Returns the hash of the best block
getblock
Returns block data for a given hash
getblockchaininfo
Returns blockchain state information
getblockcount
Returns the current block height
getblockfilter
Returns BIP 157 block filter
getblockhash
Returns block hash at given height
getblockheader
Returns block header information
getblockstats
Returns per-block statistics
getblocktemplate
Returns data for mining a block
getchaintips
Returns information about chain tips
getchaintxstats
Returns transaction statistics
getdifficulty
Returns the current mining difficulty
getfinalizedblockhash
Returns the hash of the finalized block
Mempool (6 methods)
Methods for querying the memory pool of unconfirmed transactions.
getmempoolancestors
Returns mempool ancestors of a transaction
getmempooldescendants
Returns mempool descendants of a transaction
getmempoolentry
Returns mempool data for a transaction
getmempoolinfo
Returns mempool state information
getrawmempool
Returns all transaction IDs in mempool
testmempoolaccept
Tests if transactions would be accepted
Mining & Network (2 methods)
Methods for mining information and network statistics.
getmininginfo
Returns mining-related information
getnetworkhashps
Returns estimated network hash rate
Transaction (4 methods)
Methods for querying and broadcasting transactions.
getrawtransaction
Returns raw transaction data
gettxout
Returns details about an unspent output
gettxoutproof
Returns proof that a transaction is in a block
sendrawtransaction
Broadcasts a raw transaction
Utility (7 methods)
Utility methods for address derivation, validation, and node information.
deriveaddresses
Derives addresses from a descriptor
estimatesmartfee
Estimates fee for confirmation target
getindexinfo
Returns index status information
getmemoryinfo
Returns memory usage information
getrpcinfo
Returns RPC server information
validateaddress
Validates a Bitcoin address
verifymessage
Verifies a signed message
Support
For technical support and questions:
Support: [email protected]
See Also
Last updated
Was this helpful?