Repository navigation
relayer-data-api v0.1.0 — Trading Data API Initial Release
Pre-release📊 Relayer Data API v0.1.0 – First Developer Release
This is the initial release of the Twilight Relayer Data API, a specialized read-only JSON-RPC service that provides structured access to real-time and historical trading data from the Twilight Relayer ecosystem.
🎯 Purpose & Design
The Data API is architurally separated from order submission systems to ensure uninterrupted access to trading data even under high load. This design supports scalable data consumption by external clients including trading dashboards, analytics engines, and monitoring tools.
📈 Data Access Features
Real-Time Trading Data
- Order Management: Open and historical order tracking
- Account State: Real-time balance and margin state queries
- Market Data: Live price feeds and funding rate information
- PnL Analytics: Realized and unrealized profit/loss calculations
Historical Data & Analytics
- Complete order history with filtering capabilities
- Historical price data and market trends
- Account balance evolution over time
- Comprehensive trading performance metrics
🏗️ Architecture Components
| Service | Purpose | Features |
|---|---|---|
| API Server | JSON-RPC endpoint | Query processing, data serialization |
| Archiver | Data persistence | Historical data management, indexing |
| Auth Server | Access control | Authentication, rate limiting |
| PostgreSQL | Data storage | Optimized schemas for trading data |
🚀 Key Benefits
- High Availability: Independent operation from order submission systems
- Scalable Access: Designed for multiple concurrent data consumers
- Performance Optimized: Efficient querying with PostgreSQL backend
- Developer Friendly: Clean JSON-RPC interface with comprehensive data models
- Production Ready: Docker deployment with environment configuration
🛠️ Quick Start
Docker Deployment (Recommended)
bash > # Build with SSH key for private repo access > DOCKER_BUILDKIT=1 docker build . -t relayer-api --build-arg SSH_KEY="$(cat ~/.ssh/build_key)" > docker-compose -f twilight-relayerAPI/docker-compose.yaml up -d >
Local Development
bash > # Install dependencies > sudo apt install libpq-dev > cargo install diesel_cli --no-default-features --features postgres > > # Start PostgreSQL > docker run --rm -ePOSTGRES_DATABASE=relayer -ePOSTGRES_USER=relayer -ePOSTGRES_PASSWORD=relayer -p 5432:5432 postgres > > # Run services > cargo run --release --bin archiver # Data archiver > cargo run --release --bin api # API server > cargo run --release --bin auth # Auth server >
📋 Environment Setup
- Configure
DATABASE_URLfor PostgreSQL connection - Set up authentication credentials for secure access
- Review
.env.examplefile for service configuration
⚠️ Important Notes
- Order Submission: Use the separate Relayer Order API for placing/canceling orders
- Development Status: First release - expect API refinements in future versions
- Testing: Run
./init_test_db.sh && cargo testfor comprehensive testing
🔗 Ecosystem Integration
Designed to work seamlessly with:
- relayer-core - High-performance matching engine
- twilight-relayer-sdk - Relayer service SDK
- Trading dashboards and analytical tools
Perfect for: Trading dashboards, market analysis tools, portfolio trackers, and any application requiring reliable access to Twilight Relayer trading data.