Getting started overview
The Bank of Russia offers public access to its official daily exchange rates, key interest rates, and other financial data. For developers seeking to integrate official Russian Ruble exchange rates into applications, the Bank of Russia provides an XML-based API. This API is freely accessible without the need for an account registration or API keys, simplifying the initial setup process. Data is updated daily, reflecting the official rates set by the Bank of Russia.
This guide focuses on quickly getting started with retrieving daily foreign exchange rates, which is one of the primary uses for the Bank of Russia's publicly available data. While the API is functional, developers should note that its reliance on XML may require additional parsing compared to more contemporary JSON-based APIs offered by other financial institutions or data providers.
The core process involves constructing a URL with specific parameters for the desired date and currency, then making an HTTP GET request to retrieve the XML response. This response contains the exchange rates against the Russian Ruble for various foreign currencies.
Quick Reference Guide
| Step | What to Do | Where |
|---|---|---|
| 1. Understand Access | Confirm no account/keys are needed for public data. | Bank of Russia Daily Exchange Rates |
| 2. Formulate Request | Construct the API endpoint URL with date parameters. | Bank of Russia API Reference |
| 3. Make Call | Send an HTTP GET request to the formed URL. | Your preferred programming language/tool (e.g., cURL, Python requests) |
| 4. Parse Response | Process the XML response to extract exchange rate data. | Your programming language's XML parsing library |
Create an account and get keys
For accessing the Bank of Russia's official daily exchange rates and other publicly available financial data, there is no requirement to create an account or obtain API keys. All data relevant to the daily exchange rates is made publicly available by the Bank of Russia. This simplifies the onboarding process significantly, as developers can proceed directly to making requests without any prerequisites related to registration or credential management.
This approach aligns with the Bank of Russia's mission to provide transparent access to key financial indicators. Unlike many commercial APIs that require authentication via OAuth 2.0 tokens or API keys for rate limiting and access control, the Bank of Russia's public data endpoints are open. Developers can initiate requests immediately upon understanding the API's structure and available parameters, as detailed in the Bank of Russia's web daily exchange rates documentation.
While this open access is convenient, it also means that developers are responsible for managing their own request frequency to avoid overwhelming the server, though specific rate limits are not typically published for these public endpoints. Best practices for interacting with public APIs, such as implementing exponential backoff for retries and caching data where appropriate, are still recommended to ensure efficient use and prevent potential service disruption for your application or other users.
Your first request
To make your first request to the Bank of Russia's exchange rate API, you will construct a simple HTTP GET request to a specific URL. The API provides daily exchange rates for various foreign currencies against the Russian Ruble. The primary endpoint for daily rates allows you to specify a date to retrieve historical data or omit it for the most recent available rates.
API Endpoint Structure
The base URL for daily exchange rates is typically:
https://www.cbr.ru/scripts/XML_daily.asp
To request rates for a specific date, append the ?date_req=DD/MM/YYYY parameter. For example, to get rates for May 29, 2026:
https://www.cbr.ru/scripts/XML_daily.asp?date_req=29/05/2026
The date format DD/MM/YYYY is crucial for correct parsing by the API. If the date_req parameter is omitted, the API returns the exchange rates for the current or most recently updated business day.
Example Request (cURL)
You can test this endpoint directly using cURL from your terminal:
curl "https://www.cbr.ru/scripts/XML_daily.asp?date_req=29/05/2026"
This command will output an XML document containing the exchange rates for May 29, 2026, directly to your console.
Example Request (Python)
Using Python with the requests library and xml.etree.ElementTree for parsing:
import requests
import xml.etree.ElementTree as ET
def get_cbr_exchange_rates(date_str=None):
base_url = "https://www.cbr.ru/scripts/XML_daily.asp"
params = {}
if date_str:
params['date_req'] = date_str
try:
response = requests.get(base_url, params=params)
response.raise_for_status() # Raise an HTTPError for bad responses (4xx or 5xx)
root = ET.fromstring(response.content)
print(f"Exchange Rates for: {root.get('Date')}")
for valute in root.findall('Valute'):
char_code = valute.find('CharCode').text
nominal = valute.find('Nominal').text
name = valute.find('Name').text
value = valute.find('Value').text
print(f" {nominal} {name} ({char_code}): {value} RUB")
except requests.exceptions.HTTPError as e:
print(f"HTTP error occurred: {e}")
except requests.exceptions.ConnectionError as e:
print(f"Connection error occurred: {e}")
except requests.exceptions.Timeout as e:
print(f"Timeout error occurred: {e}")
except requests.exceptions.RequestException as e:
print(f"An error occurred: {e}")
except ET.ParseError as e:
print(f"Error parsing XML: {e}")
# Get rates for a specific date
get_cbr_exchange_rates("29/05/2026")
# Get current rates
# get_cbr_exchange_rates()
This Python script defines a function get_cbr_exchange_rates that takes an optional date_str. It constructs the URL, makes the request, and then parses the XML response to print the exchange rates in a human-readable format. The xml.etree.ElementTree module is a standard library for parsing XML in Python, and its usage is demonstrated here to navigate the XML structure and extract relevant data points such as CharCode, Nominal, Name, and Value.
Expected XML Response Structure
A typical XML response will look like this (abbreviated):
<ValCurs Date="29.05.2026" name="Foreign Currency Market">
<Valute ID="R01010">
<NumCode>826</NumCode>
<CharCode>GBP</CharCode>
<Nominal>1</Nominal>
<Name>Фунт стерлингов СК</Name>
<Value>115,2345</Value>
</Valute>
<Valute ID="R01020A">
<NumCode>036</NumCode>
<CharCode>AUD</CharCode>
<Nominal>1</Nominal>
<Name>Австралийский доллар</Name>
<Value>55,6789</Value>
</Valute>
<!-- More Valute elements -->
</ValCurs>
Each <Valute> element represents a specific foreign currency. Key fields include:
ID: Unique identifier for the currency.NumCode: Numeric code of the currency (e.g., ISO 4217 numeric code).CharCode: Alphabetic code of the currency (e.g., ISO 4217 alpha code like 'USD', 'EUR').Nominal: The number of foreign currency units for which the rate is given (e.g., '1' for 1 USD, '10' for 10 JPY).Name: Full name of the currency in Russian.Value: The exchange rate of the foreign currency unit against the Russian Ruble. Note that the decimal separator is a comma (,), which is common in Russian numerical formatting. This will need to be handled during parsing if you intend to convert it to a float in programming languages that typically use a period (.) as a decimal separator.
For more details on XML parsing, refer to the Python documentation for xml.etree.ElementTree, or similar XML parsing libraries in other programming languages.
Common next steps
After successfully making your first request and parsing the XML response, consider these common next steps to integrate Bank of Russia data more robustly into your applications:
-
Error Handling and Robustness: Implement comprehensive error handling for network issues, malformed responses, or unexpected data. While the Bank of Russia API is generally stable, external API integrations benefit from retry mechanisms (e.g., with exponential backoff) and clear logging of failures. For example, consider how your application will behave if the API returns an empty response or an unparseable XML document.
-
Data Storage and Caching: Since exchange rates are updated daily, fetching them on every user request might be inefficient. Implement a caching strategy to store fetched data for at least 24 hours. This reduces the load on the Bank of Russia's servers and improves your application's performance. You could store data in a database, a local file, or an in-memory cache.
-
Data Transformation: The API returns rates with a comma as a decimal separator and often for a nominal value other than one (e.g., 100 Japanese Yen). Your application will likely need to transform these values into a standard decimal format (e.g., using a period as a separator) and adjust for the nominal value to get a 'per unit' rate. For example, if 100 JPY = 65.0000 RUB, then 1 JPY = 0.650000 RUB.
-
Automation and Scheduling: Automate the daily retrieval of exchange rates using scheduled tasks (e.g., cron jobs on Linux, Windows Task Scheduler, or cloud-based schedulers like Google Cloud Scheduler or AWS EventBridge Scheduler). This ensures your application always has access to the most current official rates without manual intervention.
-
Monitoring: Set up monitoring for your data retrieval process. This could involve checking logs for errors, verifying that new data is being fetched daily, and alerting you if the API becomes unresponsive or returns unexpected data. Tools like Prometheus or Grafana can be used for more advanced monitoring setups.
-
Explore Other Data: The Bank of Russia provides other publicly available data beyond daily exchange rates, such as key interest rates, inflation data, and banking statistics. Explore the Bank of Russia's official documentation to see if other datasets are relevant for your application.
Troubleshooting the first call
When making your first call to the Bank of Russia's exchange rate API, you might encounter some common issues. Here’s a guide to troubleshooting them:
-
Incorrect Date Format:
- Issue: The API expects dates in
DD/MM/YYYYformat (e.g.,29/05/2026). UsingMM-DD-YYYYorYYYY-MM-DDwill result in an error or no data. - Solution: Double-check your date string. Ensure it strictly adheres to the
DD/MM/YYYYformat. For example, in Python, you might usedatetime.strftime("%d/%m/%Y")to format dates correctly.
- Issue: The API expects dates in
-
Network Connectivity Issues:
- Issue: Your application cannot reach the Bank of Russia's server, leading to connection timeouts or host not found errors.
- Solution: Verify your internet connection. Try pinging
www.cbr.rufrom your terminal. Check if any firewalls or proxy settings are blocking outgoing HTTP requests from your environment. Usecurl -vto get more verbose output on network connection attempts.
-
XML Parsing Errors:
- Issue: Your XML parser reports errors like "malformed XML" or "unexpected end of file." This can happen if the response is not valid XML or is truncated.
- Solution: First, inspect the raw response content. Print the entire raw HTTP response body to see exactly what the API is returning. Sometimes, the API might return an HTML error page instead of XML if there's an internal server issue or an invalid request. Ensure your XML parsing library is robust and handles potential encoding issues (the API typically uses Windows-1251 or UTF-8).
-
No Data for Specific Date:
- Issue: The API returns an empty
<ValCurs>element or no<Valute>elements for a requested date. This usually means there are no official rates published for that specific day. - Solution: The Bank of Russia does not publish exchange rates on weekends or public holidays. If you request a date that falls on one of these, you might receive an empty response or the rates for the preceding business day if no date is specified. Try requesting a recent weekday date to confirm the API is working. Implement logic to handle cases where no rates are returned for a given date, perhaps by falling back to the previous business day's rates.
- Issue: The API returns an empty
-
Incorrect URL or Endpoint:
- Issue: Receiving a 404 Not Found or similar HTTP error.
- Solution: Double-check the API endpoint URL against the Bank of Russia's official documentation. Ensure there are no typos in the domain or path. The correct path for daily exchange rates is
/scripts/XML_daily.asp.
-
Decimal Separator for Values:
- Issue: When parsing the
<Value>field, your programming language might throw an error when trying to convert"115,2345"to a float. - Solution: Remember that Russian numerical formatting uses a comma (
,) as a decimal separator. Before converting to a float in languages like Python or JavaScript, replace the comma with a period (.). For example,value_str.replace(',', '.').
- Issue: When parsing the
By systematically checking these potential issues, you should be able to resolve most problems encountered during your initial integration with the Bank of Russia's exchange rate API.