Skip to content

Commit 8e89f3b

Browse files
committed
v1.1.2
1 parent 58db8fe commit 8e89f3b

5 files changed

Lines changed: 54 additions & 3 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 ForexRateAPI
3+
Copyright (c) 2025 ForexRateAPI
44

55
Permission is hereby granted, free of charge, to any person obtaining
66
a copy of this software and associated documentation files (the

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@ await api.fetchHistorical('2024-02-05', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
6565

6666
[Link](https://forexrateapi.com/documentation#api_historical)
6767

68+
---
69+
#### ohlc(base, currency, date, dateType)
70+
71+
- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
72+
- `currency` <[string]> Required. Specify currency you would like to get OHLC for.
73+
- `date` <[string]> Required. 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.
74+
- `dateType` <[string]> Optional. Pass in a date type, overrides date parameter if passed in.
75+
76+
```js
77+
await api.ohlc('USD', 'EUR', '2024-02-05', null);
78+
```
79+
80+
[Link](https://forexrateapi.com/documentation#api_ohlc)
81+
6882
---
6983
#### convert(from, to, amount, date)
7084

@@ -107,6 +121,15 @@ await api.change('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']
107121

108122
[Link](https://forexrateapi.com/documentation#api_change)
109123

124+
---
125+
#### usage()
126+
127+
```js
128+
await api.usage();
129+
```
130+
131+
[Link](https://forexrateapi.com/documentation#api_usage)
132+
110133
---
111134
**[Official documentation](https://forexrateapi.com/documentation)**
112135

example/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const apiKey = 'REPLACE_ME';
1616
result = await api.fetchHistorical('2024-02-05', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
1717
console.log(result.data);
1818

19+
result = await api.ohlc('USD', 'EUR', '2024-02-05', null);
20+
console.log(result.data);
21+
1922
result = await api.convert('USD', 'EUR', 100, '2024-02-05');
2023
console.log(result.data);
2124

@@ -24,4 +27,7 @@ const apiKey = 'REPLACE_ME';
2427

2528
result = await api.change('2024-02-05', '2024-02-06', 'USD', ['AUD', 'CAD', 'GBP', 'JPY']);
2629
console.log(result.data);
30+
31+
result = await api.usage();
32+
console.log(result.data);
2733
})();

index.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,19 @@
4747
});
4848
};
4949

50+
exports.ohlc = function(base, currency, date, dateType) {
51+
return axios({
52+
url: 'https://api.forexrateapi.com/v1/ohlc',
53+
params: removeEmpty({
54+
api_key: this.apiKey,
55+
base: base,
56+
currency: currency,
57+
date: date,
58+
date_type: dateType,
59+
}),
60+
});
61+
}
62+
5063
exports.convert = function(from, to, amount, date) {
5164
return axios({
5265
url: 'https://api.forexrateapi.com/v1/convert',
@@ -85,4 +98,13 @@
8598
}),
8699
});
87100
}
101+
102+
exports.usage = function(base, currency) {
103+
return axios({
104+
url: 'https://api.forexrateapi.com/v1/usage',
105+
params: removeEmpty({
106+
api_key: this.apiKey,
107+
}),
108+
});
109+
}
88110
})();

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "forexrateapi",
3-
"version": "1.0.2",
3+
"version": "1.1.2",
44
"description": "Official Node.js Library for ForexRateAPI",
55
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"author": "ForexRateAPI",
10-
"license": "GNU GPLv3",
10+
"license": "MIT",
1111
"dependencies": {
1212
"axios": "^1.6.7"
1313
},

0 commit comments

Comments
 (0)