https://github.com/krybc/xapi-js-wrapper
JavaScript xApi wrapper for nodeJS environment
https://github.com/krybc/xapi-js-wrapper
Last synced: 24 days ago
JSON representation
JavaScript xApi wrapper for nodeJS environment
- Host: GitHub
- URL: https://github.com/krybc/xapi-js-wrapper
- Owner: krybc
- Created: 2019-06-11T22:00:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-11T22:28:12.000Z (over 2 years ago)
- Last Synced: 2025-03-18T04:01:41.434Z (about 1 month ago)
- Language: TypeScript
- Size: 1.57 MB
- Stars: 2
- Watchers: 0
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xAPI JS wrapper
[](https://travis-ci.org/krybc/xapi-js-wrapper)
[](https://coveralls.io/github/krybc/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](http://developers.xstore.pro/documentation/current)
[xStation website](https://www.xtb.com/en/trading-services/trading-platforms/xstation)## Requirements
* NodeJS >= 12## Version xapi-js-wrapper vs xApi version
| xapi-js-wrapper | xAPI |
|:--|:--|
| 2.5.0 | 2.5.0.* |## Installation
```bash
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
```js
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`.
```js
import {Servers, StreamingApiConnector} from '@krybc/xapi-js-wrapper';const server = Servers.get('xtb', 'demo');
new StreamingApiConnector(server).connect().then(streamConn => {
});
```### Run streaming commands
#### GetCandles
```js
streamConn.subscribeCandles('EURUSD').subscribe((result: StreamingCandleResponse) => {
});
```### Login
```js
const result = conn.executeCommand('username', 'password').then(result => {
const sessionId = result.streamSessionId;
});
```## Test
```bash
npm run test
```