Create a new XTB client instance.
Client configuration
Get the underlying Browser client (only available in browser mode).
Useful for accessing browser-specific features and low-level page manipulation.
Browser client instance or null if in WebSocket mode
Get the underlying WebSocket client (only available in WebSocket mode).
Useful for accessing WebSocket-specific features like event listeners, raw protocol methods, and real-time subscriptions.
WebSocket client instance or null if in browser mode
Execute a BUY order for the specified symbol.
⚠️ WARNING: This executes real trades. Use demo accounts for testing.
Volume to buy (number of units)
Optionaloptions: TradeOptionsOptional trade parameters (stop loss, take profit, etc.)
Trade execution result
Disconnect from XTB.
Cleanly closes the connection and cleans up resources.
Get account balance and equity information.
Account balance with equity, free margin, and currency
Get all open positions.
Array of open positions with current P&L, stop loss, take profit, etc.
Get current quote (bid/ask prices) for a symbol.
Current quote with bid, ask, spread, and optional high/low/time
Search for financial instruments.
Searches across 11,888+ available instruments by name or description.
Search query (e.g., 'Apple', 'CIG', 'EUR/USD')
Array of matching instruments with symbol keys, IDs, and descriptions
Execute a SELL order for the specified symbol.
⚠️ WARNING: This executes real trades. Use demo accounts for testing.
Volume to sell (number of units)
Optionaloptions: TradeOptionsOptional trade parameters (stop loss, take profit, etc.)
Trade execution result
StaticbrowserCreate a browser mode client instance.
Chrome DevTools Protocol WebSocket URL (e.g., 'ws://127.0.0.1:9222')
Optionaloptions: Omit<BrowserClientConfig, "cdpUrl">Additional browser client options
New XTB client configured for browser mode
StaticwebsocketCreate a WebSocket mode client instance.
WebSocket configuration with authentication options
New XTB client configured for WebSocket mode
High-level XTB trading client. Provides a unified API over Browser automation and WebSocket modes.
⚠️ Warning: This is an unofficial library. Use at your own risk. Always test thoroughly on demo accounts before using with real money.
Features
Example: Browser Mode
Example: WebSocket Mode with Auth