Haskoin

A fast, scalable API for the Bitcoin and Bitcoin Cash block chains. Look up the balance, history and unspent outputs of any address or wallet, read blocks and transactions, follow new activity as it happens, and publish transactions, all over plain HTTP and JSON.

What Haskoin does

Haskoin follows the network, block by block and transaction by transaction, and keeps indices built for the questions that wallets, explorers and payment services ask. Answers come from a single database lookup, newest first, so they stay fast however long the history of an address grows.

Addresses

Balances, transaction histories and unspent outputs of any address, confirmed and unconfirmed.

Wallets

The same for an extended public key (xpub): every address it derives, in one request.

Blocks and transactions

By hash or height, decoded to JSON or raw, plus the full mempool.

Live events

New transactions and blocks as they arrive, over a WebSocket or a stream of JSON lines, filtered to the addresses or wallets you follow.

Publishing

Send a signed transaction to the network with one request.

Two chains, one API

Bitcoin and Bitcoin Cash, with their test networks, all served the same way.

Built to scale

A single Haskoin server answers most requests in milliseconds. Add Redis and it caches large wallets, so even an xpub with thousands of addresses comes back quickly. Run several servers against the same Redis and they work as one fleet: every server gives the same answer, from the same block and the same mempool. Put them behind a load balancer for higher throughput, and keep serving while one of them is down for maintenance.

Proven in production. Haskoin has run at Blockchain.com for years, where it handles most of the traffic for blockchain data.

The API

Each network has its own server, and each server publishes its own reference. The reference always describes the version that is running, and you can try every request from it.

Bitcoin Cash

/bch/

Bitcoin testnet4

/btctest4/

Bitcoin Cash testnet4

/bchtest4/

Try it

curl https://api.haskoin.com/btc/block/best
curl https://api.haskoin.com/btc/address/bc1q…/balance
curl -N https://api.haskoin.com/btc/events

Answers are JSON; add ?pretty=true to read them. Amounts are whole satoshis, and lists are newest first, in pages.

This public service is free and needs no key. Requests are rate-limited per client address; a client that asks too fast gets 429 Too Many Requests.

Haskoin and full nodes

Haskoin works alongside fully-validating nodes such as Bitcoin Core and Bitcoin Cash Node, not instead of them. A full node checks every rule of consensus, which is what miners and anyone securing funds rely on. It is not built to answer queries from the public at web scale. Haskoin connects to nodes over the peer-to-peer network, ideally nodes you run yourself, and turns what they relay into an API for applications.

Haskoin Bitcoin Core /
Bitcoin Cash Node
Checks every consensus rule and script —✓
Block templates for mining —✓
Wallet holding private keys —✓
Any transaction by its hash ✓✓ with -txindex
Balance and history of any address ✓—
Unspent outputs of any address ✓slow full scan
Balances and history of an xpub wallet ✓—
Paged lists, newest first ✓—
Events filtered by address or wallet ✓all, unfiltered (ZMQ)
Publish transactions ✓✓
Open HTTP/JSON API for public clients ✓—
Shared cache in Redis ✓—
Fleet of servers giving identical answers ✓—

The two fit together: nodes secure the network, and Haskoin serves the applications built on it.

Run your own

Haskoin is free software under the MIT licence, written in Haskell. The server behind this site is haskoin-store, and the Haskell client is haskoin-store-data. Run it next to your own nodes for private, unlimited access, with the same API you see here.

Custom deployments and paid support

Need Haskoin set up for your service, scaled for your traffic, extended with features you need, or backed by a support plan? Get in touch with its author, JP Rupp.

Email: jprupp@protonmail.ch
GitHub: github.com/jprupp