Impi
A developer-friendly market data processing API for Injective that provides computed & derived market metrics.
视频

技术栈
描述
Injective Market Intelligence API
A developer-friendly market data processing API for Injective that provides computed & derived market metrics.
Overview
This API processes raw Injective market data into actionable intelligence including:
Market Summary (price, volume, spread, depth)
Liquidity Metrics (bid/ask depth, imbalance, concentration)
Volatility Metrics (price change, volatility index, anomaly detection)
Health Indicators (liquidity, stability, activity scores)
Injective Data Sources
This API fetches real-time data from Injective Exchange API:
Markets: All trading pairs available on Injective
Orderbook: Real-time buy/sell orders
Trades: Recent trade history
Candles: OHLCV price history
API Endpoints Used
/exchange/v1/markets- List all markets/exchange/v1/orderbook/{market_id}- Orderbook snapshot/exchange/v1/trades/{market_id}- Recent trades/exchange/v1/orderbook/candles/{market_id}- Price history
Environment Selection
Configure mainnet or testnet via environment variable:
INJECTIVE_ENVIRONMENT=mainnet # or "testnet"Mainnet:
https://api.injective.exchangeTestnet:
https://testnet.api.injective.exchange
Installation
Configuration
Copy .env.example to .env and configure:
cp .env.example .envEdit .env with your settings:
# Injective API Configuration
INJECTIVE_ENVIRONMENT=mainnet # "mainnet" or "testnet"
INJECTIVE_API_BASE_URL=https://api.injective.exchange
INJECTIVE_API_TIMEOUT=30
INJECTIVE_USE_REAL_DATA=true # Set to false to use mock data for testing
# Application Configuration
APP_NAME=Injective Market Intelligence API
APP_VERSION=1.0.0
APP_HOST=0.0.0.0
APP_PORT=8000
DEBUG=false
# Optional: Redis Cache
REDIS_URL=redis://localhost:6379/0
CACHE_TTL=60Running the API
uvicorn app.main:app --reloadThe API will be available at http://localhost:8000
API Documentation
Interactive API documentation available at:
Swagger UI:
http://localhost:8000/docsReDoc:
http://localhost:8000/redoc
API Endpoints
Health Check
GET /healthList Markets
GET /api/v1/marketsLists all available markets on Injective Exchange.
Response:
{
"markets": [
{
"market_id": "0x...",
"ticker": "INJ/USDT",
"base_denom": "inj",
"quote_denom": "usdt"
}
],
"count": 1
}Market Summary
GET /api/v1/markets/{market_id}/summaryGet comprehensive market overview with price, volume, spread, and depth.
Response:
{
"market_id": "0x...",
"market_name": "INJ/USDT",
"price": "42.50",
"price_change_24h": "+5.2%",
"volume_24h": "12500000",
"spread": "0.02%",
"bid_depth": "500000",
"ask_depth": "480000"
}Liquidity Metrics
GET /api/v1/markets/{market_id}/liquidityGet detailed liquidity metrics including depth, imbalance, and concentration.
Response:
{
"market_id": "0x...",
"bid_depth_top10": "500000",
"ask_depth_top10": "480000",
"depth_imbalance_pct": "2.04%",
"liquidity_concentration": "0.65",
"spread_bps": 20
}Volatility Metrics
GET /api/v1/markets/{market_id}/volatilityGet volatility indicators including price change and volatility index.
Response:
{
"market_id": "0x...",
"price_change_24h": "+5.2%",
"volatility_index": 1.5,
"abnormal_movement_detected": false
}Health Score
GET /api/v1/markets/{market_id}/healthGet comprehensive health scoring with individual component metrics.
Response:
{
"market_id": "0x...",
"liquidity_score": 85,
"stability_score": 72,
"activity_score": 90,
"overall_health": 82,
"rating": "A"
}Project Structure
app/
├── api/routes/ # API endpoints
├── services/ # Business logic & data fetching
│ ├── injective_raw.py # Injective API client
│ ├── injective_norm.py # Data normalizer
│ └── market_service.py # Service orchestration
├── computations/ # Metric calculations
│ ├── liquidity.py # Liquidity metrics
│ ├── volatility.py # Volatility metrics
│ └── health.py # Health scoring
├── models/ # Pydantic schemas
└── core/ # Configuration
Architecture
Injective Exchange API (REST)
↓
Raw Data Fetcher (injective_raw.py)
↓
Data Normalizer (injective_norm.py)
↓
Computation Engine (volatility, liquidity, health)
↓
REST API (FastAPI)
Development
Running Tests
Using Mock Data
For testing without real API calls, set:
INJECTIVE_USE_REAL_DATA=falseThis will use mock data instead of making real API calls.
Code Style
This project follows standard Python conventions with type hints.
Docker Deployment
# Build and run with Docker Compose
docker-compose up -dThis starts:
FastAPI application on port 8000
Redis for caching (optional)
Background worker for data refresh (optional)
Built for Ninja API Forge
This project is submitted for the Ninja API Forge hackathon.
Category: Computation/Derived Data API
Features:
✅ Developer-friendly REST API
✅ Real-time Injective data integration
✅ Computed market metrics
✅ Clean, extensible architecture
✅ Docker deployment ready
License
MIT License