Market Data API

Complete reference for accessing real-time and historical market data, including price feeds, order book data, and trading statistics.

Overview

The Market Data API provides access to real-time and historical market data for all supported trading pairs. This includes price feeds, order book data, trade history, and market statistics.

Base URL

https://api.vibetrading.tech/api/v1/market

Price Data

Get Current Price

Get the current price for a trading pair.

Endpoint: GET /price/{symbol}

Parameters:

  • symbol (string, required): Trading pair symbol (e.g., "BTC/USD")

Response:

{
  "symbol": "BTC/USD",
  "price": 49850.25,
  "bid": 49840.0,
  "ask": 49860.5,
  "bidSize": 0.5,
  "askSize": 0.3,
  "volume24h": 1250.75,
  "change24h": 2.5,
  "changePercent24h": 0.05,
  "high24h": 50200.0,
  "low24h": 48500.0,
  "timestamp": "2024-01-15T12:00:00Z"
}

Get Multiple Prices

Get current prices for multiple trading pairs.

Endpoint: GET /prices

Query Parameters:

  • symbols (string, optional): Comma-separated list of symbols
  • include24hChange (boolean, optional): Include 24h change data (default: true)

Response:

{
  "prices": [
    {
      "symbol": "BTC/USD",
      "price": 49850.25,
      "change24h": 2.5,
      "changePercent24h": 0.05
    },
    {
      "symbol": "ETH/USD",
      "price": 3250.75,
      "change24h": -15.25,
      "changePercent24h": -0.47
    }
  ],
  "timestamp": "2024-01-15T12:00:00Z"
}

Historical Data

Get Candlestick Data

Retrieve historical candlestick (OHLCV) data.

Endpoint: GET /candles/{symbol}

Query Parameters:

  • interval (string, required): Time interval ("1m", "5m", "15m", "1h", "4h", "1d")
  • startTime (string, optional): Start time (ISO 8601)
  • endTime (string, optional): End time (ISO 8601)
  • limit (number, optional): Number of candles (max 1000, default 100)

Response:

{
  "symbol": "BTC/USD",
  "interval": "1h",
  "candles": [
    {
      "timestamp": "2024-01-15T11:00:00Z",
      "open": 49500.0,
      "high": 50200.0,
      "low": 49200.0,
      "close": 49850.25,
      "volume": 125.75
    },
    {
      "timestamp": "2024-01-15T12:00:00Z",
      "open": 49850.25,
      "high": 50100.0,
      "low": 49700.0,
      "close": 49950.0,
      "volume": 98.25
    }
  ]
}

Get Trade History

Retrieve recent trades for a trading pair.

Endpoint: GET /trades/{symbol}

Query Parameters:

  • limit (number, optional): Number of trades (max 1000, default 100)
  • startTime (string, optional): Start time (ISO 8601)
  • endTime (string, optional): End time (ISO 8601)

Response:

{
  "symbol": "BTC/USD",
  "trades": [
    {
      "tradeId": "trade_123456",
      "price": 49850.25,
      "quantity": 0.1,
      "side": "buy",
      "timestamp": "2024-01-15T12:00:00Z"
    },
    {
      "tradeId": "trade_123457",
      "price": 49860.5,
      "quantity": 0.05,
      "side": "sell",
      "timestamp": "2024-01-15T12:00:01Z"
    }
  ]
}

Order Book Data

Get Order Book

Retrieve current order book (market depth) for a trading pair.

Endpoint: GET /orderbook/{symbol}

Query Parameters:

  • depth (number, optional): Number of price levels (max 100, default 20)

Response:

{
  "symbol": "BTC/USD",
  "timestamp": "2024-01-15T12:00:00Z",
  "bids": [
    {
      "price": 49840.0,
      "quantity": 0.5
    },
    {
      "price": 49835.0,
      "quantity": 0.3
    }
  ],
  "asks": [
    {
      "price": 49860.5,
      "quantity": 0.3
    },
    {
      "price": 49865.0,
      "quantity": 0.4
    }
  ]
}

Get Order Book Summary

Get order book summary statistics.

Endpoint: GET /orderbook/{symbol}/summary

Response:

{
  "symbol": "BTC/USD",
  "timestamp": "2024-01-15T12:00:00Z",
  "bestBid": {
    "price": 49840.0,
    "quantity": 0.5
  },
  "bestAsk": {
    "price": 49860.5,
    "quantity": 0.3
  },
  "spread": 20.5,
  "spreadPercent": 0.041,
  "midPrice": 49850.25,
  "totalBidVolume": 2.5,
  "totalAskVolume": 1.8
}

Market Statistics

Get Market Stats

Retrieve comprehensive market statistics.

Endpoint: GET /stats/{symbol}

Response:

