Skip to content

ivanmolto/injective-signals-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

86 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯· Injective Signals API

Prediction market-style analytics derived from Injective perpetual futures data

A developer-focused API that transforms raw Injective exchange data into actionable trading signals, sentiment indicators, and market health metrics.

🎯 What It Does

This API provides derived signals and computed analytics on top of Injective's perpetual futures markets:

Signal Type Description
Implied Probability Bull/bear probability estimates derived from funding rates, orderbook imbalance, and momentum
Sentiment Indicator Market sentiment score (-100 to +100) with categorical labels
Momentum Indicator Price momentum with directional strength
Liquidity Score Market depth and spread analysis
Funding Rate Signals Contrarian signals from funding rate extremes
Market Health Score Overall market quality grade (A-F)
Conviction Ranking Cross-market signal strength comparison

πŸ“‘ Injective Data Sources

Overview

The Injective Signals API uses official Injective SDK packages to fetch real-time data from Injective's indexer infrastructure. All signals and analytics are calculated locally from this raw data.

Data Sources

Source SDK Class Description
Indexer gRPC API IndexerGrpcDerivativesApi Markets, orderbooks, trades, funding rates
Chronos REST API IndexerRestDerivativesChronosApi Market summaries (OHLCV, 24h change)

SDK Packages

{
  "@injectivelabs/sdk-ts": "^1.17.7",
  "@injectivelabs/networks": "^1.17.7"
}

Methods Used

IndexerGrpcDerivativesApi

Method Description Used In
fetchMarkets() List all derivative markets /api/markets
fetchOrderbookV2(marketId) Get orderbook (bids/asks) /api/markets/{id}/orderbook, signals
fetchTrades({ marketId, pagination }) Get recent trades /api/markets/{id}/trades, signals
fetchFundingRates({ marketId, pagination }) Get funding rate history /api/funding, signals

IndexerRestDerivativesChronosApi

Method Description Used In
fetchMarketSummary(marketId) Get 24h OHLCV data Signals, momentum calculation

Network Configuration

import { getNetworkEndpoints, Network } from "@injectivelabs/networks";

const endpoints = getNetworkEndpoints(Network.Mainnet);
// endpoints.indexer β€” gRPC indexer endpoint
// endpoints.chronos β€” Chronos REST endpoint

The API supports both mainnet (default) and testnet via the NETWORK environment variable.

Data Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Injective Network                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   Injective Indexer                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚  gRPC Derivatives   β”‚  β”‚  Chronos REST API           β”‚   β”‚
β”‚  β”‚  - Markets          β”‚  β”‚  - Market Summaries         β”‚   β”‚
β”‚  β”‚  - Orderbooks       β”‚  β”‚  - OHLCV Data               β”‚   β”‚
β”‚  β”‚  - Trades           β”‚  β”‚  - 24h Statistics           β”‚   β”‚
β”‚  β”‚  - Funding Rates    β”‚  β”‚                             β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 Injective Signals API                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Signal Calculations                     β”‚    β”‚
β”‚  β”‚  - Implied Probability (funding + orderbook)        β”‚    β”‚
β”‚  β”‚  - Sentiment Index (funding + imbalance + volume)   β”‚    β”‚
β”‚  β”‚  - Momentum Score (price changes + volume)          β”‚    β”‚
β”‚  β”‚  - Liquidity Score (depth + spread)                 β”‚    β”‚
β”‚  β”‚  - Conviction Ranking (combined signals)            β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                      API Endpoints                           β”‚
β”‚  GET /api/markets      - Raw market data                    β”‚
β”‚  GET /api/signals      - Calculated trading signals         β”‚
β”‚  GET /api/funding      - Funding rate analysis              β”‚
β”‚  GET /api/conviction   - Market conviction rankings         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Raw Data vs Calculated Signals

Raw Data (from Injective)

  • Market metadata (ticker, fees, margin requirements)
  • Orderbook depth (bids/asks with price and quantity)
  • Trade history (execution price, quantity, side)
  • Funding rates (hourly rates)
  • Market summaries (24h OHLCV)

Calculated Signals (by this API)

  • Implied Probability β€” Bullish/bearish probability based on funding rate, orderbook imbalance, and momentum
  • Sentiment Index β€” Market sentiment score (-100 to +100) with fear/greed labels
  • Momentum Score β€” Price momentum based on 1h and 24h price changes
  • Liquidity Score β€” Market liquidity based on spread and depth
  • Conviction Ranking β€” Combined signal strength for trade conviction

References

πŸš€ Quick Start

Local Development

npm install
cp .env.example .env
npm run dev

Deploy to Vercel

Option 1: One-Click Deploy

Deploy with Vercel

Option 2: CLI Deploy

# Install Vercel CLI
npm i -g vercel

# Deploy (from project root)
vercel

# Deploy to production
vercel --prod

Option 3: GitHub Integration

  1. Push to GitHub
  2. Go to vercel.com
  3. Import your repository
  4. Deploy automatically on every push

Test the API

# Health check
curl http://localhost:3000/api/health

# List all markets
curl http://localhost:3000/api/markets?status=active

# Get signals for a market
curl http://localhost:3000/api/signals/0x...marketId

# Get conviction ranking
curl http://localhost:3000/api/conviction

πŸ“‘ API Endpoints

Interactive Documentation

Visit /docs for the interactive Swagger UI where you can explore and test all endpoints.

  • Swagger UI: https://your-app.vercel.app/docs
  • OpenAPI Spec: https://your-app.vercel.app/api/openapi

Markets

Endpoint Description
GET /api/markets List all derivative markets
GET /api/markets/:marketId Get single market details
GET /api/markets/:marketId/orderbook Get orderbook depth
GET /api/markets/:marketId/trades Get recent trades

