Convert Endpoint
The Metals-API API comes with a separate currency conversion endpoint, which can be used to convert any amount from one currency to another. In order to convert currencies, please use the API's convert
endpoint, append the from
and to
parameters and set them to your preferred base and target currency codes or metal codes.
It is also possible to convert currencies using historical exchange rate data. To do this, please also use the API's date parameter
and set it to your preferred date. (format YYYY-MM-DD
)
API Request:
https://metals-api.com/api/convert ? access_key = API_KEY & from = GBP & to = JPY & amount = 25
Request Parameters:
Parameter | Description |
---|---|
access_key |
[required] Your API Key. |
from |
[required] The three-letter currency code or metal code of the symbol you would like to convert from. |
to |
[required] The three-letter currency code or metal code or metal code of the currency you would like to convert to. |
amount |
[required] The amount to be converted. |
date |
[optional] Specify a date (format YYYY-MM-DD ) to use historical rates for this conversion. |
API Response:
{ "success": true, "query": { "from": "GBP", "to": "JPY", "amount": 25 }, "info": { "timestamp": 1519328414, "rate": 148.972231 }, "historical": "" "date": "2018-02-22" "result": 3724.305775 }
Response Objects:
Response Object | Description |
---|---|
success |
Returns true or false depending on whether or not your API request has succeeded. |
query > from |
Returns the three-letter currency code or metal code of the symbol converted from. |
query > to |
Returns the three-letter currency code or metal code of the symbol converted to. |
query > to |
Returns the amount that is converted. |
info > timestamp |
Returns the exact date and time (UNIX time stamp) the given exchange rare was collected. |
info > rate |
Returns the exchange rate used for your conversion. |
historical |
Returns true if historical rates are used for this conversion. |
date |
Returns the date (format YYYY-MM-DD ) the given exchange rate data was collected. |
result |
Returns your conversion result. |
Example request in Postman:
https://metals-api.com/api/convert?access_key=YOUR_API_KEY&from=USD&to=GBP&amount=200
Example request in Postman with the date (Returns the date (format YYYY-MM-DD
) the given exchange rate data was collected):