6.0.2 • Published 4 years ago

forex-quotes v6.0.2

Weekly downloads
73
License
MIT
Repository
github
Last release
4 years ago

javascript-forex-quotes

javascript-forex-quotes is a Javascript Library for fetching realtime forex quotes.

1Forge Data

Table of Contents

Requirements

Installation

npm install forex-quotes --save

Usage

Importing the client

// With require
const ForgeClient = require("forex-quotes").default;

// With es6 or TypeScript
import ForgeClient from 'forex-quotes';

Using WebSocket

let client = new ForgeClient('YOUR_API_KEY');

// Handle incoming price updates from the server
client.onUpdate((symbol, data) => {
    console.log(symbol, data);
});

// Handle non-price update messages
client.onMessage((message) => {
    console.log(message);
});

// Handle disconnection from the server
client.onDisconnect(() => {
    console.log("Disconnected from server");
});

// Handle successful connection
client.onConnect(() => {

    // Subscribe to a single currency pair
    client.subscribeTo('EUR/USD');

    // Subscribe to an array of currency pairs
    client.subscribeTo([
        'GBP/JPY',
        'AUD/CAD',
        'EUR/CHF',
    ]);

    // Subscribe to all currency pairs
    client.subscribeToAll();

    // Unsubscribe from a single currency pair
    client.unsubscribeFrom('EUR/USD');

    // Unsubscribe from an array of currency pairs
    client.unsubscribeFrom([
        'GBP/JPY',
        'AUD/CAD',
        'EUR/CHF'
    ]);

    // Unsubscribe from all currency pairs
    client.unsubscribeFromAll();

    // Disconnect from the server
    client.disconnect();
});

client.connect();

Using RESTful API

// You can get an API key at 1forge.com
let client = new ForgeClient('YOUR_API_KEY');

// Get the list of available symbols
client.getSymbols().then(response => {
    console.log(response);
});

// Get quotes for specified symbols:
client.getQuotes(['EUR/USD', 'GBP/JPY', 'AUD/USD']).then(response => {
    console.log(response);
});

// Convert from one currency to another:
client.convert('EUR', 'USD', 100).then(response => {
    console.log(response);
});

// Check if the market is open:
client.getMarketStatus().then(response => {
    console.log(response);
});

// Check your usage / quota limit:
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.

6.0.2

4 years ago

6.0.1

4 years ago

6.0.0

4 years ago

5.0.5

4 years ago

5.0.4

5 years ago

5.0.3

5 years ago

5.0.2

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

4.0.1

5 years ago

4.0.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago