topstepx-api - v1.0.0
    Preparing search index...

    Class TopstepXClient

    Main client for interacting with the TopstepX trading API.

    Provides access to REST APIs for account management, order placement, position management, trade history, contract search, and historical data. Also provides real-time WebSocket connections for market data and account updates.

    import { TopstepXClient, OrderType, OrderSide } from 'topstepx-api';

    const client = new TopstepXClient({
    username: process.env.TOPSTEP_USERNAME,
    apiKey: process.env.TOPSTEP_API_KEY,
    });

    await client.connect();

    // Get accounts
    const accounts = await client.accounts.search({ onlyActiveAccounts: true });

    // Place an order
    await client.orders.place({
    accountId: accounts[0].id,
    contractId: 'CON.F.US.ENQ.M25',
    type: OrderType.Market,
    side: OrderSide.Buy,
    size: 1,
    });

    // Subscribe to real-time quotes
    client.marketHub.on('quote', ({ contractId, data }) => {
    console.log('Quote:', data);
    });
    await client.marketHub.subscribe('CON.F.US.ENQ.M25');

    await client.disconnect();

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    accounts: AccountApi

    Account management API

    contracts: ContractApi

    Contract/symbol search API

    history: HistoryApi

    Historical bars/candles API

    marketHub: MarketHub

    Real-time market data hub (quotes, trades, depth)

    orders: OrderApi

    Order management API (place, cancel, modify, search)

    positions: PositionApi

    Position management API (search, close)

    trades: TradeApi

    Trade history API

    userHub: UserHub

    Real-time account data hub (orders, positions, trades)

    Accessors

    • get isConnected(): boolean

      Check if client is connected.

      Returns boolean

    Methods

    • Connect to the TopstepX API. Authenticates and establishes WebSocket connections.

      Returns Promise<void>

    • Disconnect from all services.

      Returns Promise<void>

    • Get the current auth token (for advanced use cases).

      Returns Promise<string>