For developers and agents
A useful response in one request.
Start with the free fee snapshot. You do not need an account, API key, payment library, or wallet.
curl --fail-with-body https://bitcoinsapi.com/api/v1/fees/preview
On Windows PowerShell, use curl.exe.
Read rates and freshness together.
const response = await fetch(
"https://bitcoinsapi.com/api/v1/fees/preview",
{ signal: AbortSignal.timeout(5000) }
);
if (!response.ok) throw new Error(`Fee API: ${response.status}`);
const { data, meta } = await response.json();
const age = (Date.now() - Date.parse(meta.fetched_at)) / 1000;
// Allow up to 30 seconds of clock skew between the client and server.
if (meta.stale || !Number.isFinite(age) || age < -30 || age > 60) {
throw new Error("Request a fresher snapshot before using these fees");
}
const vbytes = 140; // Replace with your wallet's estimate.
const feeSats = Math.ceil(data.fee_rates_sat_vb.hour * vbytes);
console.log({ feeSats, source: meta.source });
The example applies a 60-second freshness policy and allows 30 seconds of clock skew. The API may serve a fallback up to 120 seconds old at the origin, plus HTTP cache time. A rate target is not a confirmation guarantee.
Add a paid decision only when you need it.
PausedPayments are paused. No payment proof is processed. The free fee preview is available without a wallet.
The optional GET /api/v1/fees/now route costs 0.001
USDC on Base mainnet when enabled. It adds a deterministic
send-or-wait result, reason codes, and a confirmed settlement
receipt. It uses the same public source data; it is not a
proprietary forecast.
curl --fail-with-body https://bitcoinsapi.com/status.json
curl -i https://bitcoinsapi.com/api/v1/fees/now
These ordinary HTTP requests do not sign or pay. While paused, the
second returns 503 payments_disabled without a
challenge. When enabled, inspect PAYMENT-REQUIRED and
use an
official x402 v2 client
with your own explicit spending policy. The v1
X-PAYMENT header is not supported.
Use the exact HTTPS URL with no query parameters. Check the payment contract and decision method before signing. The project discovery document is not a Bazaar registration or a hosted MCP server.
Handle failures without paying twice.
| Response | What to do |
|---|---|
| 503 · paused or unavailable | Do not sign. Use the free preview if available, then back off. |
| 402 · payment required or rejected | Inspect the current requirement and error. Do not retry a rejected proof in a loop. |
| 429 · rate limited | Back off. Repeating the request immediately will not help. |
| 502 · settlement uncertain |
Follow error.retry.instruction: retry the exact
payment payload. Do not automatically create a second
authorization.
|
| 410 · retired API | The former broad hosted API is retired. Use the routes in the current OpenAPI document. |