Crates.io | brk_server |
lib.rs | brk_server |
version | 0.0.95 |
created_at | 2025-02-23 23:35:39.771466+00 |
updated_at | 2025-08-28 10:48:40.473475+00 |
description | A server with an API for anything from BRK |
homepage | https://bitcoinresearchkit.org |
repository | https://github.com/bitcoinresearchkit/brk |
max_upload_size | |
id | 1566729 |
size | 110,562 |
HTTP server providing REST API access to Bitcoin analytics data
brk_server
provides a high-performance HTTP server that exposes BRK's indexed blockchain data and computed analytics through a comprehensive REST API. It offers multiple output formats, intelligent caching, compression, and optional web interface serving.
use brk_server::Server;
use brk_interface::Interface;
use brk_indexer::Indexer;
use brk_computer::Computer;
// Load data sources
let indexer = Indexer::forced_import("./brk_data")?;
let computer = Computer::forced_import("./brk_data", &indexer, None)?;
// Create interface and server
let interface = Interface::build(&indexer, &computer);
let server = Server::new(interface, Some("./website".into()));
// Start server (with MCP support)
server.serve(true).await?;
# Latest 100 price values
curl "http://brekit.org/api/vecs/date-to-close?from=-100"
# First 50 difficulty values as CSV
curl "http://brekit.org/api/vecs/height-to-difficulty?count=50&format=csv"
# Range from block 800,000 to 800,100
curl "https://brekit.org/api/vecs/height-to-timestamp?from=800000&to=800100"
# Multiple price metrics for last 30 days
curl "http://brekit.org/api/vecs/query?index=date&ids=open,high,low,close&from=-30&format=csv"
# Block statistics for specific range
curl "https://brekit.org/api/vecs/query?index=height&ids=size,weight,tx_count,fee_sum&from=800000&count=100"
# Weekly analytics as JSON matrix
curl "https://brekit.org/api/vecs/query?index=week&ids=close,difficulty&from=-52"
Endpoint | Description |
---|---|
GET /api/vecs/index-count |
Total number of available indexes |
GET /api/vecs/id-count |
Total number of vector IDs |
GET /api/vecs/vec-count |
Total vectors (all index/ID combinations) |
GET /api/vecs/indexes |
List of all available indexes |
GET /api/vecs/accepted-indexes |
Mapping of indexes to accepted variants |
GET /api/vecs/ids?page=N |
Paginated vector IDs (1000/page) |
GET /api/vecs/index-to-ids?index=INDEX&page=N |
IDs supporting given index |
GET /api/vecs/id-to-indexes?id=ID |
Indexes supported by given ID |
GET /api/vecs/{INDEX}-to-{ID}
# Examples
curl "/api/vecs/height-to-timestamp"
curl "/api/vecs/date-to-close"
curl "/api/vecs/month-to-supply"
GET /api/vecs/query
Required Parameters:
index
: Vector index type (height, date, week, month, etc.)ids
: Comma or space-separated vector IDsOptional Parameters:
from
(i64): Start index (negative = from end, default: 0)to
(i64): End index (exclusive, negative = from end)count
(usize): Maximum number of resultsformat
: Output format (json
, csv
, tsv
, md
)Single Value (one vector, one result):
42.5
Array (one vector, multiple results):
[42.5, 43.1, 44.2]
Matrix (multiple vectors):
[
[42.5, 43.1, 44.2],
[1500, 1520, 1480],
[0.05, 0.052, 0.048]
]
CSV Format:
index,close,supply,feerate
0,42.5,1500,0.05
1,43.1,1520,0.052
2,44.2,1480,0.048
Endpoint | Description |
---|---|
GET /version |
Server version information |
GET /health |
Health check with timestamp |
GET /api |
API documentation redirect |
GET /* |
Static file serving (if enabled) |
pub struct AppState {
interface: &'static Interface<'static>, // Data access interface
path: Option<PathBuf>, // Static files path
cache: Arc<Cache<String, Bytes>>, // Response cache
}
Cache-Control: must-revalidate
Accept-Encoding
headeraxum
- High-performance async web frameworktower-http
- HTTP middleware (compression, tracing, CORS)brk_interface
- Data access and formatting layerbrk_mcp
- Model Context Protocol routesquick_cache
- Fast in-memory cachingtokio
- Async runtime for networkingThis README was generated by Claude Code