> ## Documentation Index
> Fetch the complete documentation index at: https://docs.innova-trading.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get OHLC Bars

> Fetch historical OHLC candlestick data for a trading symbol

## Request

<ParamField query="symbol" type="string" required>
  Trading symbol (e.g., `EURUSD`, `GBPUSD`, `XAUUSD`)
</ParamField>

<ParamField query="timeframe" type="integer" required>
  Timeframe in minutes:

  * `1` - M1 (1 minute)
  * `5` - M5 (5 minutes)
  * `15` - M15 (15 minutes)
  * `60` - H1 (1 hour)
  * `240` - H4 (4 hours)
  * `1440` - D1 (1 day)
</ParamField>

<ParamField query="limit" type="integer" default="500">
  Number of bars to return. Maximum: `5000`
</ParamField>

<ParamField query="before_time" type="integer">
  Unix timestamp. Only return bars before this time (for pagination).
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="symbol" type="string">
  The requested symbol
</ResponseField>

<ResponseField name="timeframe" type="integer">
  The requested timeframe in minutes
</ResponseField>

<ResponseField name="count" type="integer">
  Number of bars returned
</ResponseField>

<ResponseField name="bars" type="array">
  Array of OHLC bar objects

  <Expandable title="Bar Object">
    <ResponseField name="bar_number" type="integer">
      Index of the bar (0 = oldest)
    </ResponseField>

    <ResponseField name="time" type="integer">
      Unix timestamp of the bar. **Use this value when submitting signals!**
    </ResponseField>

    <ResponseField name="datetime_utc" type="string">
      ISO 8601 formatted datetime in UTC
    </ResponseField>

    <ResponseField name="open" type="float">
      Opening price
    </ResponseField>

    <ResponseField name="high" type="float">
      Highest price
    </ResponseField>

    <ResponseField name="low" type="float">
      Lowest price
    </ResponseField>

    <ResponseField name="close" type="float">
      Closing price
    </ResponseField>

    <ResponseField name="volume" type="integer">
      Trading volume
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="pagination" type="object">
  Pagination information

  <Expandable title="Pagination Object">
    <ResponseField name="has_more" type="boolean">
      Whether more data is available
    </ResponseField>

    <ResponseField name="oldest_time" type="integer">
      Timestamp of the oldest bar returned
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.innova-trading.com/api/external/bars?symbol=EURUSD&timeframe=60&limit=100" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      "https://api.innova-trading.com/api/external/bars",
      params={
          "symbol": "EURUSD",
          "timeframe": 60,
          "limit": 100
      },
      headers={"Authorization": "Bearer YOUR_API_KEY"}
  )

  bars = response.json()["bars"]
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.innova-trading.com/api/external/bars?symbol=EURUSD&timeframe=60&limit=100",
    {
      headers: { Authorization: "Bearer YOUR_API_KEY" }
    }
  );

  const { bars } = await response.json();
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "success": true,
    "symbol": "EURUSD",
    "timeframe": 60,
    "count": 100,
    "bars": [
      {
        "bar_number": 0,
        "time": 1765540800,
        "datetime_utc": "2025-12-12T04:00:00Z",
        "open": 1.1732,
        "high": 1.1740,
        "low": 1.1725,
        "close": 1.1738,
        "volume": 2500
      },
      {
        "bar_number": 1,
        "time": 1765544400,
        "datetime_utc": "2025-12-12T05:00:00Z",
        "open": 1.1738,
        "high": 1.1745,
        "low": 1.1730,
        "close": 1.1742,
        "volume": 1800
      }
    ],
    "pagination": {
      "has_more": true,
      "oldest_time": 1765540800
    }
  }
  ```

  ```json Error Response (403) theme={null}
  {
    "error": "forbidden",
    "message": "Symbol XAUUSD not allowed for your API key",
    "allowed_symbols": ["EURUSD", "GBPUSD", "USDJPY"]
  }
  ```

  ```json Error Response (503) theme={null}
  {
    "error": "no_data",
    "message": "No bar data available. VPS/MT5 may be offline.",
    "symbol": "EURUSD",
    "timeframe": 60
  }
  ```
</ResponseExample>

## Pagination Example

To fetch more historical data:

```python theme={null}
all_bars = []
before_time = None

while True:
    params = {"symbol": "EURUSD", "timeframe": 60, "limit": 1000}
    if before_time:
        params["before_time"] = before_time

    response = requests.get(url, params=params, headers=headers)
    data = response.json()

    all_bars.extend(data["bars"])

    if not data["pagination"]["has_more"]:
        break

    before_time = data["pagination"]["oldest_time"]

print(f"Fetched {len(all_bars)} total bars")
```

<Warning>
  The `time` field is the **real Unix timestamp** from the market data source.
  Always use this value when submitting signals to ensure correct positioning on the chart.
</Warning>
