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.
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>
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.
{ "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
{ "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"}