BITCOIN API RESOURCE

Build with Bitcoin data.

Read-only API patterns that make networks, units, completeness, and failures explicit.

This is a documentation resource, not an API subscription service. Requests in the examples go to Blockstream’s external Esplora API. No requests run automatically, and no API keys or wallet connections are collected here.

Know the network

Keep mainnet and testing data separate in configuration, caches, logs, and the interface.

Explore this topic

Keep units explicit

Treat satoshis, BTC, virtual bytes, and fee rates as different quantities throughout your code.

Explore this topic

Handle unknown honestly

A timeout, missing record, and zero balance are not interchangeable outcomes.

Explore this topic

A small endpoint reference

These read-only paths use https://blockstream.info/api as the Bitcoin mainnet base. Confirm current behavior, pagination, and service policies in the provider’s documentation.

Read the official Esplora API contract (opens in a new tab)

Esplora transaction amounts use satoshis. Do not assume every field in every other Bitcoin interface uses the same units. Confirmation targets are estimates, not deadlines.

GET pathPurpose
/blocks/tip/heightCurrent height, returned as plain text.
/tx/:txidTransaction inputs, outputs, fee, and status.
/tx/:txid/statusTransaction confirmation status.
/address/:addressAddress statistics, not a whole-wallet total.
/fee-estimatesEstimated sat/vB rates by target blocks.
READ-ONLY JAVASCRIPT

Fetch a height. Preserve the context.

The sample validates a plain-text response and includes an observation time. It is not a complete production client.

JAVASCRIPT · EXTERNAL PROVIDER
// Read-only example for your own application; not executed on this page.
async function getBitcoinTipHeight() {
  const response = await fetch(
    "https://blockstream.info/api/blocks/tip/height",
    { signal: AbortSignal.timeout(15000), cache: "no-store" }
  );
  if (!response.ok) {
    throw new Error(`Provider returned HTTP ${response.status}`);
  }
  const raw = (await response.text()).trim();
  if (!/^\d+$/.test(raw)) throw new Error("Unexpected height response");
  const height = Number(raw);
  if (!Number.isSafeInteger(height)) throw new Error("Unsafe height value");
  return { network: "bitcoin-mainnet", height, observedAt: new Date().toISOString() };
}
// Add application-specific error handling, rate limits, and privacy review.
Keep administrative authority out of public clients.Do not expose private API credentials or node RPC access in a browser bundle. A public blockchain query does not require spending keys. Build production access controls separately.