How to get GraniteShares Gold Trust (BAR) prices through a simple API
How to Get GraniteShares Gold Trust (BAR) Prices Through a Simple API
In today's digital landscape, accessing real-time financial data has become essential for investors and developers alike. One of the most sought-after assets in the financial markets is gold, represented by the symbol XAU. The GraniteShares Gold Trust (BAR) is a popular investment vehicle that allows investors to gain exposure to gold prices without the need to physically hold the metal. To effectively track and analyze the prices of BAR and other precious metals, developers can leverage the capabilities of the Metals-API. This blog post will explore how to utilize this powerful API to access gold prices and provide insights into the broader market dynamics.
Metals-API Information
About Gold (XAU)
Gold has long been regarded as a safe-haven asset, particularly during times of economic uncertainty. The digital transformation in precious metals trading has opened new avenues for investors, allowing them to access real-time data and analytics that were previously unavailable. With the integration of technology in trading, investors can now make informed decisions based on market insights derived from data analytics.
The innovation in price discovery mechanisms has also been significant. Traditional methods of determining gold prices have evolved, and digital asset solutions now provide a more transparent and efficient way to track gold's value. The Metals-API plays a crucial role in this transformation by offering real-time metals data that empowers developers to build next-generation applications.
API Description
The Metals-API is a comprehensive JSON API that provides access to real-time and historical prices of various metals, including gold, silver, platinum, and palladium. This API is designed to cater to the needs of developers looking to integrate metals pricing data into their applications. With its innovative features, the Metals-API enables users to access a wealth of information, including the latest rates, historical data, and market fluctuations.
By utilizing the Metals-API, developers can create applications that offer users valuable insights into the metals market. Whether it's for trading platforms, financial analysis tools, or investment applications, the API's capabilities can be harnessed to deliver real-time data and analytics.
Key Features and Endpoints
The Metals-API offers a variety of endpoints that provide different functionalities, each designed to meet specific user 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 developers who need up-to-the-minute pricing information.
- Historical Rates Endpoint: Access historical rates for most currencies dating back to 2019. By appending a date to your query, you can retrieve past pricing data, which is invaluable for trend analysis and market research.
- Bid and Ask Endpoint: This powerful feature allows you to retrieve real-time bid and ask prices for various metals. Understanding the bid-ask spread is crucial for traders looking to optimize their buying and selling strategies.
- Convert Endpoint: The Metals-API includes a currency conversion endpoint that allows users to convert any amount from one metal to another or to/from USD. This feature is particularly useful for investors dealing with multiple currencies.
- Time-Series Endpoint: Query the API for daily historical rates between two dates of your choice. This endpoint is beneficial for analyzing price movements over specific periods.
- Fluctuation Endpoint: Retrieve information about how currencies fluctuate on a day-to-day basis. This feature helps users understand market volatility and make informed decisions.
- Carat Endpoint: Access gold rates by carat, allowing for more precise calculations and valuations based on purity.
- Lowest/Highest Price Endpoint: Query the API to get the lowest and highest price for a specified date range, aiding in market analysis.
- Open/High/Low/Close (OHLC) Price Endpoint: This endpoint provides the open, high, low, and close prices for a specific time period, essential for technical analysis.
- Historical LME Endpoint: Access historical rates for LME symbols dating back to 2008, which is useful for those interested in industrial metals.
- API Key: Your unique API key is required to access the API's features, ensuring secure and authorized usage.
- API Response: The exchange rates delivered by the Metals-API are relative to USD by default, providing a consistent reference point for users.
- Available Endpoints: The API comes with 14 endpoints, each providing different functionalities tailored to various user needs.
- Supported Symbols Endpoint: This constantly updated endpoint returns all available currencies, ensuring users have access to the latest information.
- 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": 1767571974,
"base": "USD",
"date": "2026-01-05",
"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": 1767485574,
"base": "USD",
"date": "2026-01-04",
"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": "2025-12-29",
"end_date": "2026-01-05",
"base": "USD",
"rates": {
"2025-12-29": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2025-12-31": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2026-01-05": {
"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": 1767571974,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
Fluctuation Endpoint
Track rate fluctuations between two dates:
{
"success": true,
"fluctuation": true,
"start_date": "2025-12-29",
"end_date": "2026-01-05",
"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) Price Endpoint
Get OHLC data for a specific time period:
{
"success": true,
"timestamp": 1767571974,
"base": "USD",
"date": "2026-01-05",
"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": 1767571974,
"base": "USD",
"date": "2026-01-05",
"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 GraniteShares Gold Trust (BAR) represents a significant opportunity for investors looking to gain exposure to gold without the complexities of physical ownership. By utilizing the Metals-API, developers can access a wealth of real-time and historical data that can enhance their applications and provide users with valuable insights into the gold market. The API's extensive features, including the latest rates, historical data, and various endpoints, empower developers to create innovative solutions that meet the needs of today's investors.
For more information on how to implement these features, refer to the Metals-API Documentation. Additionally, explore the Metals-API Supported Symbols page to familiarize yourself with the various metal symbols available for tracking and analysis. By leveraging the capabilities of the Metals-API, you can stay ahead in the ever-evolving landscape of precious metals trading.