Build
Explorer API
Lib Explorer has a REST API (v2) for blocks, transactions, addresses, tokens and contracts, and an Etherscan-compatible API for existing tools.
Lib Explorer runs Blockscout, which indexes every block and serves two public APIs. Both are free, need no key, and allow requests from any website (CORS is open).
| API | Base URL | Best for |
|---|---|---|
| REST v2 | https://testnet.libchain.tech/api/v2 | New apps: rich JSON, pagination, token and contract data |
| Etherscan-compatible | https://testnet.libchain.tech/api | Existing tools and scripts written for Etherscan |
Interactive documentation for every endpoint is at https://testnet.libchain.tech/api-docs.
#REST v2 essentials
| Endpoint | Returns |
|---|---|
GET /stats | Totals: blocks, transactions, addresses, average block time |
GET /main-page/blocks | The latest blocks |
GET /blocks/{number} | One block |
GET /transactions/{hash} | One transaction, decoded when the contract is verified |
GET /addresses/{address} | Balance, contract flag, names |
GET /addresses/{address}/transactions | An address's transactions, newest first |
GET /addresses/{address}/token-balances | Every token an address holds |
GET /tokens/{address} | Token metadata and total supply |
GET /tokens/{address}/holders | Holders, largest first |
GET /smart-contracts/{address} | Verified source, ABI and compiler settings |
GET /search?q=… | Search by address, hash, token name or block |
curl -s https://testnet.libchain.tech/api/v2/stats
curl -s https://testnet.libchain.tech/api/v2/tokens/0x87052f1f17b2b4054b014e93e53d6ce6dc912bda
curl -s "https://testnet.libchain.tech/api/v2/addresses/0xYourAddress/transactions"#Pagination
List endpoints return items and next_page_params. Pass those parameters back as the query string to get the next page; null means you've reached the end.
async function* allTransactions(address: string) {
let query = ''
while (true) {
const page = await fetch(`https://testnet.libchain.tech/api/v2/addresses/${address}/transactions${query}`).then((r) => r.json())
yield* page.items
if (!page.next_page_params) return
query = '?' + new URLSearchParams(page.next_page_params).toString()
}
}Addresses the explorer has never seen return 404. Treat that as "no activity yet", not as an error.
#Etherscan-compatible API
Most Etherscan calls work unchanged against https://testnet.libchain.tech/api. An API key isn't required.
# Native balance (wei)
curl -s "https://testnet.libchain.tech/api?module=account&action=balance&address=0xYourAddress"
# Transactions of an address
curl -s "https://testnet.libchain.tech/api?module=account&action=txlist&address=0xYourAddress&page=1&offset=25"
# ERC-20 balance and supply
curl -s "https://testnet.libchain.tech/api?module=account&action=tokenbalance&contractaddress=0x87052f1f17b2b4054b014e93e53d6ce6dc912bda&address=0xYourAddress"
curl -s "https://testnet.libchain.tech/api?module=stats&action=tokensupply&contractaddress=0x87052f1f17b2b4054b014e93e53d6ce6dc912bda"
# ABI of a verified contract
curl -s "https://testnet.libchain.tech/api?module=contract&action=getabi&address=0x87052f1f17b2b4054b014e93e53d6ce6dc912bda"#Rate limits
About 30 requests a second per IP address, with short bursts up to 60, and 60 open connections. Over that you'll get 429 Too Many Requests: back off and retry. For a dashboard, cache responses for a few seconds; blocks only change every 2 to 60 seconds anyway.