2.5.0 • Published 4 years ago

@krybc/xapi-js-wrapper v2.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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-wrapperxAPI
2.5.02.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