OpenBB-finance/OpenBB · error · OpenBBError
Failed to fetch data from ECB. -> Status Code: {response.sta
Error message
Failed to fetch data from ECB. -> Status Code: {response.status_code} What it means
Raised by the ECB currency-reference-rates fetcher when GET https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml returns any status other than 200. The daily XML is the sole source for this endpoint, so a non-200 means the feed itself was unreachable, blocked, or moved.
Source
Thrown at openbb_platform/providers/ecb/openbb_ecb/models/currency_reference_rates.py:52
"""Transform query."""
return ECBCurrencyReferenceRatesQueryParams(**params)
@staticmethod
def extract_data(
query: ECBCurrencyReferenceRatesQueryParams,
credentials: dict[str, str] | None,
**kwargs: Any,
) -> dict:
"""Extract the raw data from the ECB website."""
# pylint: disable=import-outside-toplevel
import xmltodict
from openbb_core.provider.utils.helpers import make_request
results = {}
url = "https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml"
response = make_request(url)
if response.status_code != 200:
raise OpenBBError(
"Failed to fetch data from ECB."
+ f" -> Status Code: {response.status_code}"
)
data = xmltodict.parse(response.content)
rates_data = data["gesmes:Envelope"]["Cube"]["Cube"]["Cube"]
rates = {d["@currency"]: d["@rate"] for d in rates_data}
results["date"] = data["gesmes:Envelope"]["Cube"]["Cube"]["@time"]
results["EUR"] = 1
results.update(rates)
return results
@staticmethod
def transform_data(
query: ECBCurrencyReferenceRatesQueryParams, data: dict, **kwargs: Any
) -> ECBCurrencyReferenceRatesData:
"""Transform data."""
return ECBCurrencyReferenceRatesData.model_validate(data)View on GitHub (pinned to 3e071fcc2c)
Solutions
- Retry after a short backoff — 403/5xx from ECB is often transient rate-limiting.
- Cache the daily file yourself: it changes once per day (~16:00 CET), so fetch at most daily instead of per-request.
- Check https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml in a browser/curl from the same machine to confirm reachability and the actual status code.
- If behind a proxy, set HTTPS_PROXY env var so make_request goes through it; if blocked, switch provider or mirror the XML.
Example fix
# before
rates = obb.currency.reference_rates(provider="ecb")
# after
import time
from openbb_core.provider.utils.errors import OpenBBError
for attempt in range(3):
try:
rates = obb.currency.reference_rates(provider="ecb")
break
except OpenBBError as e:
if "Status Code" in str(e) and attempt < 2:
time.sleep(2 ** attempt)
continue
raise Defensive patterns
Strategy: retry
Validate before calling
import requests
def ecb_fx_feed_reachable() -> bool:
return requests.get("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml", timeout=10).status_code == 200 Try / catch
import time
from openbb_core.provider.utils.errors import OpenBBError
for attempt in range(4):
try:
rates = obb.currency.reference_rates(provider="ecb")
break
except OpenBBError as e:
if "Status Code" in str(e) and attempt < 3:
time.sleep(2 ** attempt)
continue
raise Prevention
- Fetch the daily FX XML at most once per day and cache it yourself.
- Add exponential backoff for 403/5xx from ecb.europa.eu.
- Configure proxy env vars in corporate networks so requests aren't intercepted.
When it happens
Trigger: Calling obb.currency.reference_rates(provider="ecb") while ecb.europa.eu returns 403 (bot-blocking/rate-limiting from cloud egress IPs), 5xx during ECB site maintenance, or a proxy/firewall in the environment returning 407/502.
Common situations: CI runners and containers whose shared IPs get throttled by the ECB WAF; corporate proxies that intercept the request; transient ECB outages; running bulk jobs that refresh the daily rates many times per hour.
Related errors
- Congress.gov API rate limit exceeded. Please wait a moment a
- Error fetching data: {e}
- Failed to get instruments -> {e.__class__.__name__}: {e}
- Invalid JSON response from ECB
- e
AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14).
Data as JSON: /api/errors/c0d8ae803f44dc14.
Report an issue: GitHub.