mirror of
https://github.com/luxfi/indexer.git
synced 2026-10-30 16:22:36 +00:00
191 lines
2.8 KiB
Plaintext
191 lines
2.8 KiB
Plaintext
---
|
|
title: API Reference
|
|
description: REST, GraphQL, and WebSocket API documentation
|
|
---
|
|
|
|
# API Reference
|
|
|
|
The Lux Indexer provides a full explorer API v2 plus additional endpoints.
|
|
|
|
## REST API v2
|
|
|
|
Base URL: `/v1/explorer`
|
|
|
|
### Blocks
|
|
|
|
```bash
|
|
# Get latest blocks
|
|
GET /v1/explorer/blocks
|
|
|
|
# Get block by number
|
|
GET /v1/explorer/blocks/{number}
|
|
|
|
# Get block transactions
|
|
GET /v1/explorer/blocks/{number}/transactions
|
|
```
|
|
|
|
### Transactions
|
|
|
|
```bash
|
|
# Get transaction by hash
|
|
GET /v1/explorer/transactions/{hash}
|
|
|
|
# Get transaction logs
|
|
GET /v1/explorer/transactions/{hash}/logs
|
|
|
|
# Get internal transactions
|
|
GET /v1/explorer/transactions/{hash}/internal-transactions
|
|
```
|
|
|
|
### Addresses
|
|
|
|
```bash
|
|
# Get address info
|
|
GET /v1/explorer/addresses/{hash}
|
|
|
|
# Get address transactions
|
|
GET /v1/explorer/addresses/{hash}/transactions
|
|
|
|
# Get token balances
|
|
GET /v1/explorer/addresses/{hash}/token-balances
|
|
|
|
# Get coin balance history
|
|
GET /v1/explorer/addresses/{hash}/coin-balance-history
|
|
```
|
|
|
|
### Tokens
|
|
|
|
```bash
|
|
# List tokens
|
|
GET /v1/explorer/tokens
|
|
|
|
# Get token info
|
|
GET /v1/explorer/tokens/{hash}
|
|
|
|
# Get token transfers
|
|
GET /v1/explorer/tokens/{hash}/transfers
|
|
|
|
# Get token holders
|
|
GET /v1/explorer/tokens/{hash}/holders
|
|
```
|
|
|
|
### Smart Contracts
|
|
|
|
```bash
|
|
# Get verified contract
|
|
GET /v1/explorer/smart-contracts/{hash}
|
|
|
|
# Get contract ABI
|
|
GET /v1/explorer/smart-contracts/{hash}/methods-read
|
|
|
|
# Submit verification
|
|
POST /v1/explorer/smart-contracts/{hash}/verification
|
|
```
|
|
|
|
### Search
|
|
|
|
```bash
|
|
# Universal search
|
|
GET /v1/explorer/search?q={query}
|
|
```
|
|
|
|
### Stats
|
|
|
|
```bash
|
|
# Get chain stats
|
|
GET /v1/explorer/stats
|
|
|
|
# Get gas price oracle
|
|
GET /v1/explorer/stats/gas-price
|
|
|
|
# Get charts data
|
|
GET /v1/explorer/stats/charts/{type}
|
|
```
|
|
|
|
## GraphQL API
|
|
|
|
Endpoint: `/graphql`
|
|
|
|
```graphql
|
|
# Get block with transactions
|
|
query {
|
|
block(number: 12345) {
|
|
hash
|
|
number
|
|
timestamp
|
|
transactions {
|
|
hash
|
|
from
|
|
to
|
|
value
|
|
}
|
|
}
|
|
}
|
|
|
|
# Get address details
|
|
query {
|
|
address(hash: "0x...") {
|
|
balance
|
|
transactionCount
|
|
tokens {
|
|
token {
|
|
name
|
|
symbol
|
|
}
|
|
balance
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|
|
## WebSocket API
|
|
|
|
Endpoint: `/ws`
|
|
|
|
### Subscribe to new blocks
|
|
|
|
```json
|
|
{
|
|
"type": "subscribe",
|
|
"channel": "new_block"
|
|
}
|
|
```
|
|
|
|
### Subscribe to address transactions
|
|
|
|
```json
|
|
{
|
|
"type": "subscribe",
|
|
"channel": "address_updates",
|
|
"address": "0x..."
|
|
}
|
|
```
|
|
|
|
### Subscribe to token transfers
|
|
|
|
```json
|
|
{
|
|
"type": "subscribe",
|
|
"channel": "token_transfers",
|
|
"token": "0x..."
|
|
}
|
|
```
|
|
|
|
## Etherscan-Compatible RPC
|
|
|
|
Endpoint: `/api/rpc`
|
|
|
|
```bash
|
|
# Get balance
|
|
GET /api/rpc?module=account&action=balance&address=0x...
|
|
|
|
# Get transactions
|
|
GET /api/rpc?module=account&action=txlist&address=0x...
|
|
|
|
# Get token transfers
|
|
GET /api/rpc?module=account&action=tokentx&address=0x...
|
|
|
|
# Verify contract
|
|
POST /api/rpc?module=contract&action=verifysourcecode
|
|
```
|