High-performance, production-ready Python client with Playwright login (get_token) & full trade lifecycle.
- ⚡ Async: blazing fast non-blocking WebSocket client
- 🔐 Playwright Login: secure token-based login with get_token()
- 📈 Market Data: assets, quotes, candles, payouts in real-time
- 🧾 Orders: open, monitor, and resolve trades with full lifecycle
- 🩺 Logging & Debugging: with built-in health-checks
- 🧪 Examples: quick-start usage and scripts
git clone https://github.com/A11ksa/API-Expert-Option
cd API-Expert-Option
python -m venv venv
source venv/bin/activate # or venv\Scripts\activate
pip install -U pip
pip install .
python -m playwright install chromiumimport asyncio
from api_expert_option import AsyncExpertOptionClient, OrderDirection, get_token
async def main():
# 1. Fetch token using playwright helper (get_token)
token_info = get_token(email="you@example.com", password="yourpassword")
demo_token = token_info.get("demo")
# 2. Connect
client = AsyncExpertOptionClient(token=demo_token, is_demo=True)
if not await client.connect():
print("Connection failed.")
return
# 3. Balance
balance = await client.get_balance()
print(f"Balance: {balance.balance} {balance.currency}")
# 4. Place Order
order = await client.place_order(
asset="EURUSD",
amount=5.0,
direction=OrderDirection.CALL,
duration=60
)
# 5. Await result
profit, status = await client.check_win(order.order_id)
print("Result:", status, "Profit:", profit)
# 6. Disconnect
await client.disconnect()
asyncio.run(main())+----------------------------+ +-----------------------------+
| Playwright Login | --> TOKEN → | sessions/session.json |
| (opens browser) | | demo/live tokens stored |
+----------------------------+ +-----------------------------+
|
v
+-----------------------------+ WebSocket (async) +--------------------------+
| AsyncExpertOptionClient |<----------------->| Expert Option Servers |
+-----------------------------+ +--------------------------+
await client.subscribe_candles("EURUSD", timeframe=60)
async for candle in client.iter_candles("EURUSD", 60):
print(candle)order = await client.place_order(
asset="EURUSD",
amount=10.0,
direction=OrderDirection.PUT,
duration=60
)
profit, status = await client.check_win(order.order_id)
print(status, profit)
get_token()will store tokens insessions/session.json
Manual override:
{
"live": "EXPERT_LIVE_TOKEN",
"demo": "EXPERT_DEMO_TOKEN"
}- ❌ Browser not installed? →
python -m playwright install chromium - 🔒 Login fails? → delete
sessions/session.json - 🌐 Region errors? → check IP or VPN
⚠️ SSL errors? → check your Python/OpenSSL env
- Fork + open a pull request
- Follow formatting (PEP8, type hints)
- Include tests when appropriate
MIT — see LICENSE