Incremental blockchain contracts indexer for TON network using tonapi.io API.
- Fetches TON account addresses via GraphQL
- Downloads contract inspection data via REST API
- Saves data as JSON files in hierarchical directory structure
- Resumes from last processed cursor (incremental)
- Handles rate limits and retries automatically
- Install dependencies:
npm install- Configure environment:
cp env.example .env
# Edit .env and add your TONAPI_KEY- Build and run:
npm run build
npm startEnvironment variables:
| Variable | Required | Description |
|---|---|---|
TONAPI_KEY |
✅ | API key from tonapi.io |
DATA_DIRECTORY |
❌ | Output directory (default: ./data) |
MAX_CONCURRENT_REQUESTS |
❌ | Parallel requests (default: 4) |
ACCOUNTS_PER_PAGE |
❌ | Accounts per page (default: 100) |
data/
├── 00/
│ ├── 00/ (JSON files)
│ ├── 01/ (JSON files)
│ └── ...
├── 01/
└── ...
Files are saved as: inspect_{address}.json
- ✅ Incremental pagination with cursor persistence
- ✅ Hierarchical file organization (scalable to billions of files)
- ✅ Rate limit handling with exponential backoff
- ✅ Parallel processing with configurable concurrency
- ✅ Automatic retries on network errors
- ✅ Graceful shutdown handling
- ✅ Structured JSON logging
npm start # Run single iteration
npm run dev # Development mode with hot reload
npm run build # Build TypeScript
npm run lint # Check code styleAdd to crontab for periodic execution:
*/5 * * * * cd /path/to/ton-api-indexing && npm start