bitview-client
v0.13.0
Published
Bitcoin on-chain analytics client — thousands of metrics, block explorer, and address index
Maintainers
Readme
bitview-client
Zero-dependency JavaScript/TypeScript client for the Bitview Bitcoin analytics API.
npm | API Reference | Source
AI clients can use the same API through the official stateless, read-only MCP endpoint at mcp.bitview.space. No authentication is required.
Installation
npm install bitview-clientYou can also copy the index.js file into a project. The published client is a
single ES module with no runtime dependencies.
Quick start
import { BitviewClient } from 'bitview-client';
// Use the public API or point the client at a self-hosted Bitview server.
const client = new BitviewClient('https://bitview.space');
// Mempool.space-compatible blockchain endpoints.
const blockHash = await client.getBlockByHeight(800000);
const tx = await client.getTx(
'a1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d',
);
// Typed, chainable series access.
const prices = await client.series.price.close.by.day1
.last(30)
.fetch();
// Programmatic access when the series name is only known at runtime.
const samePrices = await client
.seriesEndpoint('price_close', 'day1')
.last(30)
.fetch();Series endpoints support first(n), last(n), slice(start, end), get(i),
skip(n).take(m), fetchCsv(), len(), and version(). They are also
thenable, so await endpoint.last(30) is equivalent to calling .fetch().
A value is null where it is missing (mostly a date period without blocks) or
undefined (a NaN, or a ratio over zero). The types say exactly where:
T | null at the indexes where a value can be missing, and everywhere for value
types that can be undefined (floats, Cents, ratios, parts per million).
Pass an options object to configure request behavior:
const client = new BitviewClient({
baseUrl: 'https://bitview.space',
timeout: 10_000,
browserCache: true,
memCache: 100,
});The memory cache retains parsed responses by URL and ETag. Node.js sends
If-None-Match when it retains a response. A 304 reuses the parsed value
without downloading or parsing another body.
Browsers handle HTTP revalidation themselves, preserving their HTTP cache and
avoiding extra CORS preflights. Changed responses are parsed and replace the cached value.
