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
- NodeJS >= 12
xapi-js-wrapper | xAPI |
---|---|
2.5.0 | 2.5.0.* |
npm i --save @krybc/xapi-js-wrapper
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.
import {Servers, SyncApiConnector} from '@krybc/xapi-js-wrapper';
const server = Servers.get('xtb', 'demo');
new SyncApiConnector(server).connect().then(conn => {
});
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 => {
});
streamConn.subscribeCandles('EURUSD').subscribe((result: StreamingCandleResponse) => {
});
const result = conn.executeCommand('username', 'password').then(result => {
const sessionId = result.streamSessionId;
});
npm run test