🐍 Advanced Tutorial

Python + IQ Option API Unofficial — Honest Guide

By Dan Machado · April 2026 · 12 min · Level: Advanced

IQ Option has no official API, but there’s a community-maintained Python library on GitHub: iqoptionapi. It lets you automate trades — with important caveats.

In this tutorial, I’ll show you how to use it, the risks involved, and why Deriv is a much better alternative for automation.

⚠️ HEADS UP before continuing

The iqoptionapi is unofficial. Using automation on IQ Option may violate the terms of service and result in account ban. Use only on a demo account for educational purposes. To run bots on a live account, use Deriv (which has an official API).

What is iqoptionapi?

It’s an open-source Python library hosted on GitHub (github.com/Lu-Yi-Hsun/iqoptionapi and forks). It reverse-engineers the internal IQ Option endpoints to allow:

  • Login with email/password
  • Check balance and history
  • Execute binary options trades (Rise/Fall, Turbo)
  • Get real-time quotes
  • Access historical candle data

📌 Project status

The original project has limited maintenance. There are more active forks. The API can break at any moment when IQ Option changes its internal endpoints — this has already happened multiple times. It’s not reliable for 24/7 trading.

Important risks

  • Account ban: IQ Option can detect automated traffic and ban your account
  • Frequent breakage: Platform updates break the API without notice
  • No official support: If something fails, you’re on your own
  • Credentials at risk: You have to put login/password in the code
  • ToS violation: May violate IQ Option’s terms of service
  • Demo only: For study and testing, it’s relatively safe

Installation

Terminal
pip install iqoptionapi

Basic Code

Python · iqoptionapi📋 Copy
"""
Basic example — IQ Option API (unofficial)
IA Trader Pro — iatraderpro.com/

WARNING: Use ONLY on a DEMO account.
Automation can get your account banned.
"""

from iqoptionapi.stable_api import IQ_Option
import time
import logging

# === CONFIG ===
EMAIL = "your_email@example.com"
PASSWORD = "your_password"
ASSET = "EURUSD"
STAKE = 1  # Amount in USD
DURATION = 1  # Duration in minutes
DIRECTION = "call"  # "call" or "put"

# === CONNECT ===
print("🔐 Connecting to IQ Option...")
api = IQ_Option(EMAIL, PASSWORD)
api.connect()

if not api.check_connect():
    print("❌ Failed to connect. Check credentials.")
    exit()

print("✅ Connected!")

# === SWITCH TO DEMO ACCOUNT ===
api.change_balance("PRACTICE")  # "PRACTICE" = demo, "REAL" = live
balance = api.get_balance()
print(f"💰 Demo balance: ${balance}")

# === CHECK ASSET ===
open_assets = api.get_all_open_time()
if not open_assets["turbo"][ASSET]["open"]:
    print(f"❌ Asset {ASSET} is closed right now")
    exit()

# === EXECUTE TRADE ===
print(f"📈 Opening {DIRECTION.upper()} on {ASSET} | Stake: ${STAKE} | Duration: {DURATION}min")
status, order_id = api.buy(STAKE, ASSET, DIRECTION, DURATION)

if status:
    print(f"✅ Order executed. ID: {order_id}")
else:
    print("❌ Order failed")
    exit()

# === WAIT FOR RESULT ===
print("⏳ Waiting for result...")
result = api.check_win_v4(order_id)
profit = result[1]

if profit > 0:
    print(f"🟢 WIN! Profit: +${profit:.2f}")
elif profit == 0:
    print(f"⚪ DRAW")
else:
    print(f"🔴 LOSS! Loss: ${profit:.2f}")

# === FINAL BALANCE ===
final_balance = api.get_balance()
print(f"💰 Final balance: ${final_balance}")

Useful functions

Python
# Get historical candles (last 100 of 1 minute)
candles = api.get_candles(ASSET, 60, 100, time.time())

# Real-time quote
price = api.get_price_now(ASSET, "turbo")

# Check if asset is open
is_open = api.get_all_open_time()["turbo"][ASSET]["open"]

# Trade history
history = api.get_position_history("turbo-option")

# Close connection
api.close_connect()

Why Deriv is better

Honestly, for automation in 2026, Deriv is simply superior in every aspect:

  • Official documented API at api.deriv.com
  • Encourages automation — has its own no-code “Deriv Bot”
  • Zero ban risk for using the API
  • Stable WebSocket with OAuth 2.0
  • Official support when something breaks
  • Deriv MT5 + cTrader also available
  • 24/7 synthetic indices (Volatility 75, etc.)

🏆 Recommendation

If you want serious automation with Python, use the official Deriv API. See our complete Python + Deriv API tutorial. It’s more professional, safer, and officially supported.

🚀 For Python automation, we strongly recommend Deriv:

🟢 Open Deriv Free Account Open IQ Option (manual)
DM

Dan Machado

More at Start Here.

⚠️ Educational content. The iqoptionapi is unofficial and can cause account bans. Use on demo only. Contains affiliate links. Disclaimer.

Similar Posts