🐍 Advanced Tutorial

Python + IQ Option API Unofficial β€” Honest Guide

By PrimeTraderAI Team Β· May 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

PrimeTraderAI Team

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