How to Use this API
How to Use this API
In the world of finance and trading, having access to real-time data is crucial for making informed decisions. The Metals-API provides developers with the tools to access historical prices and real-time data for various metals, including Gold (XAU), Silver (XAG), Platinum (XPT), and Palladium (XPD). This blog post will delve into the capabilities of the Metals-API, focusing on how to retrieve historical prices and leverage the API's features to build innovative applications.
Metals-API Information
API Description
The Metals-API is a powerful JSON API that offers real-time and historical price data for a variety of metals. It is designed to empower developers to create next-generation applications that require accurate and timely metals data. With its robust infrastructure, the API provides access to a wealth of information, including the latest rates, historical prices, and market trends. This capability is transformative for industries such as finance, e-commerce, and investment, where precise data can lead to better decision-making and strategic planning.
By utilizing the Metals-API, developers can integrate real-time metals data into their applications, enabling features such as price alerts, historical analysis, and market trend visualization. The API's flexibility allows for a wide range of applications, from simple price tracking tools to complex trading platforms.
Key Features and Endpoints
The Metals-API offers a variety of endpoints that cater to different needs. Here are some of the key features:
- Latest Rates Endpoint: Depending on your subscription plan, this endpoint returns real-time exchange rate data updated every 60 minutes, every 10 minutes, or even more frequently. This feature is essential for applications that require up-to-the-minute pricing information.
- Historical Rates Endpoint: Access historical rates for most currencies dating back to 2019. You can query the API for historical rates by appending a specific date, allowing for in-depth analysis of price trends over time.
- Bid And Ask Endpoint: This powerful feature enables you to retrieve real-time bid and ask prices, which are crucial for traders looking to execute orders at the best possible prices.
- Convert Endpoint: The API includes a currency conversion endpoint, allowing users to convert any amount from one currency to another. This is particularly useful for applications that deal with multiple currencies.
- Time-Series Endpoint: Query the API for daily historical rates between two dates of your choice. This endpoint is invaluable for analyzing price movements over specific time frames.
- Fluctuation Endpoint: Retrieve information about how currencies fluctuate on a day-to-day basis, providing insights into market volatility.
- Carat Endpoint: Get information about Gold rates by Carat. This feature is particularly useful for jewelers and those in the luxury goods market.
- Lowest/Highest Price Endpoint: Query the API to get the lowest and highest price for a specified date, which can help in identifying market extremes.
- Open/High/Low/Close (OHLC) Price Endpoint: This endpoint allows you to get the open, high, low, and close prices for a specific date, essential for traders analyzing market performance.
- Historical LME Endpoint: Access historical rates for LME symbols dating back to 2008, which is crucial for those involved in commodities trading.
- API Key: Your unique API key is required to access the API, ensuring secure and authorized usage.
- API Response: The exchange rates delivered by the Metals-API are by default relative to USD, and all data is returned in a structured JSON format.
- Available Endpoints: The API features 14 different endpoints, each providing unique functionalities tailored to various user needs.
- Supported Symbols Endpoint: This endpoint returns all available currencies, ensuring that developers have access to the latest symbols and their specifications.
- News Endpoint: Retrieve the latest news articles related to various metals, keeping users informed about market developments.
List of Symbols
The Metals-API provides access to a comprehensive range of metal symbols. For a complete list of all supported symbols and their specifications, refer to the Metals-API Supported Symbols page.
API Endpoint Examples and Responses
Latest Rates Endpoint
Get real-time exchange rates for all available metals:
{
"success": true,
"timestamp": 1769044445,
"base": "USD",
"date": "2026-01-22",
"rates": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912,
"XPD": 0.000744,
"XCU": 0.294118,
"XAL": 0.434783,
"XNI": 0.142857,
"XZN": 0.344828
},
"unit": "per troy ounce"
}
Historical Rates Endpoint
Access historical exchange rates for any date since 1999:
{
"success": true,
"timestamp": 1768958045,
"base": "USD",
"date": "2026-01-21",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
Time-series Endpoint
Get exchange rates for a specific time period:
{
"success": true,
"timeseries": true,
"start_date": "2026-01-15",
"end_date": "2026-01-22",
"base": "USD",
"rates": {
"2026-01-15": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2026-01-17": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2026-01-22": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}
Convert Endpoint
Convert any amount from one metal to another or to/from USD:
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1769044445,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
Fluctuation Endpoint
Track rate fluctuations between two dates:
{
"success": true,
"fluctuation": true,
"start_date": "2026-01-15",
"end_date": "2026-01-22",
"base": "USD",
"rates": {
"XAU": {
"start_rate": 0.000485,
"end_rate": 0.000482,
"change": -3.0e-6,
"change_pct": -0.62
},
"XAG": {
"start_rate": 0.03825,
"end_rate": 0.03815,
"change": -0.0001,
"change_pct": -0.26
},
"XPT": {
"start_rate": 0.000915,
"end_rate": 0.000912,
"change": -3.0e-6,
"change_pct": -0.33
}
},
"unit": "per troy ounce"
}
OHLC (Open/High/Low/Close) Endpoint
Get OHLC data for a specific time period:
{
"success": true,
"timestamp": 1769044445,
"base": "USD",
"date": "2026-01-22",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
},
"XAG": {
"open": 0.03825,
"high": 0.0383,
"low": 0.0381,
"close": 0.03815
},
"XPT": {
"open": 0.000915,
"high": 0.000918,
"low": 0.00091,
"close": 0.000912
}
},
"unit": "per troy ounce"
}
Bid/Ask Endpoint
Get current bid and ask prices for metals:
{
"success": true,
"timestamp": 1769044445,
"base": "USD",
"date": "2026-01-22",
"rates": {
"XAU": {
"bid": 0.000481,
"ask": 0.000483,
"spread": 2.0e-6
},
"XAG": {
"bid": 0.0381,
"ask": 0.0382,
"spread": 0.0001
},
"XPT": {
"bid": 0.000911,
"ask": 0.000913,
"spread": 2.0e-6
}
},
"unit": "per troy ounce"
}
Conclusion
The Metals-API is an invaluable resource for developers looking to integrate real-time and historical metals data into their applications. With a wide range of endpoints, including the latest rates, historical prices, and conversion capabilities, the API provides the tools necessary to build sophisticated financial applications. By leveraging the API's features, developers can create applications that not only track prices but also analyze trends, forecast market movements, and provide users with actionable insights.
For more information on how to get started, refer to the Metals-API Documentation, which provides comprehensive guidance on using the API effectively. Additionally, explore the Metals-API Supported Symbols page to familiarize yourself with the various metal symbols available for querying.
In summary, the Metals-API is not just a data source; it is a powerful tool that can transform how developers approach financial data and analytics. By utilizing this API, you can unlock new possibilities in the world of metals trading and investment.