If you want to read market data from IQ Option 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 guide to the IQ Option API in Python, with connection, candle and execution examples?
See the IQ Option API guide in Python →What is get_candles?
iqoptionapi is a community-maintained (unofficial) library that connects to IQ Option through the same WebSocket channels used by the browser. The get_candles method requests a batch of candles ending at a given point in time, returning a list of dictionaries with the open, high, low, close, volume and timestamps of each candle.
Syntax and parameters
The usual signature is get_candles(asset, interval, amount, end_time):
interval — candle size in seconds (60 = 1 min, 300 = 5 min)
amount — number of candles to return
end_time — 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 end = time.time(), or use the continuous streams (start_candles_stream / get_realtime_candles) when you want updates without re-polling.
Common errors
get_all_open_time().Reversed timestamp:
end_time must be the end of the period, not the start. For older history, subtract amount × interval.Disconnections: the unofficial API drops frequently — implement reconnection and check
api.check_connect() before every call.
The risks of using an unofficial API
IQ Option does not publish an official API for retail clients. iqoptionapi is reverse-engineered from the website’s protocol, which means: it can stop working with any platform update, it may violate the terms of use and, under heavy/automated usage, your account can be restricted. 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?
Usually 60 seconds (1 minute). Values like 5, 10 and 15 seconds depend on the asset and on availability in the platform.
Is iqoptionapi official?
No. It is a community project, with no support from IQ Option, and it can break at any moment.
Can I backtest with this data?
Yes, by downloading historical candles in batches. Watch out for gaps and for the timestamp timezone (Unix/UTC).
Disclaimer: binary options are extremely high-risk products and most retail traders lose money. This content is educational and technical; it does not constitute an investment recommendation, offer or financial advice. Unofficial APIs may violate the broker’s terms of use and can stop working without notice. Always test on a demo account before trading with real money and never risk amounts you cannot afford to lose.
