1.0.1 • Published 4 years ago
xapi-js-wrapper v1.0.1
xAPI JS wrapper
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 >= 8
Installation
npm i --save 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 '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 'xapi-js-wrapper';
const server = Servers.get('xtb', 'demo');
new StreamingApiConnector(server).connect().then(streamConn => {
});
Login
const credentials = new Credentials(process.env.XAPI_LOGIN, process.env.XAPI_PASSWORD);
const result = conn.executeCommand(new LoginCommand(credentials)).then(result => {
const sessionId = result.streamSessionId;
});
Test
You must first enter the login and password variables in package.json Then you need to enter command:
npm run test
1.0.1
4 years ago