If you want to read IQ Option market data with Python, the get_candles method of the unofficial iqoptionapi library is the most common starting point. It lets you download historical candles for any asset and timeframe — the foundation for backtests, indicators and bots. In this no-nonsense guide we show the correct syntax, the parameters that usually confuse people (timestamp and candle size), a working example and the real risks of using an API that is not official.
Want the complete step-by-step for the IQ Option API in Python, with connection, candle and execution examples?
See the IQ Option API in Python guide →What is get_candles?
The iqoptionapi is a community-maintained (unofficial) library that connects to IQ Option through the same WebSocket channels the browser uses. The get_candles method requests a batch of candles ending at a given moment in time, returning a list of dictionaries with the open, high, low, close, volume and the timestamps of each candle.
Syntax and parameters
The usual signature is get_candles(ativo, intervalo, quantidade, fim_em):
intervalo — candle size in seconds (60 = 1 min, 300 = 5 min)
quantidade — number of candles to return
fim_em — Unix timestamp of the most recent candle you want (usually
time.time())
Working example
Each item in the list carries the keys open, close, max, min, volume and the from/to times. For “real-time” candles, simply call get_candles in a loop with fim = time.time(), or use the continuous streams (start_candles_stream / get_realtime_candles) when you want updates without repolling.
Common errors
get_all_open_time().Inverted timestamp:
fim_em must be the end of the period, not the start. For older history, subtract quantidade × intervalo.Disconnection: the unofficial API drops frequently — implement reconnection and check
api.check_connect() before each call.
Risks of using an unofficial API
IQ Option does not publish an official API for retail clients. The iqoptionapi reverse-engineers the website’s protocol, which means: it can stop working with any platform update, it may breach the terms of use and, with intense/automated usage, your account can be restricted. It is also worth remembering that IQ Option is an offshore broker with no FSCA authorisation in South Africa. Use it for study and backtesting responsibly, and never blindly trust signals generated by unaudited code.
FAQ
Does get_candles fetch real-time data?
It pulls a batch ending at the moment you specify. For continuous updates, use the streams (start_candles_stream / get_realtime_candles).
What is the minimum candle interval?
Normally 60 seconds (1 minute). Values like 5, 10 and 15 seconds depend on the asset and on availability on the platform.
Is iqoptionapi official?
No. It is a community project, with no support from IQ Option, and it can break at any time.
Can I backtest with this data?
Yes, by downloading historical candles in batches. Watch out for gaps and for the timestamp timezone (Unix/UTC — two hours behind SAST).
Disclaimer: binary options are extremely high-risk products and most retail traders lose money. In South Africa, offshore binary options brokers such as IQ Option are not authorised by the FSCA, so you have no local regulatory protection. This content is educational and technical, and does not constitute investment advice, an offer or financial advice. Unofficial APIs may breach the broker’s terms of use and stop working without notice. Always test on a demo account before trading real money and never risk rand you cannot afford to lose.