Signals (Core Analytics)

Endpoint Description
GET /api/signals Get signals for all markets
GET /api/signals/:marketId Get comprehensive signals for a market
GET /api/signals/:marketId/probability Get implied probability only
GET /api/signals/:marketId/sentiment Get sentiment indicator only

Funding Rate Analysis

Endpoint Description
GET /api/funding Get funding rate extremes across all markets
GET /api/funding/:marketId Get detailed funding rate analysis

Market Health

Endpoint Description
GET /api/health/:marketId Get market health score and warnings

Conviction Ranking

Endpoint Description
GET /api/conviction Get conviction ranking across all markets

πŸ“Š Response Examples

Market Signal

{
  "success": true,
  "data": {
    "marketId": "0x...",
    "ticker": "BTC/USDT PERP",
    "timestamp": "2024-01-15T10:30:00Z",
    "markPrice": 42500.5,
    "lastTradePrice": 42498.0,
    "impliedProbability": {
      "bullish": 0.58,
      "bearish": 0.42,
      "confidence": 0.75,
      "signals": ["funding_rate", "orderbook_imbalance", "momentum"]
    },
    "sentiment": {
      "score": 23.5,
      "label": "greed",
      "components": {
        "fundingRate": 15.2,
        "orderbookImbalance": 28.4,
        "volumeTrend": 18.9
      }
    },
    "momentum": {
      "score": 32.1,
      "direction": "bullish",
      "priceChange": {
        "1h": 0.45,
        "24h": 2.15
      },
      "volumeChange24h": 1.08
    },
    "liquidity": {
      "score": 78.5,
      "depth": {
        "bids": {
          "atHalfPercent": 150000,
          "atOnePercent": 450000,
          "atTwoPercent": 890000
        },
        "asks": {
          "atHalfPercent": 145000,
          "atOnePercent": 420000,
          "atTwoPercent": 850000
        }
      },
      "spread": { "absolute": 0.5, "percentage": 0.0012 },
      "imbalanceRatio": 0.045
    },
    "metrics": {
      "fundingRate": 0.00015,
      "volume24h": 15400000,
      "openInterest": 0,
      "tradeCount24h": 4523,
      "high24h": 43200,
      "low24h": 41800
    }
  },
  "timestamp": "2024-01-15T10:30:00Z"
}

Funding Rate Analysis

{
  "success": true,
  "data": {
    "marketId": "0x...",
    "ticker": "BTC/USDT PERP",
    "currentRate": 0.00025,
    "predictedRate": 0.00018,
    "annualizedRate": 21.9,
    "extremeLevel": "positive",
    "signal": "sell",
    "history": [
      { "timestamp": "2024-01-15T10:00:00Z", "rate": 0.00025 },
      { "timestamp": "2024-01-15T09:00:00Z", "rate": 0.00022 }
    ]
  }
}

Conviction Ranking

{
  "success": true,
  "data": {
    "count": 10,
    "rankings": [
      {
        "marketId": "0x...",
        "ticker": "ETH/USDT PERP",
        "convictionScore": 72.5,
        "direction": "long",
        "strength": "strong",
        "factors": [
          {
            "factor": "funding_rate",
            "contribution": 25.0,
            "direction": "bullish"
          },
          {
            "factor": "orderbook_imbalance",
            "contribution": 18.5,
            "direction": "bullish"
          },
          { "factor": "momentum", "contribution": 29.0, "direction": "bullish" }
        ]
      }
    ]
  }
}

πŸ”§ Configuration

Environment Variable Description Default
NETWORK Injective network (mainnet or testnet) mainnet
PORT Server port 3000

πŸ“ Signal Methodology

Implied Probability

Combines three signals with weighted contributions as an adjustment to a base score:

  1. Funding Rate (Β±15%): Contrarian signal - high positive funding suggests overextended longs
  2. Orderbook Imbalance (Β±15%): Bid/ask volume ratio indicates buying/selling pressure
  3. Momentum (Β±10%): Recent price action contribution

Sentiment Score

Weighted composite of:

  • Funding Rate Component (40%)
  • Orderbook Imbalance Component (35%)
  • Volume Trend Component (25%)

Labels: extreme_fear | fear | neutral | greed | extreme_greed

Market Health Grade

Based on:

  • Liquidity (35%): Orderbook depth and value
  • Volatility (25%): 24h price range stability
  • Activity (25%): Trade count
  • Spread (15%): Bid-ask spread tightness

πŸ›  Injective Data Sources Used

Source Data
IndexerGrpcDerivativesApi Markets, orderbooks, trades, positions, funding rates
IndexerRestDerivativesChronosApi 24h market summaries

πŸ“¦ Tech Stack

  • Runtime: Node.js + TypeScript
  • Framework: Express.js
  • Injective SDK: @injectivelabs/sdk-ts
  • Caching: In-memory with TTL

πŸ— Project Structure

injective-signals-api/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.ts              # Entry point
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── index.ts          # API route definitions
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ injectiveClient.ts  # Injective SDK wrapper
β”‚   β”‚   β”œβ”€β”€ marketDataService.ts # Raw data fetching + caching
β”‚   β”‚   └── signalsService.ts   # Signal calculations
β”‚   └── types/
β”‚       └── index.ts          # TypeScript type definitions
β”œβ”€β”€ package.json
β”œβ”€β”€ tsconfig.json
└── README.md

πŸ“œ License

MIT

πŸ”— Links


Built for Ninja API Forge Hackathon πŸ₯·

About

Market Signals API for Injective - Prediction market style analytics derived from perpetual futures data

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors