1.0.3 • Published 6 months ago

rate-exchange-lib v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Exchange Rate Library

A simple Node.js library to fetch exchange rates from Google Finance.

Installation

Install the package using npm:

npm install rate-exchange-lib

Usage

Import the library and use the getExchangeRate function:

const { getExchangeRate } = require('rate-exchange-lib');

(async () => {
    try {
        const result = await getExchangeRate('USD', 'EUR');
        console.log(result);
    } catch (error) {
        console.error(error.message);
    }
})();

API

getExchangeRate(baseCurrency, targetCurrency)

Fetches the exchange rate between two currencies.

Parameters

  • baseCurrency (string) - The base currency (default: EUR).
  • targetCurrency (string) - The target currency (default: TRY).

Returns

A promise that resolves to an object:

{
  "base_currency": "USD",
  "target_currency": "EUR",
  "exchange_rate": "1.10"
}

Error Handling

If the exchange rate cannot be fetched, an error will be thrown.

License

This project is licensed under the MIT License.

1.0.3

6 months ago

1.0.2

6 months ago

1.0.0

6 months ago