Skip to main content

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 check
  • api.health_deep() — Deep health (DB, jobs, caches, circuit breaker)
  • api.status() — Full node status

Blocks

  • api.block(height_or_hash) — Block analysis
  • api.block_latest() — Latest block
  • api.block_stats(height) — Raw block statistics
  • api.block_header(hash) — Block header
  • api.block_txids(hash) — Transaction IDs in block
  • api.block_txs(hash, start, limit) — Paginated transactions
  • api.tip_height() / api.tip_hash() — Chain tip

Transactions

  • api.transaction(txid) — Decoded transaction
  • api.transaction_hex(txid) — Raw hex
  • api.transaction_status(txid) — Confirmation status
  • api.transaction_outspends(txid) — Output spending status
  • api.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 estimates
  • api.fee_target(target) — Specific confirmation target
  • api.fee_recommended() — Fast/medium/slow
  • api.fee_landscape() — Full analysis with recommendation
  • api.fee_mempool_blocks() — Projected mempool blocks
  • api.fee_estimate_tx(inputs, outputs) — Estimate for specific tx
  • api.fee_history(hours, interval) — Historical data

Mempool

  • api.mempool() — Analysis (size, congestion, buckets)
  • api.mempool_info() — Raw mempool info
  • api.mempool_txids() — All mempool txids
  • api.mempool_recent() — Recently added transactions
  • api.mempool_tx(txid) — Specific mempool entry

Mining & Network

  • api.mining() — Difficulty, hashrate, retarget
  • api.mining_nextblock() — Next block prediction
  • api.network() — Connections, version, relay fee
  • api.network_difficulty() — Difficulty adjustment
  • api.network_forks() — Chain tips
  • api.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

Metadata

Release files for satoshi-api-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for satoshi-api-sdk 0.1.0
File Size Uploaded Provenance
satoshi_api_sdk-0.1.0.tar.gz 7.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for satoshi-api-sdk 0.1.0
File Interpreter ABI Platform
satoshi_api_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / satoshi_api_sdk-0.1.0.tar.gz

Download URL satoshi_api_sdk-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
44c35ceede585d1006befa1f446de27de2ad543df74487ec37d20868dbd1f084
BLAKE2b-256 checksum
How to use checksums
06d8980c502c1fc68b3e25001755490fdade197e217aedad1e3475f108bd68fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / satoshi_api_sdk-0.1.0-py3-none-any.whl

Download URL satoshi_api_sdk-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7e888e6e1982473a94ff442d1b29615ea7c49bf4d20bf779f1d67cb1b0098c09
BLAKE2b-256 checksum
How to use checksums
6fcbce6eac2248643b59ab2b72804037bfd7a52d7cbf0c67125acc2bca0c95de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for satoshi-api-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page