How to retrieve GraniteShares Gold Trust (BAR) prices using this API

Introduction
In the world of precious metals trading, the GraniteShares Gold Trust (BAR) serves as a vital instrument for investors seeking exposure to gold. With the rise of digital transformation in the financial sector, accessing real-time data on gold prices has become essential. This blog post will explore how to retrieve GraniteShares Gold Trust (BAR) prices using the Metals-API, a powerful tool that provides real-time and historical data on various metals, including gold (XAU). We will delve into the capabilities of the Metals-API, its endpoints, and how developers can leverage this technology to build innovative applications.
Metals-API Information
About Gold (XAU)
Gold, represented by the symbol XAU, has long been regarded as a safe haven asset and a hedge against inflation. As digital transformation reshapes the financial landscape, the integration of technology in trading precious metals has become increasingly significant. The Metals-API stands at the forefront of this transformation, providing developers with the tools necessary to access real-time market insights and analytics.
Data analytics plays a crucial role in understanding market trends and price movements. With the Metals-API, developers can harness the power of data to gain insights into gold prices, enabling them to make informed trading decisions. The API's innovative features facilitate price discovery, allowing users to track fluctuations and historical trends effectively.
Moreover, the integration of digital asset solutions has opened new avenues for trading gold. As more investors turn to digital platforms, having access to accurate and timely data is paramount. The Metals-API empowers developers to create applications that cater to this growing demand, ensuring that users have the information they need at their fingertips.
API Description
The Metals-API is a robust API that provides real-time and historical data for various metals, including gold, silver, platinum, and palladium. It is designed to empower developers to build next-generation applications that require accurate and timely metals data. The API offers a range of endpoints, each with unique functionalities that cater to different use cases.
One of the standout features of the Metals-API is its ability to deliver real-time exchange rate data. Depending on the subscription plan, users can receive updates every 60 seconds, every 10 minutes, or even more frequently. This capability is essential for traders who need to stay informed about market movements and make quick decisions.
Additionally, the Metals-API provides access to historical rates dating back to 2019, allowing users to analyze trends over time. This feature is particularly useful for developers looking to create applications that require historical data for analysis or reporting purposes.
Furthermore, the API includes a dedicated endpoint for bid and ask prices, enabling users to retrieve real-time pricing information. This feature is crucial for traders who need to know the current market spread to make informed trading decisions.
For those interested in currency conversion, the Metals-API offers a separate endpoint that allows users to convert amounts from one currency to another. This feature is particularly useful for international traders who need to understand the value of metals in different currencies.
The API also includes a time-series endpoint, which allows users to query daily historical rates between two dates of their choice. This capability is invaluable for developers looking to create applications that require detailed historical analysis.
In summary, the Metals-API is a transformative tool that empowers developers to access real-time metals data, enabling them to build innovative applications that cater to the needs of traders and investors.
Key Features and Endpoints
The Metals-API offers a variety of endpoints, each designed to provide specific functionalities. Below, we explore some of the key features and their potential applications:
Latest Rates Endpoint
The Latest Rates Endpoint provides real-time exchange rate data for all available metals. Depending on your subscription plan, the API can return updates every 60 seconds, every 10 minutes, or more frequently. This feature is essential for traders who need to stay informed about the latest market movements.
{
"success": true,
"timestamp": 1746922176,
"base": "USD",
"date": "2025-05-11",
"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 example response, the API returns the latest rates for various metals, with gold (XAU) priced at 0.000482 per troy ounce. This information is crucial for traders looking to make timely decisions based on current market conditions.
Historical Rates Endpoint
The Historical Rates Endpoint allows users to access historical exchange rates for any date since 1999. This feature is particularly useful for developers who need to analyze trends over time or generate reports based on historical data.
{
"success": true,
"timestamp": 1746835776,
"base": "USD",
"date": "2025-05-10",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
This response shows the historical rates for gold and other metals on a specific date, allowing users to track price movements and analyze market trends over time.
Bid And Ask Endpoint
The Bid and Ask Endpoint is a powerful feature that enables users to retrieve real-time bid and ask prices for metals. This information is essential for traders who need to understand the current market spread and make informed trading decisions.
{
"success": true,
"timestamp": 1746922176,
"base": "USD",
"date": "2025-05-11",
"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"
}
In this example, the response provides the current bid and ask prices for gold, silver, and platinum, along with the spread. This information is crucial for traders looking to execute orders at the best possible prices.
Convert Endpoint
The Convert Endpoint allows users to convert any amount from one metal to another or to/from USD. This feature is particularly useful for traders who need to understand the value of metals in different currencies.
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1746922176,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
This response shows the conversion of 1000 USD to gold (XAU), resulting in 0.482 troy ounces. This capability is essential for traders operating in multiple currencies.
Time-Series Endpoint
The Time-Series Endpoint allows users to query the API for daily historical rates between two dates of their choice. This feature is invaluable for developers looking to create applications that require detailed historical analysis.
{
"success": true,
"timeseries": true,
"start_date": "2025-05-04",
"end_date": "2025-05-11",
"base": "USD",
"rates": {
"2025-05-04": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2025-05-06": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2025-05-11": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}
This response provides daily historical rates for gold, silver, and platinum over a specified period, allowing users to analyze trends and fluctuations effectively.
Fluctuation Endpoint
The Fluctuation Endpoint enables users to track rate fluctuations between two dates. This feature is essential for traders who want to understand how prices change over time.
{
"success": true,
"fluctuation": true,
"start_date": "2025-05-04",
"end_date": "2025-05-11",
"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 response shows the fluctuation in prices for gold, silver, and platinum over a specified period, providing valuable insights into market trends.
Open/High/Low/Close (OHLC) Price Endpoint
The OHLC Price Endpoint allows users to query the API for the open, high, low, and close prices for a specific time period. This feature is crucial for traders who need to analyze price movements and make informed decisions.
{
"success": true,
"timestamp": 1746922176,
"base": "USD",
"date": "2025-05-11",
"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 response provides the open, high, low, and close prices for gold, silver, and platinum on a specific date, allowing users to analyze market performance effectively.
Historical LME Endpoint
The Historical LME Endpoint provides access to historical rates for LME symbols dating back to 2008. This feature is particularly useful for developers looking to analyze trends in metals traded on the London Metal Exchange.
{
"success": true,
"timestamp": 1746835776,
"base": "USD",
"date": "2025-05-10",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
This response shows historical rates for gold and other metals traded on the LME, providing valuable insights into market trends over time.
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. This resource is invaluable for developers looking to understand the various metals available for trading and analysis.
Conclusion
In conclusion, the Metals-API is a powerful tool that enables developers to access real-time and historical data for precious metals, including gold (XAU). With its extensive range of endpoints, the API empowers developers to build innovative applications that cater to the needs of traders and investors. By leveraging the capabilities of the Metals-API, developers can gain valuable insights into market trends, track price fluctuations, and make informed trading decisions.
As the financial landscape continues to evolve, the integration of technology in trading precious metals will become increasingly important. The Metals-API stands at the forefront of this transformation, providing developers with the tools they need to succeed in a rapidly changing market. For more information on how to get started, visit the Metals-API Documentation for detailed guidance on implementation and usage.