@@ -16,7 +16,30 @@ from metalpriceapi.client import Client
1616
1717api_key = ' SET_YOUR_API_KEY_HERE'
1818client = Client(api_key)
19+
20+ # Or use EU server:
21+ # client = Client(api_key, server='eu')
1922```
23+ ---
24+ ## Server Regions
25+
26+ MetalpriceAPI 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.metalpriceapi.com/v1 ` |
31+ | Europe | ` https://api-eu.metalpriceapi.com/v1 ` |
32+
33+ ``` python
34+ from metalpriceapi.client import Client
35+
36+ # Default (US)
37+ client = Client(' SET_YOUR_API_KEY_HERE' )
38+
39+ # Europe
40+ client = Client(' SET_YOUR_API_KEY_HERE' , server = ' eu' )
41+ ```
42+
2043---
2144## Documentation
2245
@@ -28,32 +51,62 @@ client.fetchSymbols()
2851[ Link] ( https://metalpriceapi.com/documentation#api_symbol )
2952
3053---
31- #### fetchLive(base, currencies)
54+ #### setServer(server)
55+
56+ - ` server ` <[ string] > Pass ` 'eu' ` to use the EU server (` api-eu.metalpriceapi.com ` ), or ` 'us' ` for the US server. Defaults to US if not specified.
57+
58+ ``` python
59+ client.setServer(' eu' )
60+ ```
61+
62+ ---
63+ #### fetchLive(base, currencies, unit, purity, math)
3264
3365- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
34- - ` currencies ` <[ List] <[ string] >> Optional. Pass in an list of currencies to return values for.
66+ - ` currencies ` <[ List] <[ string] >> Optional. Pass in a list of currencies to return values for.
67+ - ` unit ` <[ string] > Optional. Pass in a unit for metal prices (e.g. ` troy_oz ` , ` gram ` , ` kilogram ` ).
68+ - ` purity ` <[ string] > Optional. Pass in a purity level for metal prices.
69+ - ` math ` <[ string] > Optional. Pass in a math expression to apply to the rates.
3570
3671``` python
37- client.fetchLive(base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ])
72+ client.fetchLive(base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ], unit = ' troy_oz ' )
3873```
3974
4075[ Link] ( https://metalpriceapi.com/documentation#api_realtime )
4176
4277---
43- #### fetchHistorical(date, base, currencies)
78+ #### fetchHistorical(date, base, currencies, unit )
4479
4580- ` date ` <[ string] > Required. Pass in a string with format ` YYYY-MM-DD `
4681- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
47- - ` currencies ` <[ List] <[ string] >> Optional. Pass in an list of currencies to return values for.
82+ - ` currencies ` <[ List] <[ string] >> Optional. Pass in a list of currencies to return values for.
83+ - ` unit ` <[ string] > Optional. Pass in a unit for metal prices (e.g. ` troy_oz ` , ` gram ` , ` kilogram ` ).
4884
4985``` python
50- client.fetchHistorical(date = ' 2024-02-05' , base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ])
86+ client.fetchHistorical(date = ' 2024-02-05' , base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ], unit = ' troy_oz ' )
5187```
5288
5389[ Link] ( https://metalpriceapi.com/documentation#api_historical )
5490
5591---
56- #### fetchOHLC(base, currency, date, unit, dateType)
92+ #### hourly(base, currency, unit, start_date, end_date, math, date_type)
93+
94+ - ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
95+ - ` currency ` <[ string] > Required. Specify currency you would like to get hourly rates for.
96+ - ` unit ` <[ string] > Optional. Pass in a unit for metal prices (e.g. ` troy_oz ` , ` gram ` , ` kilogram ` ).
97+ - ` start_date ` <[ string] > Required. Specify the start date using the format ` YYYY-MM-DD ` .
98+ - ` end_date ` <[ string] > Required. Specify the end date using the format ` YYYY-MM-DD ` .
99+ - ` math ` <[ string] > Optional. Pass in a math expression to apply to the rates.
100+ - ` date_type ` <[ string] > Optional. Pass in a date type, overrides date parameters if passed in.
101+
102+ ``` python
103+ client.hourly(base = ' USD' , currency = ' XAU' , unit = ' troy_oz' , start_date = ' 2025-11-03' , end_date = ' 2025-11-03' )
104+ ```
105+
106+ [ Link] ( https://metalpriceapi.com/documentation#api_hourly )
107+
108+ ---
109+ #### fetchOHLC(base, currency, date, unit, date_type)
57110
58111- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
59112- ` currency ` <[ string] > Required. Specify currency you would like to get OHLC for.
@@ -62,18 +115,19 @@ client.fetchHistorical(date='2024-02-05', base='USD', currencies=['XAU', 'XAG',
62115- ` date_type ` <[ string] > Optional. Pass in a date type, overrides date parameter if passed in.
63116
64117``` python
65- client.fetchOHLC(base = ' USD' , currency = ' XAU' , date = ' 2024-02-05' , unit = ' troy_oz' , date_type = None )
118+ client.fetchOHLC(base = ' USD' , currency = ' XAU' , date = ' 2024-02-05' , unit = ' troy_oz' )
66119```
67120
68121[ Link] ( https://metalpriceapi.com/documentation#api_ohlc )
69122
70123---
71- #### convert(from_currency, to_currency, amount, date)
124+ #### convert(from_currency, to_currency, amount, date, unit )
72125
73126- ` from_currency ` <[ string] > Optional. Pass in a base currency, defaults to USD.
74127- ` to_currency ` <[ string] > Required. Specify currency you would like to convert to.
75128- ` amount ` <[ number] > Required. The amount to convert.
76129- ` 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.
130+ - ` unit ` <[ string] > Optional. Pass in a unit for metal prices (e.g. ` troy_oz ` , ` gram ` , ` kilogram ` ).
77131
78132``` python
79133client.convert(from_currency = ' USD' , to_currency = ' EUR' , amount = 100 , date = ' 2024-02-05' )
@@ -82,26 +136,28 @@ client.convert(from_currency='USD', to_currency='EUR', amount=100, date='2024-02
82136[ Link] ( https://metalpriceapi.com/documentation#api_convert )
83137
84138---
85- #### timeframe(start_date, end_date, base, currencies)
139+ #### timeframe(start_date, end_date, base, currencies, unit )
86140
87141- ` start_date ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
88142- ` end_date ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
89143- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
90- - ` currencies ` <[ List] <[ string] >> Optional. Pass in an list of currencies to return values for.
144+ - ` currencies ` <[ List] <[ string] >> Optional. Pass in a list of currencies to return values for.
145+ - ` unit ` <[ string] > Optional. Pass in a unit for metal prices (e.g. ` troy_oz ` , ` gram ` , ` kilogram ` ).
91146
92147``` python
93- client.timeframe(start_date = ' 2024-02-05' , end_date = ' 2024-02-06' , base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ])
148+ client.timeframe(start_date = ' 2024-02-05' , end_date = ' 2024-02-06' , base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ], unit = ' troy_oz ' )
94149```
95150
96151[ Link] ( https://metalpriceapi.com/documentation#api_timeframe )
97152
98153---
99- #### change(start_date, end_date, base, currencies)
154+ #### change(start_date, end_date, base, currencies, date_type )
100155
101156- ` start_date ` <[ string] > Required. Specify the start date of your timeframe using the format ` YYYY-MM-DD ` .
102157- ` end_date ` <[ string] > Required. Specify the end date of your timeframe using the format ` YYYY-MM-DD ` .
103158- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
104- - ` currencies ` <[ List] <[ string] >> Optional. Pass in an list of currencies to return values for.
159+ - ` currencies ` <[ List] <[ string] >> Optional. Pass in a list of currencies to return values for.
160+ - ` date_type ` <[ string] > Optional. Pass in a date type, overrides date parameters if passed in.
105161
106162``` python
107163client.change(start_date = ' 2024-02-05' , end_date = ' 2024-02-06' , base = ' USD' , currencies = [' XAU' , ' XAG' , ' XPD' , ' XPT' ])
@@ -110,13 +166,14 @@ client.change(start_date='2024-02-05', end_date='2024-02-06', base='USD', curren
110166[ Link] ( https://metalpriceapi.com/documentation#api_change )
111167
112168---
113- #### carat(base, date)
169+ #### carat(base, currency, date)
114170
115171- ` base ` <[ string] > Optional. Pass in a base currency, defaults to USD.
172+ - ` currency ` <[ string] > Optional. Pass in a metal code to get carat prices for (defaults to XAU).
116173- ` date ` <[ string] > Optional. Specify date to get Carat for specific date using format ` YYYY-MM-DD ` . If not specified, uses live rates.
117174
118175``` python
119- client.carat(base = ' USD' , date = ' 2024-02-05' )
176+ client.carat(base = ' USD' , currency = ' XAU ' , date = ' 2024-02-05' )
120177```
121178
122179[ Link] ( https://metalpriceapi.com/documentation#api_carat )
0 commit comments