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.com

Authentication

All API requests require an API key passed in the Authorization header:

Authorization: Bearer your-api-key
Keep your API key secure. Never expose it in client-side code.

Supported Networks

Ethereumlive
Chain ID: 1
Arbitrumlive
Chain ID: 42161
Optimismlive
Chain ID: 10
Baselive
Chain ID: 8453
Polygonlive
Chain ID: 137
BSClive
Chain ID: 56
Avalanchebeta
Chain ID: 43114
zkSync Erabeta
Chain ID: 324

Endpoints

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}/balance

Get address balance across tokens

address: Wallet address
GET
/v1/addresses/{address}/transactions

Get transaction history for address

addresspagelimitsort

Token Data

GET
/v1/tokens/{address}

Get token metadata and statistics

address: Token contract address
GET
/v1/tokens/{address}/holders

Get top token holders

addresslimit
GET
/v1/tokens/{address}/transfers

Get token transfer history

addressfromtolimit

Smart Contracts

GET
/v1/contracts/{address}

Get contract metadata and ABI

address: Contract address
POST
/v1/contracts/{address}/call

Call read-only contract function

addressfunctionargs
GET
/v1/contracts/{address}/events

Get contract events and logs

addresseventfromBlocktoBlock

Analytics

GET
/v1/analytics/gas

Get current gas prices and predictions

network
GET
/v1/analytics/defi/tvl

Get DeFi protocol TVL data

protocolchain
POST
/v1/analytics/trace

Trace 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

PlanRequestsWebSocketsSupport
Free100/min5Community
Pro1,000/min25Email
EnterpriseUnlimitedUnlimitedDedicated

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.