Skip to main content

Satoshi API — developer-friendly Bitcoin REST API powered by your own node

Project description

Satoshi API

CI Python 3.10+ License: MIT

The thinnest REST layer over your Bitcoin node. One pip install, instant API.

Powered by bitcoinlib-rpc for analyzed data (fees, mempool congestion, block stats) rather than raw RPC dumps. Part of the AI agent pipeline: bitcoinlib-rpc -> satoshi-api -> bitcoin-mcp.

Prerequisites

  • Bitcoin Core running with server=1 in bitcoin.conf (RPC enabled)
  • Python 3.10+

Node configuration notes:

  • Transaction lookups (/tx/{txid}, /tx/{txid}/raw) for confirmed transactions require txindex=1
  • Block template (/mining/nextblock) requires at least one connected peer on mainnet
  • Block stats (/blocks/{height}/stats) is unavailable for pruned blocks below the prune height

Quick Start

pip install bitcoin-api  # or: pip install -e . for local dev

# Point at your node
export BITCOIN_RPC_USER=your_user
export BITCOIN_RPC_PASSWORD=your_password
# For testnet: export BITCOIN_RPC_PORT=18332
# For signet:  export BITCOIN_RPC_PORT=38332

# Run
bitcoin-api  # or: satoshi-api
# -> http://localhost:9332/docs

Docker

# Create .env with your node credentials
echo "BITCOIN_RPC_USER=your_user" > .env
echo "BITCOIN_RPC_PASSWORD=your_password" >> .env

docker compose up -d

Endpoints

All endpoints are under /api/v1/. Interactive docs at /docs.

Endpoint Description
GET /health Node ping (no auth required)
GET /status Sync progress, peers, disk usage
GET /network Version, connections, relay fee
GET /network/forks Chain tips / fork detection
GET /network/difficulty Difficulty epoch progress, retarget estimate
GET /blocks/latest Latest block analysis
GET /blocks/tip/height Chain tip height
GET /blocks/tip/hash Chain tip block hash
GET /blocks/{height_or_hash} Block by height or hash
GET /blocks/{height}/stats Raw block statistics
GET /blocks/{hash}/txids Transaction IDs in a block
GET /blocks/{hash}/txs Full transactions in a block (paginated)
GET /blocks/{hash}/header Block header hex string
GET /tx/{txid} Transaction analysis (fees, SegWit, Taproot, inscriptions)
GET /tx/{txid}/raw Raw decoded transaction
GET /tx/{txid}/status Confirmation status
GET /tx/{txid}/hex Raw transaction hex string
GET /tx/{txid}/outspends Spending status of each output
GET /utxo/{txid}/{vout} UTXO lookup
GET /mempool Mempool analysis (fee buckets, congestion)
GET /mempool/info Raw mempool stats
GET /mempool/tx/{txid} Mempool entry for a transaction
GET /mempool/txids All transaction IDs in the mempool
GET /mempool/recent Most recent mempool entries
GET /fees Fee estimates (1, 3, 6, 25, 144 blocks)
GET /fees/recommended Human-readable fee recommendation
GET /fees/{target} Fee estimate for specific block target
GET /fees/mempool-blocks Projected next blocks from mempool by fee rate
GET /mining Hashrate, difficulty, retarget estimate
GET /mining/nextblock Block template analysis
GET /network/validate-address/{addr} Validate a Bitcoin address
GET /prices BTC price in USD, EUR, GBP, JPY, CAD, AUD
POST /decode Decode raw transaction hex
POST /broadcast Broadcast signed transaction

Examples

# Health check
curl http://localhost:9332/api/v1/health

# Fee recommendation
curl http://localhost:9332/api/v1/fees/recommended

# Analyze a transaction
curl http://localhost:9332/api/v1/tx/a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d

# Latest block
curl http://localhost:9332/api/v1/blocks/latest

# With API key (higher rate limits)
curl -H "X-API-Key: your_key_here" http://localhost:9332/api/v1/mempool

API Keys

Anonymous access works out of the box. For higher rate limits, create a key:

python scripts/create_api_key.py --tier free --label "my-app"
python scripts/create_api_key.py --tier pro --label "production"

Pass the key via X-API-Key header. Query parameter ?api_key= is deprecated (sunset: 2026-09-01).

Rate Limits

Tier Req/min Req/day
Anonymous 30 1,000
Free (API key) 100 10,000
Pro 500 100,000
Enterprise 2,000 Unlimited

Rate limit info in response headers: X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-RateLimit-Daily-Limit, X-RateLimit-Daily-Remaining.

Every response includes X-Request-ID (UUID) and X-Auth-Tier headers.

Response Format

Standard envelope on all endpoints:

{
  "data": { ... },
  "meta": {
    "timestamp": "2026-03-05T12:00:00+00:00",
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "node_height": 880000,
    "chain": "main"
  }
}

Errors:

{
  "error": {
    "status": 404,
    "title": "Not Found",
    "detail": "Transaction not found",
    "request_id": "550e8400-e29b-41d4-a716-446655440000"
  }
}

Input Validation

  • Transaction IDs and block hashes must be exactly 64 hex characters
  • Invalid formats return 422 immediately (no wasted RPC calls)
  • Invalid API keys return 401 (not silent downgrade to anonymous)

Development

pip install -e ".[dev]"
pytest

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

satoshi_api-0.1.0.tar.gz (81.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

satoshi_api-0.1.0-py3-none-any.whl (36.1 kB view details)

Uploaded Python 3

File details

Details for the file satoshi_api-0.1.0.tar.gz.

File metadata

  • Download URL: satoshi_api-0.1.0.tar.gz
  • Upload date:
  • Size: 81.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for satoshi_api-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06cf2a8e8e47501ed59511ff17c7859ce857c67252b5cadc193c273da5f9c975
MD5 94d56222e9c9b9008da6e481f3001888
BLAKE2b-256 98c6f4c5ff803cba079870fb1ed65fa28e47e64ecf725918672c1d045a8f7cb0

See more details on using hashes here.

File details

Details for the file satoshi_api-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: satoshi_api-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for satoshi_api-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 15f4c82460e9325c22d6fcd74094d0101839904e30d223a573385b4507cd7084
MD5 8c2297595e5eaeea4b9292d6a498e2c8
BLAKE2b-256 1ae06570d24ebd3d37d20dd3f7273724644ee23d888fcace76a0a144cdd22cdf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page