Foreks SDK for web development. This SDK is used to connect to the Foreks websocket server and to use the Foreks API.
$ npm i foreks-sdk -s
import ForeksWebSDK from 'foreks-sdk/web-sdk';
import {
DefinitionLocale,
NewsSources,
NewsLocale
} from 'foreks-sdk/commons/enums';
import PubsubData from 'foreks-sdk/commons/type/PubsubData';
const sdk = new ForeksWebSDK(
'username', // username
'password', // password
'token', // if you have token (you can send undefined for username and password)
'company', // company
'foreks', // resource
'wss://', // wss address
'myapp' // your application name
);
// initialize foreks web sdk
await foreksWebSDK.initialize();
// connect to socket
await foreksWebSDK.connectToSocket();
// set fx definitions
await foreksWebSDK.definition.setDefinitionByDomain(
'FX',
DefinitionLocale.BIST
);
// get foreks news example
const newsData = await this.$foreksWebSDK.news.getNews(
NewsSources.FRKS,
10,
NewsLocale.TR
);
// socket subscribe example usdtry and eurtry ask and bid
foreksWebSDK.socket.subscribe(
['o10', 'o11'],
['a', 'b'],
(data: PubsubData) => {
console.log(data);
}
);
Documentation Web SDK
Example Web SDK Example