Ticker

Endpoint URL

The Ticker API provides historical price data for stocks in customizable time windows. It allows you to fetch OHLCV (Open, High, Low, Close, Volume) data for any stock with flexible interval options.

Local Host   :  GET http://127.0.0.1:5000/api/v1/ticker/{exchange}:{symbol}
Ngrok Domain :  GET https://<your-ngrok-domain>.ngrok-free.app/api/v1/ticker/{exchange}:{symbol}
Custom Domain:  GET https://<your-custom-domain>/api/v1/ticker/{exchange}:{symbol}

Parameters

Path Parameters

  • exchange:symbol (required): Combined exchange and symbol (e.g., NSE:RELIANCE). Defaults to NSE:RELIANCE if not provided.

Query Parameters

  • interval (optional): The time interval for the data. Default: D Supported intervals:

    • Seconds: 5s, 10s, 15s, 30s, 45s

    • Minutes: 1m, 2m, 3m, 5m, 10m, 15m, 20m, 30m

    • Hours: 1h, 2h, 4h

    • Days: D

    • Weeks: W

    • Months: M

  • from (required): The start date in YYYY-MM-DD format or millisecond timestamp

  • to (required): The end date in YYYY-MM-DD format or millisecond timestamp

  • adjusted (optional): Whether to adjust for splits. Default: true

    • true: Results are adjusted for splits

    • false: Results are NOT adjusted for splits

  • sort (optional): Sort results by timestamp. Default: asc

    • asc: Results sorted in ascending order (oldest first)

    • desc: Results sorted in descending order (newest first)

Authentication

API key must be provided either:

  • In the request header as X-API-KEY

  • As a query parameter apikey

Note: The API key must be obtained from your OpenAlgo instance dashboard under the API Key section.

AmiBroker Integration

For AmiBroker users, use this exact URL template format to fetch historical quotes:

Example:

Example Request

Response Format

Error Responses

  • 400: Bad Request - Invalid parameters

  • 403: Forbidden - Invalid API key

  • 404: Not Found - Broker module not found

  • 500: Internal Server Error - Unexpected error

Example Usage

For example, to get 5-minute bars for RELIANCE stock from NSE:

This will return 5-minute OHLCV bars for RELIANCE between January 9, 2023, and February 10, 2023.

Ticker API Documentation

The Ticker API provides historical stock data in both daily and intraday formats. The API supports both JSON and plain text responses.

Endpoint

Parameters

Parameter
Type
Required
Description
Example

symbol

string

Yes

Stock symbol with exchange (e.g., NSE:RELIANCE)

NSE:RELIANCE

interval

string

No

Time interval (D, 1m, 5m, 1h, etc.). Default: D

5m

from

string

No

Start date in YYYY-MM-DD format

2024-12-01

to

string

No

End date in YYYY-MM-DD format

2024-12-31

apikey

string

Yes

API Key for authentication

your_api_key

format

string

No

Response format (json/txt). Default: json

txt

Response Formats

Plain Text Format (format=txt)

Daily Data (interval=D)

Format: Ticker,Date_YMD,Open,High,Low,Close,Volume

Example:

Intraday Data (interval=1m, 5m, etc.)

Format: Ticker,Date_YMD,Time,Open,High,Low,Close,Volume

Example:

JSON Format (format=json)

Error Responses

Plain Text Format

Error messages are returned as plain text with appropriate HTTP status codes.

Example:

JSON Format

HTTP Status Codes

Code
Description

200

Successful request

400

Bad request (invalid parameters)

403

Invalid API key

404

Broker module not found

500

Internal server error

Rate Limiting

The API is rate-limited to 10 requests per second by default. This can be configured using the API_RATE_LIMIT environment variable.

Date Range Restrictions

To prevent large queries that could hit broker rate limits, the API automatically restricts date ranges:

  • Daily/Weekly/Monthly intervals (D, W, M): Maximum 10 years from end date

  • Intraday intervals (1m, 5m, 1h, etc.): Maximum 30 days from end date

If a request exceeds these limits, the start date will be automatically adjusted. For example:

  • Original request: http://127.0.0.1:5000/api/v1/ticker/NSE:ICICIBANK?apikey=your_api_key_here&interval=1m&from=2000-06-01&to=2025-07-04&format=txt

  • Adjusted to: from=2025-06-04&to=2025-07-04&interval=1m (30 days for 1-minute data)

Notes

  1. All timestamps in the responses are in Indian Standard Time (IST)

  2. Volume is always returned as an integer

  3. If no symbol is provided, defaults to "NSE:RELIANCE"

  4. If no exchange is specified in the symbol, defaults to "NSE"

  5. The API supports both formats:

    • NSE:RELIANCE (preferred)

    • RELIANCE (defaults to NSE)

Last updated

Was this helpful?