Get Rebar China Spot (REB-CH) Historical Prices using this API
Introduction
In the ever-evolving landscape of financial markets, the demand for accurate and timely data is paramount. For those interested in tracking the historical prices of gold, the Metals-API offers a robust solution. This API provides developers with the tools necessary to access real-time and historical data for various metals, including gold (XAU). In this blog post, we will explore how to retrieve historical prices for gold using the Metals-API, delve into its features, and discuss the transformative potential of integrating such data into applications.
Understanding the Metals-API
The Metals-API Website is a powerful resource for developers looking to incorporate metal pricing data into their applications. With a focus on innovation and technological advancement, the Metals-API empowers users to build next-generation applications that leverage real-time metals data. The API is designed to facilitate digital transformation in metal markets, providing insights that can drive decision-making and strategy.
About GraniteShares Gold Trust (BAR)
The GraniteShares Gold Trust (BAR) represents a significant advancement in the way investors can access gold. By utilizing smart technology integration and data analytics, BAR allows investors to gain exposure to the price of gold without the complexities of physical ownership. This trust exemplifies the future trends in the metals market, where digital transformation is reshaping investment strategies.
API Description
The Metals-API is a JSON-based API that provides access to a wide range of functionalities related to metal prices and currency conversion. It offers endpoints for retrieving the latest rates, historical rates, bid and ask prices, and much more. This API is particularly valuable for developers looking to create applications that require accurate and up-to-date information on metal prices.
Key Features of the Metals-API
One of the standout features of the Metals-API is its Latest Rates Endpoint, which provides real-time exchange rate data for various metals. Depending on your subscription plan, this endpoint can return data updated every 60 minutes or even every 10 minutes. This ensures that developers have access to the most current pricing information, which is crucial for applications that require real-time data.
Another essential feature is the Historical Rates Endpoint, which allows users to access historical rates dating back to 2019. By appending a specific date in the format YYYY-MM-DD, developers can query the API for historical prices, making it an invaluable tool for market analysis and trend identification.
The Bid and Ask Endpoint is another powerful feature that enables developers to retrieve real-time bid and ask prices for metals. This information is critical for traders and investors who need to make informed decisions based on the current market conditions.
Additionally, the Convert Endpoint allows users to convert any amount from one metal to another or to/from USD. This feature is particularly useful for applications that require currency conversion for transactions or reporting purposes.
Exploring the API Endpoints
To illustrate the capabilities of the Metals-API, let’s take a closer look at some of the key endpoints and their functionalities.
Latest Rates Endpoint
The Latest Rates Endpoint provides real-time exchange rates for all available metals. Here’s an example of a typical JSON response:
{
"success": true,
"timestamp": 1779754473,
"base": "USD",
"date": "2026-05-26",
"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"
}
In this response, the rates object provides the current price of various metals relative to USD, measured in troy ounces. This data is essential for developers building applications that require up-to-date pricing information.
Historical Rates Endpoint
The Historical Rates Endpoint allows users to access historical exchange rates for any date since 1999. Here’s an example response:
{
"success": true,
"timestamp": 1779668073,
"base": "USD",
"date": "2026-05-25",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
This endpoint is particularly useful for analysts and developers who need to track price movements over time. By querying historical data, users can identify trends and make informed predictions about future price movements.
Time-Series Endpoint
The Time-Series Endpoint allows users to query the API for daily historical rates between two dates of their choice. This functionality is invaluable for applications that require a comprehensive view of price trends over a specified period. Here’s an example response:
{
"success": true,
"timeseries": true,
"start_date": "2026-05-19",
"end_date": "2026-05-26",
"base": "USD",
"rates": {
"2026-05-19": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2026-05-21": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2026-05-26": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}
This endpoint provides a detailed view of how prices have changed over a specific timeframe, allowing developers to analyze fluctuations and trends effectively.
Convert Endpoint
The Convert Endpoint is designed to facilitate currency conversion between metals and USD. Here’s an example response:
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1779754473,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
This endpoint is particularly useful for applications that require real-time conversion rates for transactions or reporting purposes. Developers can easily integrate this functionality into their applications to enhance user experience.
Fluctuation Endpoint
The Fluctuation Endpoint allows users to track rate fluctuations between two dates. Here’s an example response:
{
"success": true,
"fluctuation": true,
"start_date": "2026-05-19",
"end_date": "2026-05-26",
"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"
}
This endpoint is crucial for traders who need to understand how prices have fluctuated over a specific period, enabling them to make informed trading decisions.
OHLC (Open/High/Low/Close) Price Endpoint
The OHLC Price Endpoint provides open, high, low, and close prices for a specific time period. Here’s an example response:
{
"success": true,
"timestamp": 1779754473,
"base": "USD",
"date": "2026-05-26",
"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"
}
This endpoint is particularly useful for technical analysis, allowing traders to assess market conditions and make predictions based on historical performance.
Bid/Ask Endpoint
The Bid/Ask Endpoint provides current bid and ask prices for metals. Here’s an example response:
{
"success": true,
"timestamp": 1779754473,
"base": "USD",
"date": "2026-05-26",
"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"
}
This endpoint is essential for traders who need to understand the current market spread and make informed decisions based on real-time data.
Common Use Cases and Integration Strategies
Integrating the Metals-API into applications can open up a myriad of possibilities for developers. Here are some common use cases:
- Market Analysis Tools: Developers can create applications that analyze historical price trends for gold and other metals, providing insights to traders and investors.
- Trading Platforms: By integrating real-time pricing data, trading platforms can offer users the ability to make informed decisions based on the latest market conditions.
- Financial Reporting: Businesses can utilize the API to generate reports that reflect the current and historical prices of metals, aiding in financial analysis and decision-making.
Performance Optimization and Security Considerations
When integrating the Metals-API, it’s crucial to consider performance optimization and security best practices. Here are some strategies:
- Rate Limiting: Be aware of the API's rate limits to avoid throttling. Implement caching strategies to minimize unnecessary API calls.
- Error Handling: Ensure robust error handling mechanisms are in place to manage API response errors gracefully.
- Data Validation: Validate all incoming data to prevent injection attacks and ensure data integrity.
Conclusion
The Metals-API is a powerful tool for developers looking to access real-time and historical data for metals, particularly gold. By leveraging its various endpoints, developers can create applications that provide valuable insights into market trends and pricing. Whether you are building a trading platform, a market analysis tool, or a financial reporting application, the Metals-API offers the functionality and flexibility needed to succeed in today’s data-driven environment.
For more information on how to get started, refer to the Metals-API Documentation and explore the Metals-API Supported Symbols to understand the full range of capabilities available. Embrace the future of metal market data with the Metals-API and unlock the potential of your applications.