@@ -20,6 +20,24 @@ const api = require('forexrateapi');
2020api .setAPIKey (' SET_YOUR_API_KEY_HERE' );
2121await api .fetchLive (' USD' , [' AUD' , ' CAD' , ' GBP' , ' JPY' ]);
2222```
23+ ---
24+ ## Server Regions
25+
26+ ForexRateAPI provides two regional endpoints. Choose the one closest to your servers for optimal performance.
27+
28+ | Region | Base URL |
29+ | --------| ----------|
30+ | United States (default) | ` https://api.forexrateapi.com/v1 ` |
31+ | Europe | ` https://api-eu.forexrateapi.com/v1 ` |
32+
33+ ``` js
34+ api .setAPIKey (' SET_YOUR_API_KEY_HERE' );
35+
36+ // Default is US server
37+ // Switch to EU server:
38+ api .setServer (' eu' );
39+ ```
40+
2341---
2442## Documentation
2543
@@ -32,6 +50,15 @@ In order to use this library, you must first call this function with an API key.
3250``` js
3351api .setAPIKey (' SET_YOUR_API_KEY_HERE' );
3452```
53+ ---
54+ #### setServer(server)
55+
56+ - ` server ` <[ string] > Pass ` 'eu' ` to use the EU server (` api-eu.forexrateapi.com ` ), or ` 'us' ` for the US server. Defaults to US if not specified.
57+
58+ ``` js
59+ api .setServer (' eu' );
60+ ```
61+
3562---
3663#### fetchSymbols()
3764``` js
@@ -41,10 +68,11 @@ await api.fetchSymbols();
4168[ Link] ( https://forexrateapi.com/documentation#api_symbol )
4269
4370---
44- #### fetchLive(base, currencies)
71+ #### fetchLive(base, currencies, math )
4572
4673- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
4774- ` currencies ` <[ Array] <[ string] >> Optional. Pass in an array of currencies to return values for.
75+ - ` math ` <[ string] > Optional. Pass in a math expression to apply to the rates.
4876
4977``` js
5078await api .fetchLive (' USD' , [' AUD' , ' CAD' , ' GBP' , ' JPY' ]);
@@ -65,6 +93,22 @@ await api.fetchHistorical('2024-02-05', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
6593
6694[ Link] ( https://forexrateapi.com/documentation#api_historical )
6795
96+ ---
97+ #### hourly(base, currency, startDate, endDate, math, dateType)
98+
99+ - ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
100+ - ` currency ` <[ string] > Required. Specify currency you would like to get hourly rates for.
101+ - ` startDate ` <[ string] > Required. Specify the start date using the format ` YYYY-MM-DD ` .
102+ - ` endDate ` <[ string] > Required. Specify the end date using the format ` YYYY-MM-DD ` .
103+ - ` math ` <[ string] > Optional. Pass in a math expression to apply to the rates.
104+ - ` dateType ` <[ string] > Optional. Pass in a date type, overrides date parameters if passed in.
105+
106+ ``` js
107+ await api .hourly (' USD' , ' EUR' , ' 2024-02-05' , ' 2024-02-05' );
108+ ```
109+
110+ [ Link] ( https://forexrateapi.com/documentation#api_hourly )
111+
68112---
69113#### ohlc(base, currency, date, dateType)
70114
@@ -94,10 +138,10 @@ await api.convert('USD', 'EUR', 100, '2024-02-05');
94138[ Link] ( https://forexrateapi.com/documentation#api_convert )
95139
96140---
97- #### timeframe(start_date, end_date , base, currencies)
141+ #### timeframe(startDate, endDate , base, currencies)
98142
99- - ` start_date ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
100- - ` end_date ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
143+ - ` startDate ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
144+ - ` endDate ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
101145- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
102146- ` currencies ` <[ Array] <[ string] >> Optional. Pass in an array of currencies to return values for.
103147
@@ -108,12 +152,13 @@ await api.timeframe('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JP
108152[ Link] ( https://forexrateapi.com/documentation#api_timeframe )
109153
110154---
111- #### change(start_date, end_date , base, currencies)
155+ #### change(startDate, endDate , base, currencies, dateType )
112156
113- - ` start_date ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
114- - ` end_date ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
157+ - ` startDate ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
158+ - ` endDate ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
115159- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
116160- ` currencies ` <[ Array] <[ string] >> Optional. Pass in an array of currencies to return values for.
161+ - ` dateType ` <[ string] > Optional. Pass in a date type, overrides date parameters if passed in.
117162
118163``` js
119164await api .change (' 2024-02-05' , ' 2024-02-06' , ' USD' , [' AUD' , ' CAD' , ' GBP' , ' JPY' ]);
@@ -153,4 +198,4 @@ For support, get in touch using [this form](https://forexrateapi.com/contact).
153198
154199[ array ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array ' Array '
155200[ number ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type ' Number '
156- [ string ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type ' String '
201+ [ string ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type ' String '
0 commit comments