Skip to content

Latest commit

 

History

History
81 lines (50 loc) · 1.96 KB

File metadata and controls

81 lines (50 loc) · 1.96 KB

xAPI JS wrapper

Build Status Coverage Status

xAPI wrapper for nodeJS environment based on websocket and written in Typescript.
xAPI is a endpoint for xStation forex trading software distributed by one of the biggest polish trading brokers - XTB.

xAPI documentation
xStation website

Requirements

  • NodeJS >= 12

Version xapi-js-wrapper vs xApi version

xapi-js-wrapper xAPI
2.5.0 2.5.0.*

Installation

npm i --save @krybc/xapi-js-wrapper

Usage

Every sync api command class and streaming command class has equal one response class that be returned as Promise (sync response) as Observable (streaming response), when response has been received.

Connect to sync api

import {Servers, SyncApiConnector} from '@krybc/xapi-js-wrapper';

const server = Servers.get('xtb', 'demo');

new SyncApiConnector(server).connect().then(conn => {
  
});

Connect to streaming api

Streaming API commands is available only if you're logged in, because all streaming commands required streamSessionId value, that will be returned by sync LoginCommand.

import {Servers, StreamingApiConnector} from '@krybc/xapi-js-wrapper';

const server = Servers.get('xtb', 'demo');

new StreamingApiConnector(server).connect().then(streamConn => {
  
});

Run streaming commands

GetCandles

streamConn.subscribeCandles('EURUSD').subscribe((result: StreamingCandleResponse) => {
  
});

Login

const result = conn.executeCommand('username', 'password').then(result => {
  const sessionId = result.streamSessionId;
});

Test

npm run test