|
| 1 | +# ForexRateAPI |
| 2 | + |
| 3 | +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. |
| 4 | + |
| 5 | +## Installation |
| 6 | +Add to Gemfile. |
| 7 | + |
| 8 | +``` |
| 9 | +gem 'forexrateapi' |
| 10 | +``` |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +```ruby |
| 15 | + |
| 16 | +api_key = 'SET_YOUR_API_KEY_HERE' |
| 17 | +client = ForexRateAPI::Client.new(api_key: api_key) |
| 18 | +``` |
| 19 | +--- |
| 20 | +## Documentation |
| 21 | + |
| 22 | +#### fetchSymbols() |
| 23 | +```ruby |
| 24 | +client.fetchSymbols() |
| 25 | +``` |
| 26 | + |
| 27 | +[Link](https://forexrateapi.com/documentation#api_symbol) |
| 28 | + |
| 29 | +--- |
| 30 | +#### fetchLive(base, currencies) |
| 31 | + |
| 32 | +- `base` <[string]> Optional. Pass in a base currency, defaults to USD. |
| 33 | +- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for. |
| 34 | + |
| 35 | +```ruby |
| 36 | +client.fetchLive(base='USD', currencies=['AUD', 'CAD', 'GBP', 'JPY']) |
| 37 | +``` |
| 38 | + |
| 39 | +[Link](https://forexrateapi.com/documentation#api_realtime) |
| 40 | + |
| 41 | +--- |
| 42 | +#### fetchHistorical(date, base, currencies) |
| 43 | + |
| 44 | +- `date` <[string]> Required. Pass in a string with format `YYYY-MM-DD` |
| 45 | +- `base` <[string]> Optional. Pass in a base currency, defaults to USD. |
| 46 | +- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for. |
| 47 | + |
| 48 | +```ruby |
| 49 | +client.fetchHistorical(date='2021-04-05', base='USD', currencies=['AUD', 'CAD', 'GBP', 'JPY']) |
| 50 | +``` |
| 51 | + |
| 52 | +[Link](https://forexrateapi.com/documentation#api_historical) |
| 53 | + |
| 54 | +--- |
| 55 | +#### convert(from_currency, to_currency, amount, date) |
| 56 | + |
| 57 | +- `from_currency` <[string]> Optional. Pass in a base currency, defaults to USD. |
| 58 | +- `to_currency` <[string]> Required. Specify currency you would like to convert to. |
| 59 | +- `amount` <[number]> Required. The amount to convert. |
| 60 | +- `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. |
| 61 | + |
| 62 | +```ruby |
| 63 | +client.convert(from_currency='USD', to_currency='EUR', amount=100, date='2021-04-05') |
| 64 | +``` |
| 65 | + |
| 66 | +[Link](https://forexrateapi.com/documentation#api_convert) |
| 67 | + |
| 68 | +--- |
| 69 | +#### timeframe(start_date, end_date, base, currencies) |
| 70 | + |
| 71 | +- `start_date` <[string]> Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`. |
| 72 | +- `end_date` <[string]> Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`. |
| 73 | +- `base` <[string]> Optional. Pass in a base currency, defaults to USD. |
| 74 | +- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for. |
| 75 | + |
| 76 | +```ruby |
| 77 | +client.timeframe(start_date='2021-04-05', end_date='2021-04-06', base='USD', currencies=['AUD', 'CAD', 'GBP', 'JPY']) |
| 78 | +``` |
| 79 | + |
| 80 | +[Link](https://forexrateapi.com/documentation#api_timeframe) |
| 81 | + |
| 82 | +--- |
| 83 | +#### change(start_date, end_date, base, currencies) |
| 84 | + |
| 85 | +- `start_date` <[string]> Required. Specify the start date of your timeframe using the format `YYYY-MM-DD`. |
| 86 | +- `end_date` <[string]> Required. Specify the end date of your timeframe using the format `YYYY-MM-DD`. |
| 87 | +- `base` <[string]> Optional. Pass in a base currency, defaults to USD. |
| 88 | +- `currencies` <[Array]<[string]>> Optional. Pass in an array of currencies to return values for. |
| 89 | + |
| 90 | +```ruby |
| 91 | +client.change(start_date='2021-04-05', end_date='2021-04-06', base='USD', currencies=['AUD', 'CAD', 'GBP', 'JPY']) |
| 92 | +``` |
| 93 | + |
| 94 | +[Link](https://forexrateapi.com/documentation#api_change) |
| 95 | + |
| 96 | +--- |
| 97 | +**[Official documentation](https://forexrateapi.com/documentation)** |
| 98 | + |
| 99 | + |
| 100 | +--- |
| 101 | +## FAQ |
| 102 | + |
| 103 | +- How do I get an API Key? |
| 104 | + |
| 105 | + Free API Keys are available [here](https://forexrateapi.com). |
| 106 | + |
| 107 | +- I want more information |
| 108 | + |
| 109 | + Checkout our FAQs [here](https://forexrateapi.com/faq). |
| 110 | + |
| 111 | + |
| 112 | +## Support |
| 113 | + |
| 114 | +For support, get in touch using [this form](https://forexrateapi.com/contact). |
| 115 | + |
| 116 | + |
| 117 | +[Array]: https://www.geeksforgeeks.org/ruby-data-types/ 'Array' |
| 118 | +[number]: https://www.geeksforgeeks.org/ruby-data-types/ 'Number' |
| 119 | +[string]: https://apidock.com/ruby/String 'String' |
0 commit comments