xtb-api-unofficial - v0.1.0
    Preparing search index...

    Interface CoreAPICommand

    CoreAPI command payload sent via WebSocket.

    Wraps all WebSocket commands in the standard CoreAPI format used by XTB. Each command includes an endpoint and account information, plus the specific command payload (subscription, trade, auth, etc.).

    // Subscribe to tick data
    const command: CoreAPICommand = {
    CoreAPI: {
    endpoint: 'meta1',
    accountId: 'meta1_12345678',
    getAndSubscribeElement: {
    eid: 2, // TICKS
    keys: ['9_CIG.PL_6']
    }
    }
    };
    interface CoreAPICommand {
        CoreAPI: {
            accountId?: string;
            endpoint: string;
            getAndSubscribeElement?: { eid: number; keys?: string[] };
            logonWithServiceTicket?: { serviceTicket: string };
            ping?: Record<string, never>;
            registerClientInfo?: { clientInfo: ClientInfo };
            subscribeElement?: { eid: number; keys?: string[] };
            tradeTransaction?: { newMarketOrder: INewMarketOrderEvent };
            unsubscribeElement?: { eid: number; keys?: string[] };
            [key: string]: unknown;
        };
    }
    Index

    Properties

    Properties

    CoreAPI: {
        accountId?: string;
        endpoint: string;
        getAndSubscribeElement?: { eid: number; keys?: string[] };
        logonWithServiceTicket?: { serviceTicket: string };
        ping?: Record<string, never>;
        registerClientInfo?: { clientInfo: ClientInfo };
        subscribeElement?: { eid: number; keys?: string[] };
        tradeTransaction?: { newMarketOrder: INewMarketOrderEvent };
        unsubscribeElement?: { eid: number; keys?: string[] };
        [key: string]: unknown;
    }

    Type Declaration

    • [key: string]: unknown

      Allow additional command types

    • OptionalaccountId?: string

      Account ID in format 'meta1_{accountNumber}'

    • endpoint: string

      Server endpoint (usually 'meta1')

    • OptionalgetAndSubscribeElement?: { eid: number; keys?: string[] }

      Get current data and subscribe to updates

    • OptionallogonWithServiceTicket?: { serviceTicket: string }

      Login with service ticket - second step in auth flow

    • Optionalping?: Record<string, never>

      Ping command for latency testing

    • OptionalregisterClientInfo?: { clientInfo: ClientInfo }

      Register client info - first step in auth flow

    • OptionalsubscribeElement?: { eid: number; keys?: string[] }

      Subscribe to an element ID

    • OptionaltradeTransaction?: { newMarketOrder: INewMarketOrderEvent }

      Execute a trade transaction

    • OptionalunsubscribeElement?: { eid: number; keys?: string[] }

      Unsubscribe from an element ID