Accessing GraniteShares Gold Trust (BAR) price data in your projects using this API
Accessing GraniteShares Gold Trust (BAR) Price Data in Your Projects Using Metals-API
In today's rapidly evolving financial landscape, accessing real-time data for precious metals like gold is crucial for developers and traders alike. The GraniteShares Gold Trust (BAR) represents a modern approach to investing in gold, and with the help of the Metals-API, you can seamlessly integrate gold price data into your applications. This blog post will explore the capabilities of the Metals-API, focusing on how it can be utilized to access and analyze gold price data effectively.
About Gold (XAU)
Gold, represented by the symbol XAU, has long been a cornerstone of wealth preservation and investment strategies. As digital transformation sweeps through the financial sector, the integration of technology into precious metals trading is becoming increasingly significant. The rise of data analytics and market insights allows traders to make informed decisions based on real-time data, while innovation in price discovery is reshaping how investors approach gold trading.
With the advent of digital asset solutions, gold is no longer just a physical commodity; it is becoming a digital asset that can be traded and analyzed with unprecedented efficiency. The Metals-API plays a pivotal role in this transformation, providing developers with the tools needed to access real-time and historical gold price data, enabling them to build next-generation applications that cater to the evolving needs of investors.
Understanding Metals-API
The Metals-API is a powerful JSON API designed to deliver real-time and historical data for various metals, including gold, silver, platinum, and palladium. This API empowers developers to create applications that can track market trends, analyze price fluctuations, and convert between different metal values. By leveraging the capabilities of the Metals-API, developers can enhance their applications with accurate and timely data, ultimately improving user experience and decision-making.
Key Features and Endpoints
The Metals-API offers a variety of endpoints that cater to different data needs. Here are some of the most significant features:
- Latest Rates Endpoint: This endpoint provides real-time exchange rate data for metals, updated based on your subscription plan. Depending on your plan, you can receive updates every 60 minutes or even every 10 minutes, ensuring you have the latest information at your fingertips.
- Historical Rates Endpoint: Access historical rates dating back to 2019. By appending a specific date to your request, you can retrieve past price data for analysis and comparison.
- Bid and Ask Endpoint: This feature allows you to retrieve real-time bid and ask prices for metals, providing insights into market conditions and helping traders make informed decisions.
- Convert Endpoint: Easily convert any amount from one metal to another or to/from USD. This endpoint simplifies the process of understanding the value of metals in different currencies.
- Time-Series Endpoint: Query the API for daily historical rates between two dates of your choice, allowing for in-depth analysis of price trends over time.
- Fluctuation Endpoint: Track how metal prices fluctuate on a day-to-day basis, providing insights into market volatility and helping traders strategize accordingly.
- Carat Endpoint: Retrieve information about gold rates by carat, which is essential for jewelers and those dealing in fine gold.
- Lowest/Highest Price Endpoint: Query the API to get the lowest and highest prices for a specified date, which can be crucial for identifying market extremes.
- Open/High/Low/Close (OHLC) Price Endpoint: Access detailed OHLC data for a specific time period, which is vital for technical analysis and trading strategies.
- Historical LME Endpoint: Access historical rates for LME symbols dating back to 2008, providing a comprehensive view of market trends over time.
- API Key: Your unique API key is essential for accessing the Metals-API. It must be included in your requests to authenticate your access.
- API Response: The API delivers exchange rates relative to USD by default, ensuring consistency in data interpretation.
- Available Endpoints: The Metals-API includes 14 endpoints, each designed to provide specific functionalities tailored to various user needs.
- Supported Symbols Endpoint: This endpoint returns a constantly updated list of all available metal symbols, ensuring you have access to the latest data.
- News Endpoint: Retrieve the latest news articles related to various metals, keeping you informed about market developments.
Examples of API Responses
Understanding the structure of API responses is crucial for effective integration. Here are examples of responses from various endpoints:
Latest Rates Endpoint
{
"success": true,
"timestamp": 1762387269,
"base": "USD",
"date": "2025-11-06",
"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"
}
The response includes a success flag, a timestamp, the base currency, the date of the rates, and a detailed breakdown of rates for various metals, all expressed in terms of troy ounces.
Historical Rates Endpoint
{
"success": true,
"timestamp": 1762300869,
"base": "USD",
"date": "2025-11-05",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
This response provides historical rates for a specific date, allowing developers to analyze trends over time.
Time-Series Endpoint
{
"success": true,
"timeseries": true,
"start_date": "2025-10-30",
"end_date": "2025-11-06",
"base": "USD",
"rates": {
"2025-10-30": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2025-11-01": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2025-11-06": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}
This endpoint allows for tracking price changes over a specified period, making it invaluable for trend analysis.
Convert Endpoint
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1762387269,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
The Convert Endpoint simplifies the process of understanding the value of metals in different currencies, providing a clear result based on the current exchange rate.
Fluctuation Endpoint
{
"success": true,
"fluctuation": true,
"start_date": "2025-10-30",
"end_date": "2025-11-06",
"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 provides insights into how metal prices fluctuate over time, which is essential for traders looking to capitalize on market movements.
OHLC (Open/High/Low/Close) Price Endpoint
{
"success": true,
"timestamp": 1762387269,
"base": "USD",
"date": "2025-11-06",
"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"
}
OHLC data is crucial for technical analysis, allowing traders to assess market conditions and make informed decisions based on price movements.
Bid/Ask Endpoint
{
"success": true,
"timestamp": 1762387269,
"base": "USD",
"date": "2025-11-06",
"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 provides current bid and ask prices, which are essential for traders looking to execute orders at the best possible prices.
Conclusion
In conclusion, the Metals-API offers a comprehensive suite of tools for accessing and analyzing gold price data, making it an invaluable resource for developers and traders alike. By leveraging the various endpoints, you can build applications that provide real-time insights, historical analysis, and conversion capabilities for precious metals. The integration of technology in trading and data analytics is transforming how investors approach the market, and the Metals-API is at the forefront of this evolution.
For more information on how to get started with the Metals-API, visit the Metals-API Documentation and explore the Metals-API Supported Symbols to familiarize yourself with the available data. With the right tools and insights, you can navigate the world of precious metals trading with confidence and precision.