Skip to content

Commit 65db48a

Browse files
version 1.1.1
1 parent fcafc7e commit 65db48a

File tree

5 files changed

+45
-4
lines changed

5 files changed

+45
-4
lines changed

LICENSE.md

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) 2021 MetalpriceAPI
3+
Copyright (c) 2025 MetalpriceAPI
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: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ client.fetchHistorical(date='2021-04-05', base='USD', currencies=['XAU', 'XAG',
5151

5252
[Link](https://metalpriceapi.com/documentation#api_historical)
5353

54+
---
55+
#### fetchOHLC(base, currency, date, unit, dateType)
56+
57+
- `base` <[string]> Optional. Pass in a base currency, defaults to USD.
58+
- `currency` <[string]> Required. Specify currency you would like to get OHLC for.
59+
- `date` <[string]> Required. Specify date to get OHLC for specific date using format `YYYY-MM-DD`.
60+
- `unit` <[string]> Optional. Pass in a unit, defaults to troy_oz.
61+
- `dateType` <[string]> Optional. Pass in a date type, overrides date parameter if passed in.
62+
63+
```ruby
64+
client.fetchOHLC(base='USD', currency='XAU', date='2024-02-05', unit='troy_oz', dateType=nil)
65+
```
66+
67+
[Link](https://metalpriceapi.com/documentation#api_ohlc)
68+
5469
---
5570
#### convert(from_currency, to_currency, amount, date)
5671

@@ -105,8 +120,13 @@ client.carat(base='USD', date='2021-04-06')
105120
[Link](https://metalpriceapi.com/documentation#api_carat)
106121

107122
---
108-
**[Official documentation](https://metalpriceapi.com/documentation)**
123+
#### usage()
124+
125+
```ruby
126+
client.usage()
127+
```
109128

129+
[Link](https://metalpriceapi.com/documentation#api_usage)
110130

111131
---
112132
## FAQ

example/index.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
data = client.fetchHistorical('2021-04-05', 'USD', ['XAU', 'XAG', 'XPD', 'XPT'])
1818
puts data
1919

20+
data = client.fetchOHLC('USD', 'XAU', '2024-02-06', 'troy_oz', nil)
21+
puts data
22+
2023
data = client.convert('USD', 'EUR', 100, '2021-04-05')
2124
puts data
2225

@@ -27,4 +30,7 @@
2730
puts data
2831

2932
data = client.carat('USD', '2021-04-06')
30-
puts data
33+
puts data
34+
35+
data = client.usage()
36+
puts data

lib/metalpriceapi/endpoints/index.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ def fetchHistorical(date, base = nil, currencies = nil)
2222
get(date, options)
2323
end
2424

25+
def fetchOHLC(base = nil, currency = nil, date = nil, unit = nil, dateType = nil)
26+
options = removeEmpty({
27+
base: base,
28+
currency: currency,
29+
date: date,
30+
unit: unit,
31+
dateType: dateType
32+
})
33+
get('ohlc', options)
34+
end
35+
2536
def convert(from_currency = nil, to_currency = nil, amount = nil, date = nil)
2637
options = removeEmpty({
2738
'from': from_currency,
@@ -60,6 +71,10 @@ def carat(base = '', date = nil)
6071
get('carat', options)
6172
end
6273

74+
def usage
75+
get('usage')
76+
end
77+
6378
private
6479

6580
def removeEmpty(options)

lib/metalpriceapi/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module MetalpriceAPI
4-
VERSION = '1.0.3'
4+
VERSION = '1.1.1'
55
end

0 commit comments

Comments
 (0)