If you are looking for the IQ Option API in Python, the first honest truth is this: IQ Option has no 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 grey zone 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 integration in Python

Does IQ Option have an official API?

Not for the everyday trader. IQ Option offers integrations via partnership/affiliate arrangements 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.

Practical consequence: since nothing is official, the broker can change the protocol, demand a captcha, or block the account for automated usage. Bear in mind, too, that IQ Option is not FSCA-authorised in South Africa. Always use a demo account first and never risk money you cannot afford to lose.

Installing the library

The most active fork is usually pyiqoptionapi. The typical installation:

pip install pyiqoptionapi # alternativa direta do repositorio: pip install git+https://github.com/iqoptionapi/iqoptionapi.git

Connection and login

The entry point is the main class. The connect() method returns a tuple (status, motivo) — always check the status before continuing:

from iqoptionapi.stable_api import IQ_Option import logging logging.basicConfig(level=logging.INFO) api = IQ_Option(“seu_email”, “sua_senha”) status, reason = api.connect() if status: print(“Conectado!”) else: print(“Falha:”, reason) # Trabalhe SEMPRE em demo durante os testes: api.change_balance(“PRACTICE”) # ou “REAL” print(“Saldo:”, api.get_balance())

Main methods you will use

These are the most common day-to-day methods (names can vary between forks — check your installed version):

Account and balance: connect(), check_connect(), change_balance("PRACTICE"/"REAL"), get_balance(), reset_practice_balance().
Quotes / candles: get_candles(ativo, intervalo, quantidade, fim), start_candles_stream(), get_realtime_candles(), stop_candles_stream().
Binary orders: buy(valor, ativo, direcao, expiracao) 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)

ativo = “EURUSD” # 10 velas de 1 minuto ate agora import time velas = api.get_candles(ativo, 60, 10, time.time()) ultima = velas[-1] print(“Fechamento:”, ultima[“close”]) # Ordem binaria de 1 dolar, CALL, expiracao de 1 minuto direcao = “call” # ou “put” valor = 1 expiracao = 1 check, order_id = api.buy(valor, ativo, direcao, expiracao) if check: resultado, lucro = api.check_win_v4(order_id) print(“Resultado:”, resultado, “Lucro/Prejuizo:”, lucro) else: print(“Ordem recusada”)

The example places a 1-dollar binary order (most IQ Option accounts are denominated in US dollars; if yours runs in rand, the same value of 1 applies in ZAR) with a 1-minute expiry.

Robustness tip: wrap calls in try/except and reconnect with check_connect(). WebSocket drops frequently, 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:

Login fails even with the right password → captcha/2FA or anti-bot blocking.
Connection drops in long loops → missing reconnection and keep-alive.
get_candles comes back empty → asset closed at that hour (check schedules against SAST/UTC+2) or an incorrect symbol name.
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 this up: 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 properly documented API, such as Deriv, or ready-made solutions that have already been tested.

FAQ

Is pyiqoptionapi safe? The code is open and auditable, but you hand it your email and password. Use a unique password and, preferably, a demo account.

Can I get banned for using it? Yes. Automation generally breaches 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. IQ Option and similar offshore brokers are not authorised by the FSCA, so South African clients have no local regulatory protection. This content is educational, does not constitute investment advice, and unofficial libraries may breach the broker’s terms. Always test on a demo account before any real trade.

Similar Posts