Quotex API with Python — Connect, Read Candles and Automate
Want to connect to Quotex from Python to read prices and place CALL/PUT trades automatically? This page explains how the Quotex API works, shows a minimal Python example, and gives you a free open-source bot that already wraps it all — 13 strategies and a visual dashboard, no coding required.
🤖 Get the free Quotex bot (API ready)
Open-source Python bot using the Quotex API. Edit it by chatting with ChatGPT/Claude — no coding. Free, no spam.
Is there an official Quotex API?
Quotex does not offer an official public API. The community connects to it through the same WebSocket the web platform uses, via open-source Python libraries (the best known is pyquotex). It works, but because it is unofficial it can change without notice, and you should use it on a demo account first.
What you can do with the Quotex API in Python
Connect with Python — minimal example
Using the pyquotex library (included in our bot), a minimal connection looks like this:
# pip install pyquotex (or use the bot, it is bundled)
from pyquotex.stable_api import Quotex
import asyncio
async def main():
client = Quotex(email="you@email.com", password="yourpass")
client.account_is_demo = 1 # always start on demo
ok, reason = await client.connect()
candles = await client.get_candles("EURUSD_otc", 60, 0)
status, order = await client.buy(1, "EURUSD_otc", "call", 60)
await client.close()
asyncio.run(main())That is the raw API. Turning it into a profitable, safe strategy (signals, risk control, payout filter, stop loss) is the hard part — which is exactly what the bot below already does.
Skip the setup: get the ready-made bot
Instead of wiring the API by hand, download IaTraderPro Bot: it already uses the Quotex API and adds 9 ready strategies (EMA, RSI, Bollinger, MACD, ADX…), a visual Streamlit dashboard, payout filter, daily stop loss/win and configurable martingale. Everything is open source, so you can read and change the code.
Modify it with AI — no coding
Paste bot.py into ChatGPT or Claude, describe the strategy you want in plain English, and the AI returns working code. You paste it back, test on demo, done. That is the real advantage of an open bot over a closed “magic” one.
FAQ
Is it official? No — it uses the community Quotex WebSocket API. Use demo first.
Can my account get banned? Automation carries risk on real accounts; test on demo and read the broker terms.
Is it free? Yes — the bot is free and open source.
Does it work for IQ Option too? Yes, the bot has an IQ Option version as well.
Full example: an RSI bot in 30 lines
The minimal example above only connects and places one order. Below is a genuinely functional bot: it reads the last 100 candles, computes RSI and opens a CALL when oversold (RSI < 30) or a PUT when overbought (RSI > 70), repeating every minute:
# Full example: simple RSI strategy (educational — run on DEMO)
import asyncio
from pyquotex.stable_api import Quotex
ASSET, AMOUNT, EXP = "EURUSD_otc", 1, 60
def rsi(closes, period=14):
gains = [max(closes[i+1]-closes[i], 0) for i in range(len(closes)-1)]
losses = [max(closes[i]-closes[i+1], 0) for i in range(len(closes)-1)]
ag = sum(gains[-period:]) / period
al = sum(losses[-period:]) / period or 1e-9
return 100 - 100 / (1 + ag / al)
async def main():
client = Quotex(email="you@email.com", password="yourpass")
client.account_is_demo = 1 # DEMO first, always
ok, _ = await client.connect()
while ok:
candles = await client.get_candles(ASSET, 60, 100)
closes = [c["close"] for c in candles]
r = rsi(closes)
if r < 30: # oversold → CALL
await client.buy(AMOUNT, ASSET, "call", EXP)
elif r > 70: # overbought → PUT
await client.buy(AMOUNT, ASSET, "put", EXP)
await asyncio.sleep(60)
asyncio.run(main())That is the skeleton of every Quotex bot: read candles → compute indicator → decide → place order. What separates this example from a bot you can run daily is the protection layer: daily stop loss/win, minimum payout filter, losing-streak limit and trade logging — everything the IaTraderPro Bot ships with out of the box.
How the connection works under the hood (WebSocket)
Understanding the mechanism helps you diagnose problems. Quotex's web platform talks to its servers over a WebSocket channel (wss://) — the same one that streams the live chart to your browser. The Python libraries do exactly what the browser does:
- Login: they authenticate with e-mail/password and store the session cookies (which is why sessions expire and you sometimes need to reconnect).
- Data subscription: they request the tick/candle stream for the chosen asset and receive continuous JSON with price, time and volume.
- Orders: placing a CALL/PUT means sending a message on the same channel with asset, amount, direction and expiry; the broker replies with the order ID and later the result.
- Keepalive: a periodic ping keeps the channel open — unstable connections kill bots, which is why a stable network matters more than CPU.
This is also why unofficial APIs break from time to time: whenever Quotex changes its internal protocol, the libraries must be updated. Prefer actively maintained GitHub projects and avoid "frozen" copies from courses and groups.
Common connection errors (and fixes)
“Connection failed” or timeout — usually an expired session. Delete the library's session folder and reconnect; confirm your e-mail and password by logging in manually in the browser.
SSL/certificate error — update Python to 3.12+ and the certifi package (pip install -U certifi). Corporate proxies may block the WebSocket.
Account with 2FA/verification — on first connection Quotex may e-mail you a PIN code. Current libraries prompt for it in the terminal; type it once and the session is saved.
“Asset is closed” — the asset is outside market hours. Use _otc pairs on weekends and check the payout before trading (below 80% rarely pays off).
Order not executing — check the balance of the selected account (demo vs real) and the minimum order amount ($1).
Risk-management best practices for bots
- Demo first, always: run any change for at least a few days on demo before considering a real account.
- Daily stops: set a daily stop loss and stop win (e.g. −5% / +10% of the bankroll) — the bot stops by itself and you don't give profits back.
- Small stakes: 1–2% of the bankroll per trade; martingale multiplies wins and losses.
- Payout filter: only trade assets paying 80%+ — low payout destroys any strategy long term.
- Logging: follow the dashboard statistics to learn which strategy works at which hours.
⚠️ Binary options involve high risk and can result in total loss. This content is educational and not investment advice. No bot guarantees profit. Always test on a demo account first.