Back to Developers
API Reference
Complete reference for the ChainLens API. Access blockchain data, smart contract interactions, and analytics with simple REST endpoints and SDKs.
Base URL
https://api.getchainlens.comAuthentication
All API requests require an API key passed in the Authorization header:
Authorization: Bearer your-api-keyKeep your API key secure. Never expose it in client-side code.
Supported Networks
Ethereumlive
Chain ID: 1Arbitrumlive
Chain ID: 42161Optimismlive
Chain ID: 10Baselive
Chain ID: 8453Polygonlive
Chain ID: 137BSClive
Chain ID: 56Avalanchebeta
Chain ID: 43114zkSync Erabeta
Chain ID: 324Endpoints
Blockchain Data
GET
/v1/blocks/{number}Get block by number or hash
number: Block number or "latest"
GET
/v1/transactions/{hash}Get transaction details and receipt
hash: Transaction hash
GET
/v1/addresses/{address}/balanceGet address balance across tokens
address: Wallet address
GET
/v1/addresses/{address}/transactionsGet transaction history for address
addresspagelimitsort
Token Data
GET
/v1/tokens/{address}Get token metadata and statistics
address: Token contract address
GET
/v1/tokens/{address}/holdersGet top token holders
addresslimit
GET
/v1/tokens/{address}/transfersGet token transfer history
addressfromtolimit
Smart Contracts
GET
/v1/contracts/{address}Get contract metadata and ABI
address: Contract address
POST
/v1/contracts/{address}/callCall read-only contract function
addressfunctionargs
GET
/v1/contracts/{address}/eventsGet contract events and logs
addresseventfromBlocktoBlock
Analytics
GET
/v1/analytics/gasGet current gas prices and predictions
network
GET
/v1/analytics/defi/tvlGet DeFi protocol TVL data
protocolchain
POST
/v1/analytics/traceTrace transaction execution
txHash
SDK Examples
import { ChainLens } from '@chainlens/sdk';
const client = new ChainLens({
apiKey: 'your-api-key',
network: 'ethereum'
});
// Get wallet balance
const balance = await client.getBalance('0x...');
console.log(balance);
// Get transaction history
const txs = await client.getTransactions({
address: '0x...',
limit: 10
});
// Subscribe to events
client.subscribe('Transfer', {
contract: '0x...',
callback: (event) => {
console.log('New transfer:', event);
}
});Rate Limits
| Plan | Requests | WebSockets | Support |
|---|---|---|---|
| Free | 100/min | 5 | Community |
| Pro | 1,000/min | 25 | |
| Enterprise | Unlimited | Unlimited | Dedicated |
Error Codes
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions
404Not FoundResource does not exist
429Too Many RequestsRate limit exceeded
500Internal ErrorServer error, please retry
Webhooks
Set up webhooks to receive real-time notifications for blockchain events.
// Create a webhook
POST /v1/webhooks
{
"url": "https://your-server.com/webhook",
"events": ["transfer", "swap", "liquidation"],
"filters": {
"contract": "0x...",
"minValue": "1000000000000000000"
}
}
// Webhook payload
{
"id": "evt_123",
"type": "transfer",
"data": {
"from": "0x...",
"to": "0x...",
"value": "1000000000000000000",
"txHash": "0x..."
},
"timestamp": 1699900000
}Ready to Build?
Get your free API key and start building with ChainLens in minutes.