The Easiest Way to Get Saudi Riyal (SAR) Historical Rates Using Public APIs
The Easiest Way to Get Saudi Riyal (SAR) Historical Rates Using Public APIs
In today's fast-paced digital economy, accessing historical currency rates is crucial for businesses, traders, and developers alike. One of the most efficient ways to obtain historical rates for the Saudi Riyal (SAR) is through the Metals-API. This powerful API provides real-time and historical data for various metals and currencies, enabling developers to create applications that require accurate financial data. In this blog post, we will explore how to retrieve historical prices for SAR using Metals-API, including example endpoints, parameters, and data formats.
Metals-API Information
Metals-API is a robust platform that offers a wide range of functionalities for accessing metal prices and currency conversion. It is designed for developers who need reliable and real-time data to build next-generation applications. The API supports various endpoints that allow users to fetch the latest rates, historical data, and even perform conversions between different currencies.
About Tellurium (TE)
While the focus of this post is on the Saudi Riyal, it is worth mentioning the broader context of metals like Tellurium (TE). The digital transformation in metal markets has been profound, driven by technological innovation and advancements in data analytics. The integration of smart technologies has allowed for real-time insights into market trends, enabling traders and businesses to make informed decisions.
As we look to the future, the possibilities for integrating advanced data analytics into metal markets are endless. The ability to track fluctuations, analyze historical data, and predict future trends will empower developers to create applications that can adapt to market changes swiftly.
API Description
The Metals-API provides a comprehensive suite of features that cater to various needs. From retrieving the latest rates to accessing historical data dating back to 2019, the API is designed to be flexible and user-friendly. Developers can leverage the API to build applications that require accurate and timely financial data, making it an invaluable tool in the financial technology landscape.
For detailed documentation on how to use the API, visit the Metals-API Documentation. The documentation provides in-depth information on each endpoint, including parameters, response formats, and usage examples.
Key Features and Endpoints
The Metals-API offers a variety of endpoints, each designed to fulfill specific requirements. Here are some of the key features:
- Latest Rates Endpoint: This endpoint provides real-time exchange rate data updated every 60 minutes, 10 minutes, or even more frequently, depending on your subscription plan. It allows users to access the most current rates for various metals and currencies.
- Historical Rates Endpoint: Users can access historical rates for most currencies dating back to 2019. By appending a specific date to the endpoint, developers can retrieve historical data for analysis and reporting.
- Bid And Ask Endpoint: This feature enables users to retrieve real-time bid and ask prices, providing insights into market conditions and helping traders make informed decisions.
- Convert Endpoint: The API includes a currency conversion endpoint that allows users to convert any amount from one currency to another, making it easy to handle transactions across different currencies.
- Time-Series Endpoint: This endpoint allows users to query the API for daily historical rates between two dates of their choice, providing a comprehensive view of price movements over time.
- Fluctuation Endpoint: Users can track how currencies fluctuate on a day-to-day basis, which is essential for understanding market volatility.
- Carat Endpoint: This feature provides information about gold rates by carat, allowing users to make precise calculations based on the purity of gold.
- Lowest/Highest Price Endpoint: This endpoint allows users to query the API to get the lowest and highest prices for a specified date, which is crucial for traders looking to optimize their buying and selling strategies.
- Open/High/Low/Close (OHLC) Price Endpoint: This endpoint provides open, high, low, and close prices for a specific date, offering a detailed view of market performance.
- Historical LME Endpoint: This endpoint provides access to historical rates for LME symbols dating back to 2008, which is vital for users interested in long-term trends.
- API Key: Each user is assigned a unique API key that must be included in requests to authenticate and authorize access to the API.
- API Response: The API delivers exchange rates relative to USD by default, ensuring consistency in data representation.
- Available Endpoints: The Metals-API comes with 14 different endpoints, each providing unique functionalities tailored to user needs.
- Supported Symbols Endpoint: This endpoint returns all available currencies, allowing users to stay updated on the latest symbols supported by the API.
- News Endpoint: Users can retrieve the latest news articles related to various metals, keeping them informed about market developments.
List of Symbols
The 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
To get real-time exchange rates for all available metals, you can use the following endpoint:
GET https://metals-api.com/api/latest?access_key=YOUR_API_KEY
Example response:
{
"success": true,
"timestamp": 1771374354,
"base": "USD",
"date": "2026-02-18",
"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
To access historical exchange rates for any date since 1999, use the following endpoint:
GET https://metals-api.com/api/historical?access_key=YOUR_API_KEY&date=YYYY-MM-DD
Example response:
{
"success": true,
"timestamp": 1771287954,
"base": "USD",
"date": "2026-02-17",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915,
"XPD": 0.000748
},
"unit": "per troy ounce"
}
Time-series Endpoint
To get exchange rates for a specific time period, use the following endpoint:
GET https://metals-api.com/api/timeseries?access_key=YOUR_API_KEY&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
Example response:
{
"success": true,
"timeseries": true,
"start_date": "2026-02-11",
"end_date": "2026-02-18",
"base": "USD",
"rates": {
"2026-02-11": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"2026-02-13": {
"XAU": 0.000483,
"XAG": 0.0382,
"XPT": 0.000913
},
"2026-02-18": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912
}
},
"unit": "per troy ounce"
}
Convert Endpoint
To convert any amount from one metal to another or to/from USD, use the following endpoint:
GET https://metals-api.com/api/convert?access_key=YOUR_API_KEY&from=USD&to=XAU&amount=1000
Example response:
{
"success": true,
"query": {
"from": "USD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1771374354,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
Fluctuation Endpoint
To track rate fluctuations between two dates, use the following endpoint:
GET https://metals-api.com/api/fluctuation?access_key=YOUR_API_KEY&start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
Example response:
{
"success": true,
"fluctuation": true,
"start_date": "2026-02-11",
"end_date": "2026-02-18",
"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
To get OHLC data for a specific time period, use the following endpoint:
GET https://metals-api.com/api/open-high-low-close?access_key=YOUR_API_KEY&date=YYYY-MM-DD
Example response:
{
"success": true,
"timestamp": 1771374354,
"base": "USD",
"date": "2026-02-18",
"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
To get current bid and ask prices for metals, use the following endpoint:
GET https://metals-api.com/api/bid-ask?access_key=YOUR_API_KEY
Example response:
{
"success": true,
"timestamp": 1771374354,
"base": "USD",
"date": "2026-02-18",
"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
In conclusion, the Metals-API provides a comprehensive and user-friendly solution for accessing historical rates for the Saudi Riyal (SAR) and other metals. With its wide range of endpoints, developers can easily retrieve real-time data, historical prices, and perform conversions, making it an essential tool for anyone working in finance or trading.
By leveraging the capabilities of the Metals-API, developers can create innovative applications that provide valuable insights into market trends and fluctuations. Whether you are building a trading platform, a financial analysis tool, or simply need accurate historical data, the Metals-API is equipped to meet your needs.
For more information on how to get started, visit the Metals-API Documentation and explore the Metals-API Supported Symbols page for a complete list of available symbols. With the right tools and data, you can stay ahead in the ever-evolving financial landscape.