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)

Self-Serve API Key Registration

Request a free API key programmatically:

curl -X POST https://bitcoinsapi.com/api/v1/register \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "label": "my-app"}'

Returns your API key once — save it, it won't be shown again. Max 3 keys per email.

L402 Lightning Payments

Satoshi API supports L402 (formerly LSAT) — the HTTP 402 + Lightning micropayment protocol by Lightning Labs. Clients can pay per-request via Lightning Network instead of using API keys. Available as an optional extension. See bitcoin-api-l402 for details.

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.2.1.tar.gz (81.3 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.2.1-py3-none-any.whl (31.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: satoshi_api-0.2.1.tar.gz
  • Upload date:
  • Size: 81.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for satoshi_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4aba4388b362ba265fe0214dd0e618149950d96dffeed7505a40bb8cd220d186
MD5 9af2f610eda406ca65493481fefee0ba
BLAKE2b-256 40ee72c1912436c4508c7c9b05b1eccffdf69a8027f78fda0e588495507cc319

See more details on using hashes here.

Provenance

The following attestation bundles were made for satoshi_api-0.2.1.tar.gz:

Publisher: publish.yml on Bortlesboat/bitcoin-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: satoshi_api-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 31.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for satoshi_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d16d34669edab4855490217e24ec075ea2fa3d10bbb3637e6b48ca978801aa3
MD5 498b77b1192fa345df4bb6cc87600c5f
BLAKE2b-256 fb1c94052c32afa69476015909a2add8c4d76ca4eec49ad4a16237adeb4107e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for satoshi_api-0.2.1-py3-none-any.whl:

Publisher: publish.yml on Bortlesboat/bitcoin-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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