{
  "symbol": "BTC/USD",
  "timestamp": "2024-01-15T12:00:00Z",
  "price": {
    "current": 49850.25,
    "open24h": 48600.0,
    "high24h": 50200.0,
    "low24h": 48500.0,
    "change24h": 1250.25,
    "changePercent24h": 2.57
  },
  "volume": {
    "volume24h": 1250.75,
    "volume7d": 8750.25,
    "volume30d": 37500.5,
    "averageVolume24h": 1200.0
  },
  "trades": {
    "count24h": 15420,
    "averageSize24h": 0.081,
    "largestTrade24h": 5.25
  },
  "volatility": {
    "volatility24h": 0.025,
    "volatility7d": 0.035,
    "volatility30d": 0.042
  }
}

Get Market Summary

Get summary data for all trading pairs.

Endpoint: GET /summary

Response:

{
  "markets": [
    {
      "symbol": "BTC/USD",
      "price": 49850.25,
      "change24h": 2.57,
      "volume24h": 1250.75,
      "marketCap": 950000000000
    },
    {
      "symbol": "ETH/USD",
      "price": 3250.75,
      "change24h": -0.47,
      "volume24h": 850.25,
      "marketCap": 390000000000
    }
  ],
  "totalMarkets": 150,
  "totalVolume24h": 2500000.0,
  "timestamp": "2024-01-15T12:00:00Z"
}

AI Signals

Get AI Signal

Retrieve current AI trading signal for a trading pair.

Endpoint: GET /signals/{symbol}

Response:

{
  "symbol": "BTC/USD",
  "timestamp": "2024-01-15T12:00:00Z",
  "signal": {
    "recommendation": "buy",
    "confidence": 87,
    "timeHorizon": "short_term",
    "riskLevel": "medium",
    "reasoning": [
      "Strong bullish momentum detected",
      "High volume confirmation",
      "Positive sentiment from social media",
      "Technical indicators showing oversold conditions"
    ]
  },
  "technicalAnalysis": {
    "rsi": 35.2,
    "macd": "bullish",
    "movingAverage": "above",
    "support": 48500.0,
    "resistance": 50200.0
  },
  "sentimentAnalysis": {
    "socialSentiment": 0.75,
    "newsSentiment": 0.68,
    "fearGreedIndex": 45
  }
}

Get Multiple AI Signals

Retrieve AI signals for multiple trading pairs.

Endpoint: GET /signals

Query Parameters:

  • symbols (string, optional): Comma-separated list of symbols
  • minConfidence (number, optional): Minimum confidence level (0-100)

Response:

{
  "signals": [
    {
      "symbol": "BTC/USD",
      "recommendation": "buy",
      "confidence": 87,
      "timeHorizon": "short_term"
    },
    {
      "symbol": "ETH/USD",
      "recommendation": "hold",
      "confidence": 65,
      "timeHorizon": "medium_term"
    }
  ],
  "timestamp": "2024-01-15T12:00:00Z"
}

Market Indices

Get Market Index

Retrieve market index data (e.g., Fear & Greed Index).

Endpoint: GET /indices/{indexName}

Available Indices:

  • fear_greed: Crypto Fear & Greed Index
  • volatility: Market Volatility Index
  • momentum: Market Momentum Index

Response:

{
  "indexName": "fear_greed",
  "value": 45,
  "classification": "fear",
  "description": "Market showing signs of fear",
  "timestamp": "2024-01-15T12:00:00Z",
  "historicalValues": [
    {
      "timestamp": "2024-01-14T12:00:00Z",
      "value": 42
    },
    {
      "timestamp": "2024-01-15T12:00:00Z",
      "value": 45
    }
  ]
}

Supported Symbols

Cryptocurrency Pairs

  • Major Pairs: BTC/USD, ETH/USD, BNB/USD, ADA/USD, SOL/USD
  • Altcoin Pairs: DOGE/USD, SHIB/USD, MATIC/USD, DOT/USD, AVAX/USD
  • Cross Pairs: BTC/ETH, ETH/BNB, ADA/BTC

Traditional Markets

  • Stocks: AAPL/USD, MSFT/USD, GOOGL/USD, TSLA/USD, AMZN/USD
  • Forex: EUR/USD, GBP/USD, USD/JPY, AUD/USD, CAD/USD
  • Commodities: GOLD/USD, SILVER/USD, OIL/USD, NATGAS/USD

Indices

  • Stock Indices: SPX/USD, NASDAQ/USD, DOW/USD
  • Crypto Indices: CRYPTO/USD, DEFI/USD, NFT/USD

Data Intervals

Available Intervals

  • 1m: 1 minute
  • 5m: 5 minutes
  • 15m: 15 minutes
  • 30m: 30 minutes
  • 1h: 1 hour
  • 4h: 4 hours
  • 1d: 1 day
  • 1w: 1 week
  • 1M: 1 month

Data Retention

  • 1m, 5m, 15m: 30 days
  • 30m, 1h: 90 days
  • 4h, 1d: 1 year
  • 1w, 1M: 5 years

Error Handling

Common Errors

Invalid Symbol (400)

