If you are looking for the IQ Option API in Python, the first honest truth is this: IQ Option does not have an official public API for automating retail accounts. Everything circulating on GitHub — including the popular pyiqoptionapi library (a maintained fork of the old iqoptionapi) — is reverse engineering of the WebSocket channel used by the website. It works, but it lives in a gray area and can break with any broker update. This guide shows the real methods, with examples, and where the risks are.
Want to automate without fighting an unofficial library that breaks every week? See the ready-made alternative:
▶ See the IQ Option bot and Python integrationDoes IQ Option have an official API?
Not for the everyday trader. IQ Option offers integrations via partnerships/affiliates in some corporate cases, but it does not publish trading API documentation for individual accounts. That is why all automation depends on libraries that mimic the browser, connecting to the WebSocket endpoint wss://iqoption.com/echo/websocket and sending the same commands the website would send.
Installing the library
The most active fork is usually pyiqoptionapi. The typical installation:
Connection and login
The entry point is the main class. The connect() method returns a (status, reason) tuple — always check the status before continuing:
The main methods you will use
These are the most common methods in day-to-day use (names may vary between forks — check the version you installed):
connect(), check_connect(), change_balance("PRACTICE"/"REAL"), get_balance(), reset_practice_balance().
get_candles(asset, interval, amount, endtime), start_candles_stream(), get_realtime_candles(), stop_candles_stream().
buy(amount, asset, direction, expiration) returns (check, id); track it with check_win_v4(id) or check_win_digital_v2(id) for digital options.
Example: read candles and send an order (on DEMO)
try/except and reconnect with check_connect(). The WebSocket drops often, and a loop without reconnection simply freezes.
Common errors (and why they happen)
Most problems are not bugs in your code, but changes on the broker’s side:
Connection drops during long loops → missing reconnection and keep-alive.
get_candles comes back empty → the asset is closed at that time or the symbol name is wrong.
The library stops working out of nowhere → IQ Option updated the protocol; wait for a new fork.
Is automating IQ Option worth it?
For learning and testing ideas on demo, yes — it is a great laboratory. For trading real money, weigh it carefully: you depend on unofficial code that can break, and no automation turns binary options (a negative-sum game because of the payout) into guaranteed income. If your goal is stability, consider brokers with a truly documented API, such as Deriv, or ready-made, already tested solutions.
FAQ
Is pyiqoptionapi safe? The code is open and auditable, but you hand it your e-mail and password. Use a dedicated password and, preferably, a demo account.
Can I get banned for using it? Yes. Automation usually violates the terms of use. The broker can close the account.
Does it work with digital options? Yes, there are specific methods (buy_digital_spot, check_win_digital_v2), but they change more between versions.
Is there a more stable alternative? Deriv has an official, documented API. For IQ Option, ready-made solutions reduce the maintenance burden.
Disclaimer: binary options are extremely high-risk products and most retail traders lose money. This content is educational, does not constitute investment advice, and unofficial libraries may violate the broker’s terms. Always test on a demo account before any real trade.
