Obtain API for
In the world of finance and trading, having access to accurate and timely data is crucial. This is especially true for metals trading, where fluctuations in prices can significantly impact investment decisions. One powerful tool that developers can leverage to obtain real-time and historical data on metals is the Metals-API. This API provides a comprehensive suite of features that allow users to access a wide range of data, including historical prices, latest rates, and much more. In this blog post, we will explore how to obtain historical prices for metals, specifically focusing on the symbol XAU, which represents Gold, and delve into the capabilities of the Metals-API.
Metals-API Information
API Description
The Metals-API is a robust and innovative solution designed to provide developers with real-time and historical data on various metals. With its advanced capabilities, the API empowers developers to build next-generation applications that require accurate and timely metals data. Whether you are developing a trading platform, a financial analysis tool, or a market research application, the Metals-API offers the flexibility and reliability needed to succeed.
One of the standout features of the Metals-API is its ability to deliver real-time exchange rate data. Depending on your subscription plan, the API can provide updates every 60 minutes, every 10 minutes, or even more frequently. This ensures that users have access to the most current information available, which is essential for making informed trading decisions.
For developers looking to access historical prices, the Metals-API offers a dedicated endpoint that allows users to query historical rates dating back to 2019. This feature is invaluable for conducting market analysis, backtesting trading strategies, and understanding price trends over time.
To learn more about the API's capabilities, you can refer to the Metals-API Documentation, which provides detailed information on how to implement and utilize the various endpoints effectively.
Key Features and Endpoints
The Metals-API boasts a variety of endpoints, each designed to serve specific needs. Here are some of the key features:
- Latest Rates Endpoint: This endpoint provides real-time exchange rate data for metals, updated based on your subscription plan. Users can access the latest rates for metals like Gold (XAU), Silver (XAG), Platinum (XPT), and Palladium (XPD).
- Historical Rates Endpoint: Users can obtain historical rates for metals by appending a specific date to the API call. This allows for detailed analysis of price movements over time.
- Bid And Ask Endpoint: This feature enables users to retrieve real-time bid and ask prices for metals, providing insights into market liquidity and pricing.
- Convert Endpoint: The API includes a currency conversion feature that allows users to convert amounts between different metals or to/from USD.
- Time-Series Endpoint: This endpoint allows users to query daily historical rates between two specified dates, making it easier to analyze trends over specific periods.
- Fluctuation Endpoint: Users can track how metal prices fluctuate on a day-to-day basis, providing insights into market volatility.
- Carat Endpoint: This feature allows users to retrieve Gold rates based on carat values, which is essential for jewelers and gold traders.
- Lowest/Highest Price Endpoint: Users can query the API to find the lowest and highest prices for metals over a specified period.
- Open/High/Low/Close (OHLC) Price Endpoint: This endpoint provides open, high, low, and close prices for metals, which are critical for technical analysis.
- Historical LME Endpoint: This endpoint offers access to historical rates for LME symbols dating back to 2008, useful for those involved in the London Metal Exchange.
- API Key: Each user is assigned a unique API key that must be included in API requests to authenticate access.
- API Response: The API delivers exchange rates relative to USD, ensuring consistency in data presentation.
- Available Endpoints: The Metals-API includes 14 different endpoints, each providing distinct functionalities tailored to user needs.
- Supported Symbols Endpoint: This endpoint returns a constantly updated list of all available metal symbols, ensuring users have access to the latest data.
- News Endpoint: Users can retrieve the latest news articles related to various metals, keeping them 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.
Obtaining Historical Prices with Metals-API
To obtain historical prices for Gold (XAU) using the Metals-API, you will primarily utilize the Historical Rates Endpoint. This endpoint allows you to query historical exchange rates for any date since 2019. The process is straightforward and involves appending the desired date to the API request.
Using the Historical Rates Endpoint
To access historical rates, you will need to format your API request as follows:
GET https://metals-api.com/api/historical?access_key=YOUR_API_KEY&date=YYYY-MM-DD&base=XAU
In this request, replace YOUR_API_KEY with your actual API key, and YYYY-MM-DD with the specific date for which you want to retrieve historical prices. The base parameter indicates the metal symbol you are querying, in this case, XAU for Gold.
Example Response for Historical Rates
When you make a successful request to the Historical Rates Endpoint, you will receive a JSON response that looks like this:
{
"success": true,
"timestamp": 1773274832,
"base": "USD",
"date": "2026-03-12",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
This response indicates that the request was successful, and it provides the historical exchange rate for Gold (XAU) on the specified date. The rates object contains the exchange rates for various metals relative to USD, allowing for easy comparison and analysis.
Understanding the Response Fields
Each field in the API response carries specific significance:
- success: A boolean value indicating whether the API request was successful.
- timestamp: The server timestamp at the time of the request, useful for tracking data freshness.
- base: The base currency for the exchange rates, which is USD by default.
- date: The date for which the historical rates are provided.
- rates: An object containing the exchange rates for various metals, with the metal symbols as keys.
- unit: The unit of measurement for the rates, typically per troy ounce.
Practical Use Cases for Historical Data
Accessing historical prices for Gold (XAU) can be beneficial in various scenarios:
- Market Analysis: Traders can analyze historical price movements to identify trends and make informed decisions.
- Backtesting Strategies: Developers can use historical data to backtest trading algorithms and assess their performance over time.
- Investment Research: Financial analysts can conduct research on Gold price trends to provide insights to investors.
Conclusion
The Metals-API is an invaluable resource for developers and traders looking to access real-time and historical data on metals. By utilizing the various endpoints, including the Historical Rates Endpoint, users can obtain critical information that aids in making informed trading decisions. The ability to access historical prices for Gold (XAU) and other metals opens up a world of possibilities for market analysis, strategy development, and investment research.
For more information on how to implement the Metals-API in your applications, refer to the Metals-API Documentation. Additionally, explore the Metals-API Supported Symbols page to familiarize yourself with the available metal symbols. Start leveraging the power of real-time metals data today with the Metals-API Website.