Fetch Moroccan Dirham (MAD) Historical Prices with this API
Introduction
The Moroccan Dirham (MAD) is a vital currency in North Africa, serving as the official currency of Morocco. For developers and financial analysts looking to fetch historical prices of the Moroccan Dirham, the Metals-API offers a robust solution. This API provides real-time and historical data for various metals and currencies, including the Moroccan Dirham, enabling users to build applications that require accurate financial data. In this blog post, we will explore how to effectively utilize the Metals-API to fetch historical prices of the Moroccan Dirham, delve into its features, and provide practical examples for implementation.
Understanding Metals-API
The Metals-API is a powerful tool designed for developers who need access to real-time and historical data on metals and currencies. With its innovative approach to data analytics, the API allows users to integrate various functionalities into their applications seamlessly. The API is built on modern technological advancements, ensuring that users receive timely and accurate data. By leveraging the capabilities of the Metals-API, developers can create applications that provide insights into market trends, price fluctuations, and historical data analysis.
About Molybdenum (MO)
Molybdenum is a critical metal in various industrial applications, and understanding its market dynamics can be enhanced through the use of the Metals-API. The digital transformation in metal markets has led to significant technological innovations that allow for better data analytics and insights. The integration of smart technology into metal trading has opened new avenues for developers to explore future trends and possibilities.
API Description
The Metals-API provides a comprehensive suite of features that empower developers to access a wide array of data related to metals and currencies. By utilizing this API, developers can build next-generation applications that require real-time data and historical analysis. The API's capabilities include fetching the latest rates, historical prices, bid and ask prices, and much more. For detailed information on how to get started, refer to the Metals-API Documentation.
Key Features of Metals-API
The Metals-API offers several endpoints that cater to different data needs. Here are some of the key features:
Latest Rates Endpoint
The Latest Rates endpoint provides real-time exchange rate data for various metals and currencies, including the Moroccan Dirham. Depending on your subscription plan, this endpoint can return data updated every 60 minutes or every 10 minutes. This feature is essential for applications that require up-to-the-minute pricing information.
{
"success": true,
"timestamp": 1776816795,
"base": "MAD",
"date": "2026-04-22",
"rates": {
"XAU": 0.000482,
"XAG": 0.03815,
"XPT": 0.000912,
"XPD": 0.000744
},
"unit": "per troy ounce"
}
Historical Rates Endpoint
The Historical Rates endpoint allows users to access historical exchange rates for the Moroccan Dirham dating back to 2019. By appending a specific date to the API request, developers can retrieve historical data, which is crucial for trend analysis and financial forecasting.
{
"success": true,
"timestamp": 1776730395,
"base": "MAD",
"date": "2026-04-21",
"rates": {
"XAU": 0.000485,
"XAG": 0.03825,
"XPT": 0.000915
},
"unit": "per troy ounce"
}
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 vital for traders and analysts who need to make informed decisions based on current market conditions.
{
"success": true,
"timestamp": 1776816795,
"base": "MAD",
"date": "2026-04-22",
"rates": {
"XAU": {
"bid": 0.000481,
"ask": 0.000483,
"spread": 2.0e-6
},
"XAG": {
"bid": 0.0381,
"ask": 0.0382,
"spread": 0.0001
}
},
"unit": "per troy ounce"
}
Convert Endpoint
The Convert endpoint allows users to convert any amount from one currency to another, including conversions involving the Moroccan Dirham. This feature is particularly useful for applications that require currency conversion functionalities.
{
"success": true,
"query": {
"from": "MAD",
"to": "XAU",
"amount": 1000
},
"info": {
"timestamp": 1776816795,
"rate": 0.000482
},
"result": 0.482,
"unit": "troy ounces"
}
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 essential for analyzing trends over specific periods, enabling developers to build applications that provide insights into price movements.
{
"success": true,
"timeseries": true,
"start_date": "2026-04-15",
"end_date": "2026-04-22",
"base": "MAD",
"rates": {
"2026-04-15": {
"XAU": 0.000485,
"XAG": 0.03825
},
"2026-04-22": {
"XAU": 0.000482,
"XAG": 0.03815
}
},
"unit": "per troy ounce"
}
Fluctuation Endpoint
The Fluctuation endpoint provides information about how currencies fluctuate on a day-to-day basis. This feature is valuable for developers looking to analyze volatility and market trends for the Moroccan Dirham.
{
"success": true,
"fluctuation": true,
"start_date": "2026-04-15",
"end_date": "2026-04-22",
"base": "MAD",
"rates": {
"XAU": {
"start_rate": 0.000485,
"end_rate": 0.000482,
"change": -3.0e-6,
"change_pct": -0.62
}
},
"unit": "per troy ounce"
}
Open/High/Low/Close (OHLC) Price Endpoint
The OHLC Price endpoint allows users to retrieve the open, high, low, and close prices for a specific time period. This data is crucial for traders who need to analyze market performance over time.
{
"success": true,
"timestamp": 1776816795,
"base": "MAD",
"date": "2026-04-22",
"rates": {
"XAU": {
"open": 0.000485,
"high": 0.000487,
"low": 0.000481,
"close": 0.000482
}
},
"unit": "per troy ounce"
}
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 focusing on metals traded on the London Metal Exchange.
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 who need to understand the various metals and currencies available through the API.
API Response Examples
Understanding the API responses is crucial for effective implementation. Below are examples of various API responses along with explanations of their fields:
Latest Rates Example
The response from the Latest Rates endpoint includes the following fields:
- success: Indicates whether the request was successful.
- timestamp: The time at which the data was retrieved.
- base: The base currency for the exchange rates.
- date: The date for which the rates are applicable.
- rates: An object containing the exchange rates for various metals.
- unit: The unit of measurement for the rates.
Historical Rates Example
The Historical Rates endpoint returns similar fields, with the addition of the specific date for which the historical rates are provided. This data is essential for analyzing past market conditions.
Time-Series Example
The Time-Series endpoint response includes a timeline of rates, allowing developers to visualize trends over time. Each date in the response contains its corresponding rates, making it easy to analyze fluctuations.
Common Developer Questions
As developers begin to integrate the Metals-API into their applications, they may encounter common questions and challenges. Here are some frequently asked questions:
How do I authenticate my API requests?
Authentication is handled through an API key, which must be included in the request URL. Ensure that your API key is kept secure and not exposed in public repositories.
What are the rate limits for API requests?
Rate limits vary depending on your subscription plan. Be sure to check the documentation for specific limits and adjust your application logic accordingly to avoid exceeding these limits.
How can I handle errors in API responses?
API responses may include error codes and messages. Implement error handling in your application to gracefully manage these scenarios and provide feedback to users.
Conclusion
In conclusion, the Metals-API is an invaluable resource for developers looking to fetch historical prices of the Moroccan Dirham and other metals. With its comprehensive features, including real-time rates, historical data, and various endpoints, developers can build powerful applications that provide critical financial insights. By understanding the API's capabilities and effectively utilizing its endpoints, developers can create solutions that meet the demands of the modern financial landscape. For more information, visit the Metals-API Website and explore the extensive documentation to get started on your integration journey.