Documentation

API reference

Everything is authenticated with an API key. A key is tied to a list of symbols and, optionally, the website domains allowed to use it.

# your first request
curl -H "x-api-key: YOUR_API_KEY" \
  https://indiantrader.in/v1/quote/XAUUSD

Authentication

Send the key as the x-api-key header, or as ?key= in the URL. The WebSocket requires the query form.

x-api-keyHeader form. Recommended for server-to-server calls.
?key=Query form. Needed for WebSocket and for the widget.
DomainsBrowser calls must come from a domain on the key's allow-list. Calls without an Origin header are allowed.

Chart widget

Load the script once, then add a data-it-chart element wherever you want a chart.

<script src="https://indiantrader.in/widget.js"></script>

<div data-it-chart
     data-key="YOUR_API_KEY"
     data-symbol="XAUUSD"
     data-timeframe="H1"
     data-theme="dark"
     style="height:520px"></div>
data-keyRequired. Your API key.
data-symbolInitial symbol. Default XAUUSD.
data-timeframeM1 M5 M15 M30 H1 H4 D1 W1 MN. Default H1.
data-themedark or light. Default dark.
data-symbolsComma list that limits the symbol picker.
data-toolbarfalse hides the toolbar.
data-volumefalse hides the volume pane.

JavaScript API

const chart = IndianTrader.chart('#my-div', { key: 'YOUR_API_KEY', symbol: 'EURUSD' });
chart.setSymbol('GBPUSD');
chart.setTimeframe('H4');
chart.destroy();

REST API

Base URL: https://indiantrader.in. All responses are JSON. Errors return {"error": "…"} with a matching status code.

GET/v1/symbols

The symbols your key can use, with price digits and the last quote.

{ "data": [ { "symbol": "XAUUSD", "digits": 2,
            "bid": 3876.9, "ask": 3877.06, "time": 1793393700054 } ] }

GET/v1/quote/:symbol

The latest quote for one symbol.

GET/v1/overview

A snapshot for a watchlist or heatmap in one call: quote, change versus the previous daily close, today's range, and a day of sparkline closes. Up to 60 symbols.

symbolsOptional comma list. Defaults to every symbol your key can use (first 60).
{ "data": [ { "symbol": "XAUUSD", "digits": 2, "bid": 3876.9, "ask": 3877.06,
            "prevClose": 4010.2, "change": -3.313,
            "high": 4018.865, "low": 3870.285,
            "spark": [ 3890.1, 3888.4, … ] } ] }

change, high, low and spark are empty for symbols without candle history.

GET/v1/candles/:symbol

timeframeM1 M3 M5 M15 M30 H1 H4 D1 W1 MN. Default H1.
limit1 to 1500. Default 500.
toUnix milliseconds. Returns the candles ending at this time — use it to page backwards.
{ "symbol": "XAUUSD", "timeframe": "H1", "count": 200,
  "data": [ { "time": 1792389600, "open": 4184.7, "high": 4186.6,
            "low": 4171.2, "close": 4183.9, "volume": 8675 } ] }

Times are Unix seconds, oldest first. Daily bars follow the broker's midnight, so they may not start at 00:00 UTC. Weekly and monthly bars are built from daily bars.

WebSocket stream

Connect to wss://indiantrader.in/v1/stream?key=YOUR_API_KEY, then subscribe to symbols.

→ send
{"op":"subscribe","symbols":["XAUUSD","EURUSD"]}
{"op":"unsubscribe","symbols":["EURUSD"]}
{"op":"ping"}

← receive
{"t":"hello","symbols":251}
{"t":"ticks","d":[["XAUUSD",3876.9,3877.06,1793393700054]]}
{"t":"candle","s":"XAUUSD","tf":"M1","c":[1793393640,3876.5,3877.1,3876.4,3876.9,241]}
{"t":"error","error":"unknown symbol ABC"}
ticks[symbol, bid, ask, time in ms]. Batched, with the newest tick per symbol, about ten times a second.
candleA closed bar: [time, open, high, low, close, volume].
reconnectReconnect with backoff after a drop and re-send your subscriptions.

Errors and limits

401Invalid API key.
403Key disabled or expired, or the domain isn't allowed for this key.
404Unknown symbol, or one outside the key's scope.
429Rate limit reached, or too many connections for this key.
502History is temporarily unavailable. Retry shortly.