Skip to content

Get start

document version

last update:2020/10/19

Version 7.5

get_top_asset

Version 7.3 FIX ALL CHECK_WIN problem

Version 7.2.2

websocket stable,check win fix

Version 7.2.1

more hight speed get_balance_v2()

Version 7.2

  • get_active_exposure()

Version:7.1.0

  • now check_win support check all(binary,digital,forex,....)

Version:7.0.0

  • Perfect 2fa

Version:6.9.5

  • this icon 🔒 mean the api support thread safe
  • thread safe buy()
  • thread safe buy_multi()

Version:6.9.4

  • support multi account
from iqoptionapi.stable_api import IQ_Option 
account1=IQ_Option("email1","password1")
account1.connect()
 
account2=IQ_Option("email2","password2")
account2.connect()
print(account1.get_balance_id())
print(account2.get_balance_id())
  • by pass 2FA

Version:6.9.2

  • fix buy_digital_spot

Version:6.9.1

  • fix update_ACTIVES_OPCODE and add active code

Version:6.9

  • fix heartbeat, protect iqoption close connect

Version:6.8.9

fix some ssl problem

Version:6.8.8

more stable

fix login and auto logout

fix check_connect

Version:6.8.7

add get_leader_board

install iqoptionapi

download the source code and run this

python setup.py install

little sample

import time
from iqoptionapi.stable_api import IQ_Option
I_want_money=IQ_Option("email","password")
I_want_money.connect()#connect to iqoption
goal="EURUSD"
print("get candles")
print(I_want_money.get_candles(goal,60,111,time.time()))

Import

from iqoptionapi.stable_api import IQ_Option

Login

I_want_money.connect() will return (check,reason)

if connect sucess return True,None

if connect fail return False,reason

from iqoptionapi.stable_api import IQ_Option
import logging

logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
I_want_money=IQ_Option("email","password")
check, reason=I_want_money.connect()#connect to iqoption
print(check, reason)

Login by pass 2FA

from iqoptionapi.stable_api import IQ_Option 
import json
account=IQ_Option("email","password")
_,r=account.connect()
if r !="":
    r=json.loads(r)
    if "method" in r:
        r=account.TWO_FA(method="sms",token=r["token"])
        code=input("Please input SMS CODE\n")
        r=account.TWO_FA(code=code,token=r["token"])
        if r["code"]=="success":
            account.setting_2FA_TOKEN(r["token"])
            check,_=account.connect()
            if check:
                print("Login OK!!")

Debug mode on

import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')

Connect&Check connect

some time connect will close so this way can check connect and reconnect

try close your network and restart network in this sample

from iqoptionapi.stable_api import IQ_Option
error_password="""{"code":"invalid_credentials","message":"You entered the wrong credentials. Please check that the login/password is correct."}"""
iqoption = IQ_Option("email", "password")
check,reason=iqoption.connect()
if check:
    print("Start your robot")
    #if see this you can close network for test
    while True: 
        if iqoption.check_connect()==False:#detect the websocket is close
            print("try reconnect")
            check,reason=iqoption.connect()         
            if check:
                print("Reconnect successfully")
            else:
                if reason==error_password:
                    print("Error Password")
                else:
                    print("No Network")
        
else:
    
    if reason=="[Errno -2] Name or service not known":
        print("No Network")
    elif reason==error_password:
        print("Error Password")

set_session

Default User-Agent is "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"

from iqoptionapi.stable_api import IQ_Option
import logging
logging.basicConfig(level=logging.DEBUG,format='%(asctime)s %(message)s')
 
I_want_money=IQ_Option("email","password")

#Default is "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36"

header={"User-Agent":r"Mozilla/5.0 (X11; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0"}
cookie={"I_want_money":"GOOD"}

I_want_money.set_session(header,cookie)

I_want_money.connect()#connect to iqoption

Check version

from iqoptionapi.stable_api import IQ_Option
print(IQ_Option.__version__)

Check connect

return True/False

print(I_want_money.check_connect())

Reconnect

I_want_money.connect()

time

get_server_timestamp the get_server_timestamp time is sync with iqoption

I_want_money.get_server_timestamp()