| Crates.io | stellar-data |
| lib.rs | stellar-data |
| version | 0.1.5 |
| created_at | 2025-11-08 06:52:07.720626+00 |
| updated_at | 2026-01-23 09:20:42.906707+00 |
| description | A command line tool and REST API for querying the Stellar blockchain using public data lakes and RPC nodes, providing JSON formatted responses to simplify data availability |
| homepage | https://jamesbachini.com |
| repository | https://github.com/jamesbachini/Stellar-Data |
| max_upload_size | |
| id | 1922574 |
| size | 236,350 |
A command line tool and REST API for querying the Stellar blockchain using public data lakes and RPC nodes, providing JSON formatted responses to simplify data availability.
cargo install --locked stellar-data
stellar-data --help
This tool downloads Stellar ledger data from the public S3 bucket at s3://aws-public-blockchain/v1.1/stellar/ledgers/, decompresses the Zstandard compressed XDR data, and converts it to JSON format. If data isn't available (Most recent blocks) it falls back to querying an RPC node.
Available currently for Stellar mainnet only. Testnet coming soon (hopefully)
Published to: https://crates.io/crates/stellar-data
-999 for last 999 blocks)cargo build --release
The binary will be available at ./target/release/stellar-data
The tool can be used in two modes:
Basic syntax:
stellar-data --ledger <LEDGER_NUMBER | RANGE> --query <QUERY_TYPE> [--address <ADDRESS>]
--ledger, -l: The ledger/block number or range to query (required)
--ledger 63864--ledger 63864-63900--ledger -999 (queries last 999 blocks from current)--query, -q: Query type - all, transactions, address, or ttl (default: all)--address, -a: Stellar address to filter by (required when --query address or --query ttl)./target/release/stellar-data --ledger 63864 --query all
Output includes the full ledger close metadata:
./target/release/stellar-data --ledger 50000000 --query transactions
Output format:
{
"start_sequence": 50000000,
"end_sequence": 50000000,
"count": 721,
"transactions": [
{
"tx": {
"signatures": [...],
"tx": {
"source_account": "...",
"fee": 5000,
"seq_num": "...",
"operations": [...],
"memo": "none",
"cond": {...}
}
}
}
]
}
./target/release/stellar-data --ledger 63864 --query transactions
./target/release/stellar-data --ledger 50000000-50000010 --query transactions
Output format:
{
"start_sequence": 50000000,
"end_sequence": 50000010,
"ledgers_processed": 11,
"address": null,
"count": 7945,
"transactions": [...]
}
Get transactions from the last 10 blocks:
./target/release/stellar-data --ledger -10 --query transactions
The tool will automatically fetch the current latest ledger from Horizon and work backwards.
Output format:
{
"start_sequence": 59423252,
"end_sequence": 59423261,
"ledgers_processed": 10,
"address": null,
"count": 5621,
"transactions": [...]
}
Single ledger:
./target/release/stellar-data --ledger 50000000 --query address --address GCWGA2XKBSKVAAPN3UKG2V4TA2O4UDOQEVNNND5GPRLBC63DDEUM3G2I
Ledger range:
./target/release/stellar-data --ledger 63864-638900 --query address --address GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB
Recent blocks with address filter:
./target/release/stellar-data --ledger -999 --query address --address GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB
./target/release/stellar-data --query ttl --address C123...ABC
The address filter searches for:
Output format:
{
"start_sequence": 63864,
"end_sequence": 638900,
"ledgers_processed": 575037,
"address": "GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB",
"count": 42,
"transactions": [...]
}
Start the API server to enable HTTP access to Stellar blockchain data:
./target/release/stellar-data --server --port 3000
Or use the default port (80):
./target/release/stellar-data --server
Once started, the server will display:
Stellar Data API Server
======================
Listening on http://0.0.0.0:3000
Available endpoints:
GET /help
GET /transactions?ledger=<LEDGER>&address=<ADDRESS>
GET /all?ledger=<LEDGER>
GET /contract?ledger=<LEDGER>&address=<CONTRACT>
GET /function?ledger=<LEDGER>&name=<FUNCTION>
GET /balance?address=<ADDRESS>&token=<TOKEN>
All endpoints return JSON responses (except /help which returns HTML documentation).
GET /helpReturns an interactive HTML documentation page with detailed information about all endpoints.
curl http://localhost:3000/help
Or visit http://localhost:3000/help in your browser for a formatted documentation page.
GET /transactionsGet transactions from specified ledger(s), optionally filtered by address.
Parameters:
ledger (required): Ledger sequence number, range, or negative valueaddress (optional): Stellar address to filter transactionsExamples:
# Single ledger
curl "http://localhost:3000/transactions?ledger=50000000"
# Ledger range
curl "http://localhost:3000/transactions?ledger=50000000-50000005"
# Recent ledgers
curl "http://localhost:3000/transactions?ledger=-10"
# Filter by address
curl "http://localhost:3000/transactions?ledger=50000000&address=GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB"
Response:
{
"start_sequence": 50000000,
"end_sequence": 50000005,
"ledgers_processed": 6,
"address": null,
"transactions": [...],
"count": 4523
}
GET /allGet complete ledger metadata including all transaction processing details.
Parameters:
ledger (required): Ledger sequence number, range, or negative valueExamples:
# Single ledger
curl "http://localhost:3000/all?ledger=50000000"
# Ledger range
curl "http://localhost:3000/all?ledger=50000000-50000002"
# Recent ledgers
curl "http://localhost:3000/all?ledger=-5"
Response:
{
"start_sequence": 50000000,
"end_sequence": 50000000,
"ledgers_processed": 1,
"ledgers": [...],
"count": 1
}
GET /contractGet transactions involving a specific smart contract.
Parameters:
ledger (required): Ledger sequence number, range, or negative valueaddress (required): Contract address (starts with 'C')Examples:
# Search contract invocations in ledger range
curl "http://localhost:3000/contract?ledger=50000000-50000010&address=CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
# Search recent ledgers
curl "http://localhost:3000/contract?ledger=-100&address=CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
Response:
{
"start_sequence": 50000000,
"end_sequence": 50000010,
"ledgers_processed": 11,
"contract": "CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC",
"transactions": [...],
"count": 15
}
GET /functionGet transactions calling a specific contract function by name.
Parameters:
ledger (required): Ledger sequence number, range, or negative valuename (required): Function name (e.g., 'transfer', 'approve', 'mint')Examples:
# Search for transfer function calls
curl "http://localhost:3000/function?ledger=50000000-50000100&name=transfer"
# Search recent ledgers for approve calls
curl "http://localhost:3000/function?ledger=-1000&name=approve"
Response:
{
"start_sequence": 50000000,
"end_sequence": 50000100,
"ledgers_processed": 101,
"function": "transfer",
"transactions": [...],
"count": 234
}
GET /balanceGet current token balance for a Stellar address using RPC.
Parameters:
address (required): Stellar account addresstoken (required): Token contract address or shortcutToken Shortcuts:
xlm - Native Stellar Lumensusdc - USD Coinusdt - Tether USDaqua - Aquarius tokenbtc - Bitcoin (wrapped)Examples:
# Get XLM balance
curl "http://localhost:3000/balance?address=GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB&token=xlm"
# Get USDC balance
curl "http://localhost:3000/balance?address=GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB&token=usdc"
# Get balance for specific token contract
curl "http://localhost:3000/balance?address=GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB&token=CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC"
Response:
{
"address": "GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB",
"token": "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA",
"balance": "1121995790",
"raw_balance": 1121995790
}
/help endpoint in a browser for full interactive documentation| Feature | CLI Mode | REST API Mode |
|---|---|---|
| Use Case | One-time queries, scripts, automation | Web applications, continuous access, integration |
| Output | stdout (console) | HTTP JSON responses |
| Concurrency | Single query per invocation | Multiple concurrent requests |
| Setup | Run directly | Start server once |
| Documentation | --help flag |
Interactive /help endpoint |
The tool calculates the S3 URL based on the ledger sequence number using the following format:
https://aws-public-blockchain.s3.us-east-2.amazonaws.com/v1.1/stellar/ledgers/pubnet/{PARTITION}/{BATCH}.xdr.zst
Where:
FFFFFFFF--{start}-{end}FFFFFFFF--{ledger}.xdr.zstExample for ledger 63864:
FFFFFFFF--0-63999/FFFF0687--63864.xdr.zst
The hexadecimal values are calculated as 0xFFFFFFFF - ledger_sequence.
LedgerCloseMetaBatch structureThe tool uses these default values from the S3 data lake configuration:
https://aws-public-blockchain.s3.us-east-2.amazonaws.comThe XDR files contain LedgerCloseMetaBatch structures with:
struct LedgerCloseMetaBatch {
start_sequence: u32,
end_sequence: u32,
ledger_close_metas: Vec<LedgerCloseMeta>,
}
Each LedgerCloseMeta can be V0, V1, or V2 format, containing:
There's a bug in WSL that prevents metadata, use Windows console
cargo test
cargo login
cargo clean
cargo package
cargo publish --dry-run
cargo publish
The major prompts that I used with Claude Code and Codex can be found in the prompts/ directory which has been published with the code to provide some insight in to the assisted development process I use.
Nb. the compounding bug was a stickler
MIT
Feel free to improve and put in a pull request ♥️