Professional API service providing intelligent liquidity analysis across all Injective DEX markets.
Built for the Ninja API Forge hackathon on Injective blockchain.
This API helps developers build better trading applications by providing:
- Optimal Execution Routes - Split large orders across multiple markets to minimize slippage
- Real-time Arbitrage Detection - Find profitable price discrepancies across DEXes
- Comprehensive Liquidity Metrics - Get detailed market health scores and depth analysis
- Smart Order Routing - Automatically route trades for best execution
- Webhook Alerts - Get notified of arbitrage opportunities and liquidity changes
┌─────────────────┐
│ REST API │
│ (NestJS) │
└────────┬────────┘
│
┌────┴────┐
│ Cache │
│ (Redis) │
└─────────┘
│
┌────────┴─────────┐
│ Injective SDK │
│ (Real-time WS) │
└──────────────────┘
│
┌────────┴─────────┐
│ TimescaleDB │
│ (Time-series) │
└──────────────────┘
- Backend: TypeScript, NestJS 10
- Blockchain: Injective SDK (@injectivelabs/sdk-ts)
- Cache: Redis 7
- Database: TimescaleDB (PostgreSQL)
- Queue: Bull
- Documentation: OpenAPI/Swagger
- Node.js 20+
- pnpm
- Docker & Docker Compose
- Clone the repository
git clone https://github.com/yourusername/liquidity-intelligence-api.git
cd liquidity-intelligence-api- Install dependencies
pnpm install- Configure environment
cp .env.example .env
# Edit .env with your configuration- Start with Docker Compose (Recommended)
cd docker
docker-compose up -dThe API will be available at:
- API: http://localhost:3000/api/v1
- Documentation: http://localhost:3000/docs
- Health Check: http://localhost:3000/api/v1/health
# Start Redis & TimescaleDB
docker-compose up redis timescaledb -d
# Run in development mode
pnpm run start:dev
# Run tests
pnpm run test
# Build for production
pnpm run buildFind the best way to split an order across markets.
GET /api/v1/liquidity/token/{token}/best-route?amount=1000&side=buyExample Request:
curl http://localhost:3000/api/v1/liquidity/token/INJ/best-route?amount=1000&side=buyExample Response:
{
"markets": [
{
"marketId": "0x...",
"amount": 700,
"price": 15.23,
"slippage": 0.12
},
{
"marketId": "0x...",
"amount": 300,
"price": 15.28,
"slippage": 0.08
}
],
"totalAmount": 1000,
"averagePrice": 15.25,
"totalSlippage": 0.10,
"savings": 24.50,
"timestamp": "2026-02-14T10:30:00Z"
}Get comprehensive liquidity metrics for a market.
GET /api/v1/liquidity/market/{marketId}/analysisExample Response:
{
"marketId": "0x...",
"token": "INJ",
"liquidityScore": {
"overall": 85.4,
"depth": 125000,
"spread": 0.0015,
"concentration": 0.23,
"resilience": 0
},
"orderbook": {
"bids": [
{ "price": 15.20, "quantity": 1000 },
{ "price": 15.19, "quantity": 1500 }
],
"asks": [
{ "price": 15.21, "quantity": 1200 },
{ "price": 15.22, "quantity": 1100 }
]
},
"slippageEstimates": [
{ "orderSize": 100, "slippagePercent": 0.05, "priceImpact": 0.05 },
{ "orderSize": 500, "slippagePercent": 0.12, "priceImpact": 0.12 },
{ "orderSize": 1000, "slippagePercent": 0.25, "priceImpact": 0.25 }
],
"timestamp": "2026-02-14T10:30:00Z"
}Find profitable arbitrage across markets.
GET /api/v1/liquidity/opportunities/arbitrage?minSpread=0.5Example Response:
{
"opportunities": [
{
"buyMarket": "0x...",
"sellMarket": "0x...",
"buyPrice": 15.20,
"sellPrice": 15.35,
"spread": 0.15,
"spreadPercent": 0.99,
"maxProfitableSize": 500,
"estimatedProfit": 72.50,
"token": "INJ"
}
],
"count": 1,
"timestamp": "2026-02-14T10:30:00Z"
}Compare liquidity across multiple tokens.
GET /api/v1/liquidity/markets/comparison?tokens=INJ,USDT,ETHSubscribe to real-time alerts.
POST /api/v1/webhooks/subscribe
Content-Type: application/json
{
"url": "https://your-app.com/webhook",
"eventType": "arbitrage",
"threshold": 0.5
}Visit http://localhost:3000/docs for full Swagger documentation with:
- All endpoints
- Request/response schemas
- Try-it-now functionality
- Authentication details
Key environment variables:
# Application
PORT=3000
NODE_ENV=development
# Injective
INJECTIVE_NETWORK=testnet
INJECTIVE_CHAIN_ID=injective-888
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379
# Database
DATABASE_HOST=localhost
DATABASE_PORT=5432
DATABASE_NAME=liquidity_intelligence
# Rate Limiting
RATE_LIMIT_TTL=60
RATE_LIMIT_MAX=100See .env.example for full configuration options.
# Unit tests
pnpm run test
# E2E tests
pnpm run test:e2e
# Test coverage
pnpm run test:cov- Response Time: <100ms (cached), <1s (computed)
- Rate Limits: 100 requests/minute (configurable)
- Cache TTL: 5-15 seconds (endpoint-specific)
- WebSocket: Real-time orderbook updates
src/
├── modules/
│ ├── liquidity/ # Core liquidity logic
│ │ ├── algorithms/ # Calculation engines
│ │ ├── dto/ # Data transfer objects
│ │ └── entities/ # Database models
│ ├── injective/ # Injective SDK integration
│ ├── webhooks/ # Webhook system
│ └── jobs/ # Background tasks
├── config/ # Configuration
├── common/ # Shared utilities
└── health/ # Health checks
- Create DTOs in
dto/ - Implement business logic in service
- Add controller endpoint
- Update Swagger annotations
- Write tests
This project was built for Ninja API Forge hackathon. Contributions welcome!
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing) - Open Pull Request
MIT License - see LICENSE file
Event: Ninja API Forge
Category: Developer APIs on Injective
Built by: Evanson Kamau
Date: February 2026
Trading applications need liquidity intelligence to:
- Minimize slippage on large orders
- Find arbitrage opportunities
- Route orders optimally
- Monitor market health
This API provides all of that in simple, well-documented endpoints.
- Twitter: @yourusername
- GitHub: @yourusername
- Email: evansonkamau233@gmail.com
- Injective Labs for the amazing blockchain infrastructure
- Ninja Labs for organizing the hackathon
- NestJS community for the excellent framework
Made with ❤️ for Injective ecosystem