Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/forexrateapi/forexrateapi-nodejs
Currency exchange rates library | Official Node.js API wrapper for ForexRateAPI
https://github.com/forexrateapi/forexrateapi-nodejs
currency currency-converter foreign-exchange-rates foreignexchange forex nodejs price-tracker
Last synced: about 2 months ago
JSON representation
Currency exchange rates library | Official Node.js API wrapper for ForexRateAPI
- Host: GitHub
- URL: https://github.com/forexrateapi/forexrateapi-nodejs
- Owner: forexrateapi
- License: mit
- Created: 2023-01-19T17:24:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-22T01:07:34.000Z (11 months ago)
- Last Synced: 2024-11-07T19:46:25.221Z (about 2 months ago)
- Topics: currency, currency-converter, foreign-exchange-rates, foreignexchange, forex, nodejs, price-tracker
- Language: JavaScript
- Homepage: https://forexrateapi.com/
- Size: 2.93 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ForexRateAPI
forexrateapi is the official Node.js wrapper for ForexRateAPI.com. This allows you to quickly integrate our foreign exchange rate API and currency conversion API into your application. Check https://forexrateapi.com documentation for more information.
## Installation
#### NPM
```
$ npm i forexrateapi
```
---
## Usage```js
const api = require('forexrateapi');api.setAPIKey('SET_YOUR_API_KEY_HERE');
await api.fetchLive('USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```
---
## Documentation#### setAPIKey(apiKey)
- `apiKey` <[string]> API Key
In order to use this library, you must first call this function with an API key.
```js
api.setAPIKey('SET_YOUR_API_KEY_HERE');
```
---
#### fetchSymbols()
```js
await api.fetchSymbols();
```[Link](https://forexrateapi.com/documentation#api_symbol)
---
#### fetchLive(base, currencies)- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for.```js
await api.fetchLive('USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```[Link](https://forexrateapi.com/documentation#api_realtime)
---
#### fetchHistorical(date, base, currencies)- `date` <[string]> Required. Pass in a string with format `YYYY-MM-DD`
- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for.```js
await api.fetchHistorical('2024-02-05', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```[Link](https://forexrateapi.com/documentation#api_historical)
---
#### convert(from, to, amount, date)- `from` <[string]> Optional. Pass in a base currency, defaults to USD.
- `to` <[string]> Required. Specify currency you would like to convert to.
- `amount` <[number]> Required. The amount to convert.
- `date` <[string]> Optional. Specify date to use historical midpoint value for conversion with format `YYYY-MM-DD`. Otherwise, it will use live exchange rate date if value not passed in.```js
await api.convert('USD', 'EUR', 100, '2024-02-05');
```[Link](https://forexrateapi.com/documentation#api_convert)
---
#### timeframe(start_date, end_date, base, currencies)- `start_date` <[string]> Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`.
- `end_date` <[string]> Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`.
- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for.```js
await api.timeframe('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```[Link](https://forexrateapi.com/documentation#api_timeframe)
---
#### change(start_date, end_date, base, currencies)- `start_date` <[string]> Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`.
- `end_date` <[string]> Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`.
- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for.```js
await api.change('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
```[Link](https://forexrateapi.com/documentation#api_change)
---
**[Official documentation](https://forexrateapi.com/documentation)**---
## FAQ- How do I get an API Key?
Free API Keys are available [here](https://forexrateapi.com).
- I want more information
Checkout our FAQs [here](https://forexrateapi.com/faq).
## Support
For support, get in touch using [this form](https://forexrateapi.com/contact).
[array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array 'Array'
[number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type 'Number'
[string]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type 'String'