{
  "error": "invalid_symbol",
  "message": "The symbol 'INVALID/USD' is not supported",
  "code": 400,
  "supportedSymbols": ["BTC/USD", "ETH/USD", "BNB/USD"]
}

Invalid Interval (400)

{
  "error": "invalid_interval",
  "message": "The interval '2m' is not supported",
  "code": 400,
  "supportedIntervals": ["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w", "1M"]
}

Data Not Available (404)

{
  "error": "data_not_available",
  "message": "Historical data not available for the requested time range",
  "code": 404
}

Rate Limits

  • Price Data: 1000 requests per minute
  • Historical Data: 100 requests per minute
  • Order Book: 200 requests per minute
  • AI Signals: 50 requests per minute
  • Market Stats: 100 requests per minute

Code Examples

Python Market Data Client

import requests
import pandas as pd
from datetime import datetime, timedelta

class MarketDataClient:
    def __init__(self, api_key, secret_key):
        self.api_key = api_key
        self.secret_key = secret_key
        self.base_url = "https://api.vibetrading.tech/api/v1/market"

    def get_current_price(self, symbol):
        """Get current price for a symbol"""
        response = requests.get(
            f"{self.base_url}/price/{symbol}",
            headers=self._get_headers()
        )
        return response.json()

    def get_candles(self, symbol, interval, limit=100):
        """Get historical candlestick data"""
        end_time = datetime.utcnow()
        start_time = end_time - timedelta(hours=limit)

        params = {
            "interval": interval,
            "startTime": start_time.isoformat() + "Z",
            "endTime": end_time.isoformat() + "Z",
            "limit": limit
        }

        response = requests.get(
            f"{self.base_url}/candles/{symbol}",
            headers=self._get_headers(),
            params=params
        )
        return response.json()

    def get_ai_signal(self, symbol):
        """Get AI trading signal"""
        response = requests.get(
            f"{self.base_url}/signals/{symbol}",
            headers=self._get_headers()
        )
        return response.json()

    def _get_headers(self):
        # Include authentication headers
        return {
            "X-API-Key": self.api_key,
            "X-Timestamp": str(int(datetime.utcnow().timestamp())),
            "X-Signature": self._generate_signature()
        }

    def _generate_signature(self):
        # Implement signature generation
        pass

# Usage
client = MarketDataClient("your_api_key", "your_secret_key")

# Get current Bitcoin price
btc_price = client.get_current_price("BTC/USD")
print(f"BTC Price: ${btc_price['price']}")

# Get hourly candles for the last 24 hours
candles = client.get_candles("BTC/USD", "1h", 24)
df = pd.DataFrame(candles['candles'])
print(df.head())

# Get AI signal
signal = client.get_ai_signal("BTC/USD")
print(f"AI Recommendation: {signal['signal']['recommendation']}")
print(f"Confidence: {signal['signal']['confidence']}%")

JavaScript Market Data Client

const axios = require("axios");

class MarketDataClient {
  constructor(apiKey, secretKey) {
    this.apiKey = apiKey;
    this.secretKey = secretKey;
    this.baseUrl = "https://api.vibetrading.tech/api/v1/market";
  }

  async getCurrentPrice(symbol) {
    const response = await axios.get(`${this.baseUrl}/price/${symbol}`, {
      headers: this.getHeaders(),
    });
    return response.data;
  }

  async getCandles(symbol, interval, limit = 100) {
    const endTime = new Date();
    const startTime = new Date(endTime.getTime() - limit * 60 * 60 * 1000);

    const params = {
      interval,
      startTime: startTime.toISOString(),
      endTime: endTime.toISOString(),
      limit,
    };

    const response = await axios.get(`${this.baseUrl}/candles/${symbol}`, {
      headers: this.getHeaders(),
      params,
    });
    return response.data;
  }

  async getAISignal(symbol) {
    const response = await axios.get(`${this.baseUrl}/signals/${symbol}`, {
      headers: this.getHeaders(),
    });
    return response.data;
  }

  getHeaders() {
    return {
      "X-API-Key": this.apiKey,
      "X-Timestamp": Math.floor(Date.now() / 1000).toString(),
      "X-Signature": this.generateSignature(),
    };
  }

  generateSignature() {
    // Implement signature generation
    return "signature";
  }
}

// Usage
const client = new MarketDataClient("your_api_key", "your_secret_key");

async function main() {
  // Get current Bitcoin price
  const btcPrice = await client.getCurrentPrice("BTC/USD");
  console.log(`BTC Price: $${btcPrice.price}`);

  // Get hourly candles for the last 24 hours
  const candles = await client.getCandles("BTC/USD", "1h", 24);
  console.log("Recent candles:", candles.candles.slice(0, 5));

  // Get AI signal
  const signal = await client.getAISignal("BTC/USD");
  console.log(`AI Recommendation: ${signal.signal.recommendation}`);
  console.log(`Confidence: ${signal.signal.confidence}%`);
}

main().catch(console.error);

Need real-time data? Check out our WebSocket Feeds for live market data streams.