javascript-forex-quotes
javascript-forex-quotes is a Javascript Library for fetching realtime forex quotes.
Table of Contents
Requirements
Installation
npm install forex-quotes --save
Usage
Importing the client
const ForgeClient = require("forex-quotes").default;
import ForgeClient from 'forex-quotes';
Using WebSocket
let client = new ForgeClient('YOUR_API_KEY');
client.onUpdate((symbol, data) => {
console.log(symbol, data);
});
client.onMessage((message) => {
console.log(message);
});
client.onDisconnect(() => {
console.log("Disconnected from server");
});
client.onConnect(() => {
client.subscribeTo('EUR/USD');
client.subscribeTo([
'GBP/JPY',
'AUD/CAD',
'EUR/CHF',
]);
client.subscribeToAll();
client.unsubscribeFrom('EUR/USD');
client.unsubscribeFrom([
'GBP/JPY',
'AUD/CAD',
'EUR/CHF'
]);
client.unsubscribeFromAll();
client.disconnect();
});
client.connect();
Using RESTful API
let client = new ForgeClient('YOUR_API_KEY');
client.getSymbols().then(response => {
console.log(response);
});
client.getQuotes(['EUR/USD', 'GBP/JPY', 'AUD/USD']).then(response => {
console.log(response);
});
client.convert('EUR', 'USD', 100).then(response => {
console.log(response);
});
client.getMarketStatus().then(response => {
console.log(response);
});
client.getQuota().then(response => {
console.log(response);
});
Contributing
Thank you for considering contributing! Any issues, bug fixes, suggestions, improvements or help in any other way is always appreciated. Please feel free to open an issue or create a pull request.
Support and Contact
Please contact me at contact@1forge.com if you have any questions or requests.
License and Terms
This library is provided without warranty under the MIT license.