SAMA Historical Data API: Timeseries, Charts & Downloads

SAMA Historical Data API: Timeseries, Charts & Downloads

Introduction

In the fast-paced world of finance, access to accurate and timely interest rate data is crucial for developers, economists, and financial analysts. The SAMA Historical Data API from interestratesapi.com provides a robust solution for retrieving interest rate data, including central bank rates, interbank rates, and financial time series analysis. This blog post will delve into the capabilities of the SAMA Historical Data API, focusing on the SAMA_RATE, which represents the Saudi Central Bank Repo Rate. We will explore various endpoints, practical implementation examples, and best practices for utilizing this API effectively.

Understanding the SAMA_RATE

The SAMA_RATE is a critical indicator of the monetary policy stance of the Saudi Arabian Monetary Authority (SAMA). It reflects the interest rate at which commercial banks can borrow from the central bank, influencing lending rates across the economy. Accessing historical data for the SAMA_RATE allows developers and analysts to conduct time series analysis, evaluate trends, and make informed financial decisions.

API Overview

The SAMA Historical Data API offers several endpoints that cater to different data retrieval needs. Below is a summary of the key endpoints:

  • /api/v1/symbols: Retrieve a catalogue of available rate symbols.
  • /api/v1/latest: Get the latest value for specified symbols.
  • /api/v1/historical: Fetch the value of a symbol on a specific date.
  • /api/v1/timeseries: Retrieve a series of values between two dates.
  • /api/v1/fluctuation: Get change statistics over a specified range.
  • /api/v1/ohlc: Obtain OHLC candlestick data for visual analysis.
  • /api/v1/convert: Compare loan interest costs between two rates.

Retrieving Time Series Data with the /timeseries Endpoint

The /timeseries endpoint is particularly valuable for developers looking to analyze trends over time. This endpoint allows users to fetch a series of values for the SAMA_RATE between two specified dates. The ability to retrieve multi-year data enables comprehensive analysis and forecasting.

To use the /timeseries endpoint, you need to specify the start and end dates, as well as the symbols you wish to retrieve. Here’s an example of how to make a request:

curl "https://interestratesapi.com/api/v1/timeseries?start=2025-05-15&end=2026-05-15&symbols=SAMA_RATE&api_key=YOUR_KEY"

The expected JSON response will look like this:


{
"success": true,
"base": "USD",
"start_date": "2025-05-15",
"end_date": "2026-05-15",
"rates": {
"SAMA_RATE": {
"2025-01-02": 5.33,
"2025-01-03": 5.33,
"2025-01-06": 5.33
}
},
"frequencies": {
"SAMA_RATE": "daily"
},
"currencies": {
"SAMA_RATE": "USD"
}
}

In this response, the rates object contains the SAMA_RATE values for each date within the specified range. The frequencies field indicates that the data is available on a daily basis, which is essential for time series analysis.

Point-in-Time Lookups with the /historical Endpoint

For scenarios where a specific date's interest rate is required, the /historical endpoint is invaluable. This endpoint allows users to retrieve the SAMA_RATE for a given date, accommodating edge cases such as weekends and holidays.

To fetch the historical rate for a specific date, you can use the following cURL command:

curl "https://interestratesapi.com/api/v1/historical?date=2025-06-15&symbols=SAMA_RATE&api_key=YOUR_KEY"

The JSON response will provide the rate for that date:


{
"success": true,
"date": "2025-06-15",
"base": "USD",
"rates": {
"SAMA_RATE": 5.33
},
"currencies": {
"SAMA_RATE": "USD"
}
}

This endpoint is particularly useful for financial analysts who need to assess the impact of historical interest rates on economic indicators or financial models.

Visualizing Data with the /ohlc Endpoint

To create visual representations of interest rate data, the /ohlc endpoint provides OHLC (Open, High, Low, Close) candlestick data. This is essential for traders and analysts who rely on visual data to make informed decisions.

To retrieve OHLC data for the SAMA_RATE, you can use the following cURL command:

curl "https://interestratesapi.com/api/v1/ohlc?symbols=SAMA_RATE&period=monthly&start=2025-05-15&end=2026-05-15&api_key=YOUR_KEY"

The expected response will look like this:


{
"success": true,
"period": "monthly",
"start_date": "2025-05-15",
"end_date": "2026-05-15",
"rates": {
"SAMA_RATE": [
{
"period": "2025-01",
"open": 5.50,
"high": 5.50,
"low": 5.33,
"close": 5.33,
"data_points": 23
}
]
}
}

With this data, you can easily integrate it into visualization libraries such as Chart.js or Plotly to create interactive charts. Below is a simple example of how to use Chart.js to visualize the SAMA_RATE data:


const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'candlestick',
data: {
datasets: [{
label: 'SAMA_RATE',
data: [
{ x: '2025-01', o: 5.50, h: 5.50, l: 5.33, c: 5.33 }
]
}]
},
options: {
scales: {
x: {
type: 'time'
}
}
}
});

Building a Data Pipeline with Python

For developers looking to automate data retrieval and analysis, building a data pipeline using Python is an effective approach. Below is a complete example of how to fetch SAMA_RATE data, store it in a Pandas DataFrame, and export it to CSV or Parquet format.

import requests
import pandas as pd

# Fetch time series data
response = requests.get(
'https://interestratesapi.com/api/v1/timeseries',
params=dict(start='2025-05-15', end='2026-05-15', symbols='SAMA_RATE', api_key='YOUR_KEY')
)

data = response.json()

# Convert to DataFrame
dates = data['rates']['SAMA_RATE'].keys()
values = data['rates']['SAMA_RATE'].values()
df = pd.DataFrame({'Date': dates, 'SAMA_RATE': values})

# Export to CSV
df.to_csv('sama_rate_data.csv', index=False)

# Export to Parquet
df.to_parquet('sama_rate_data.parquet', index=False)

This pipeline allows for efficient data handling and storage, making it easier to perform further analysis or integrate with other systems.

Common Pitfalls in Time Series Analysis

When working with time series data, developers should be aware of several common pitfalls:

  • Missing Dates: Ensure that your analysis accounts for weekends and holidays when data may not be available.
  • Frequency Considerations: Understand the implications of using daily versus monthly data, as this can significantly impact your analysis.
  • Data Points Interpretation: Be cautious when interpreting the data_points field in the OHLC response, as it indicates the number of data points used to calculate the OHLC values.

Error Handling and Best Practices

When working with the SAMA Historical Data API, it is essential to implement robust error handling. Common error responses include:

  • 401: Missing or invalid API key.
  • 403: Account without an active plan.
  • 404: No symbols matched or no data for the requested date/range.
  • 422: Validation error, such as an incorrect date format.
  • 429: Request quota exhausted.

Implementing proper error handling will ensure that your application can gracefully handle issues and provide meaningful feedback to users.

Conclusion

The SAMA Historical Data API from interestratesapi.com offers a comprehensive suite of endpoints for accessing interest rate data, enabling developers and analysts to perform in-depth financial analysis. By leveraging the capabilities of this API, users can efficiently retrieve historical data, visualize trends, and build robust financial applications. Whether you are conducting time series analysis or integrating data into your fintech solutions, the SAMA_RATE provides valuable insights into the monetary landscape of Saudi Arabia.

For more information on how to get started, visit Get started with Interest Rates API and Explore Interest Rates API features.

Ready to get started?

Get your API key and start validating bank data in minutes.

Get API Key

Related posts