Build algo trading bots
Automate trading strategies on real or demo accounts. Open and close positions, manage portfolios, and access live PnL — all via REST.
Why eToro?
- Real + Demo Trading APIs with identical endpoints — build once, deploy to either
- WebSocket streaming for real-time price data and market events
- Production-grade sandbox: the Demo API mirrors real behavior exactly
- Full portfolio management: positions, orders, trade history, PnL
- Rate limits designed for automated strategies, not just manual use
How it works
Your Strategy
eToro REST API
Order Execution
Market
Code example
algo_strategy.py
import requests, uuid
BASE = "https://public-api.etoro.com/api/v1"
HEADERS = {
"x-api-key": "YOUR_PUBLIC_API_KEY",
"x-user-key": "YOUR_USER_KEY",
"x-request-id": str(uuid.uuid4()),
}
# Search for an instrument
instruments = requests.get(
f"{BASE}/market-data/instruments",
headers=HEADERS,
params={"search": "TSLA"}
).json()
instrument_id = instruments["data"][0]["instrumentId"]
# Open a BUY position on Demo
position = requests.post(
f"{BASE}/demo-trading/positions",
headers=HEADERS,
json={
"instrumentId": instrument_id,
"amount": 5000,
"direction": "BUY",
}
).json()
print(f"Opened position: {position['data']['positionId']}")
# Check portfolio
portfolio = requests.get(
f"{BASE}/demo-trading/portfolio",
headers=HEADERS,
).json()
for pos in portfolio["data"]["positions"]:
print(f"{pos['instrumentName']}: {pos['pnl']}")Relevant APIs
Trading (Real)11
Trading (Demo)10
Market Data8
WebSocket∞