InsightSentry

    Historical Data

    Overview

    '/history' endpoint provides the historical data for a symbol from the most recent quote update.

    Key Features:

    • Supports both GET and POST requests
    • Includes the current price
    • Up to 20k data point (ticks) from the most recent quote update
    • Same response format as '/latest' or '/realtime' endpoints for easier intergration with the new series data

    GET request

    https://insightsentry.p.rapidapi.com/v1/history?code=NASDAQ:AAPL&interval=300&interval_type=minute

    POST request

    {
      "code": "NASDAQ:AAPL",
      "interval": 1000, 
      "interval_type": "minute" 
    }

    Request Parameter

    If you set `interval_type` to `'day'` and `interval` to `20000`, you will retrieve up to 20,000 days of data from the most recent update.
    Likewise, if you set 'interval_type' to 'second' and 'interval' to 20000, you will retrieve the last 20000 seconds of data from the most recent update.

    code
    Symbol code (e.g., 'NASDAQ:AAPL')
    interval
    Optional. Default value is '1000'. Number of bars (ticks) to retrieve (300 - 20,000).
    interval_type
    Optional. Default value is 'minute' Allowed values: 'second', 'minute', 'hour', 'day', 'week', 'month'
    interval_length
    Optional. Default value is 1. Allowed values are as follows: when interval_type is 'second', only 1 is allowed else ignored. For other types, only less than 1 year is allowed

    Response Data

    {
      "code": "NASDAQ:AAPL",
      "next_start": 1733432340,
      "bar_type": "minute",
      "series": [
        // omitted for brevity
        {
          "time": 1733432220,
          "open": 242.815,
          "high": 242.95,
          "low": 242.7428,
          "close": 242.9395,
          "volume": 131905
        },
        {
          "time": 1733432280,
          "open": 242.94,
          "high": 243.05,
          "low": 242.87,
          "close": 242.89,
          "volume": 193484
        },
        {
          "time": 1733432340, // most recent bar
          "open": 242.89,
          "high": 243.09,
          "low": 242.82,
          "close": 243.08, // current price
          "volume": 533779
        }
      ]
    }

    Response Fields

    code
    Symbol code (String)
    bar_end
    End time of the current bar (Unix time in seconds, Integer)
    bar_type
    Type of the bar - 's' is seconds. m is minutes. h is hours. D is days. W is weeks. M is months. (String)
    series
    Array of bars (Array)
    time
    Time of the current bar (Unix time in seconds, Integer)
    open
    Opening price of the bar (Float)
    high
    Highest price of the bar (Float)
    low
    Lowest price of the bar (Float)
    close
    Current price (if the bar is not finished) or the close price of the bar (Float)
    volume
    Trading volume (Integer)

    Code Examples

    import requests
    
    url = "https://insightsentry.p.rapidapi.com/v1/history"
    headers = {
        "x-rapidapi-key": "<your key>",
        "x-rapidapi-host": "insightsentry.p.rapidapi.com"
    }
    data = {
        "code": "NASDAQ:AAPL",
        "interval": 300,
        "interval_type": "minute",
        "interval_length": 1
    }
    
    response = requests.post(url, headers=headers, json=data)
    print(response.text)
    
    # or you can also use GET request
    
    response = requests.get("https://insightsentry.p.rapidapi.com/v1/history?code=NASDAQ:AAPL&interval=300&interval_type=minute&interval_length=1", headers=headers)
    print(response.text)