Python SDK for Satoshi API — Bitcoin fee intelligence and blockchain data
Project description
Satoshi API Python SDK
Typed Python client for the Satoshi API — Bitcoin fee intelligence that saves money on every transaction.
Zero dependencies. Uses only Python stdlib. Works with Python 3.10+.
Install
pip install satoshi-api-sdk
Quick Start
from satoshi_api import SatoshiAPI
api = SatoshiAPI() # anonymous tier (30 req/min)
# Get current fees
fees = api.fees()
print(fees.data)
# Get a block
block = api.block(840000)
print(f"Block {block.data['height']}: {block.data['tx_count']} transactions")
# Check mempool
mempool = api.mempool()
print(f"Mempool: {mempool.data['size']} transactions")
# Fee recommendation
landscape = api.fee_landscape()
print(landscape.data["recommendation"])
Authentication
# Register for a free API key at https://bitcoinsapi.com/docs
api = SatoshiAPI(api_key="your-api-key") # 100 req/min
# Or point at your own node
api = SatoshiAPI(base_url="http://localhost:9332")
Error Handling
from satoshi_api import SatoshiAPI, APIError, RateLimitError
api = SatoshiAPI()
try:
tx = api.transaction("abc123invalid")
except RateLimitError as e:
print(f"Rate limited. Retry in {e.retry_after}s")
except APIError as e:
print(f"API error [{e.status}]: {e.detail}")
except ConnectionError:
print("Cannot reach API")
Rate limiting is handled automatically — the SDK reads the Retry-After header and retries up to 3 times.
Response Object
Every method returns a Response with:
resp = api.fees()
resp.data # The response payload (dict)
resp.meta # Metadata (timestamp, node_height, chain)
resp.height # Shortcut for meta.node_height
resp.chain # Shortcut for meta.chain
resp.cached # Whether response was served from cache
resp.request_id # Request ID for support/debugging
All Methods
Status & Health
api.health()— Node health checkapi.health_deep()— Deep health (DB, jobs, caches, circuit breaker)api.status()— Full node status
Blocks
api.block(height_or_hash)— Block analysisapi.block_latest()— Latest blockapi.block_stats(height)— Raw block statisticsapi.block_header(hash)— Block headerapi.block_txids(hash)— Transaction IDs in blockapi.block_txs(hash, start, limit)— Paginated transactionsapi.tip_height()/api.tip_hash()— Chain tip
Transactions
api.transaction(txid)— Decoded transactionapi.transaction_hex(txid)— Raw hexapi.transaction_status(txid)— Confirmation statusapi.transaction_outspends(txid)— Output spending statusapi.broadcast(hex)— Broadcast signed tx (requires key)api.decode(hex)— Decode without broadcasting (requires key)api.utxo(txid, vout)— Check UTXO existence
Fees
api.fees()— All fee estimatesapi.fee_target(target)— Specific confirmation targetapi.fee_recommended()— Fast/medium/slowapi.fee_landscape()— Full analysis with recommendationapi.fee_mempool_blocks()— Projected mempool blocksapi.fee_estimate_tx(inputs, outputs)— Estimate for specific txapi.fee_history(hours, interval)— Historical data
Mempool
api.mempool()— Analysis (size, congestion, buckets)api.mempool_info()— Raw mempool infoapi.mempool_txids()— All mempool txidsapi.mempool_recent()— Recently added transactionsapi.mempool_tx(txid)— Specific mempool entry
Mining & Network
api.mining()— Difficulty, hashrate, retargetapi.mining_nextblock()— Next block predictionapi.network()— Connections, version, relay feeapi.network_difficulty()— Difficulty adjustmentapi.network_forks()— Chain tipsapi.validate_address(addr)— Address validation
Prices & Tools
api.prices()— BTC price (USD, EUR, GBP, etc.)api.exchange_compare(amount_usd)— Exchange fee comparison
Self-Hosted
Point the SDK at your own Satoshi API instance:
api = SatoshiAPI(base_url="http://my-node:9332")
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file satoshi_api_sdk-0.1.0.tar.gz.
File metadata
- Download URL: satoshi_api_sdk-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
44c35ceede585d1006befa1f446de27de2ad543df74487ec37d20868dbd1f084
|
|
| MD5 |
0d220c8685c5b7c3eb703f772250206f
|
|
| BLAKE2b-256 |
06d8980c502c1fc68b3e25001755490fdade197e217aedad1e3475f108bd68fd
|
File details
Details for the file satoshi_api_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: satoshi_api_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e888e6e1982473a94ff442d1b29615ea7c49bf4d20bf779f1d67cb1b0098c09
|
|
| MD5 |
a558248cd0a0d2fb2da25d7736d8e2f8
|
|
| BLAKE2b-256 |
6fcbce6eac2248643b59ab2b72804037bfd7a52d7cbf0c67125acc2bca0c95de
|