OpenBB-finance/OpenBB · error · OpenBBError

Failed to fetch data from the Federal Reserve API.

Error message

Failed to fetch data from the Federal Reserve API.

What it means

Raised as OpenBBError by FederalReservePrimaryDealerFailsFetcher.aextract_data when any exception escapes the multi-request fetch loop (the model issues several amake_request calls to markets.newyorkfed.org timeseries endpoints and concatenates 'pd.timeseries' lists). The bare message hides the cause, but the original exception is chained via `from e`.

Source

Thrown at openbb_platform/providers/federal_reserve/openbb_federal_reserve/models/primary_dealer_fails.py:108

            data = response.get("pd", {}).get("timeseries", [])  # type: ignore
            if query.start_date and query.start_date < datetime(2013, 4, 1).date():
                # The data is broken into different series and the structure of the data is different over time.
                if query.start_date < datetime(2001, 7, 1).date():
                    url2 = (
                        "https://markets.newyorkfed.org/api/pd/get/SBP2001/timeseries/PDFASUFDA_PDFASUFRA"
                        + "_PDFASFAFDA_PDFASFAFRA_PDFASMBFDA_PDFASMBFRA.json"
                    )
                    response = await amake_request(url2, **kwargs)
                    data += response.get("pd", {}).get("timeseries", [])  # type: ignore
                url = (
                    "https://markets.newyorkfed.org/api/pd/get/SBP2013/timeseries/"
                    + "PDFASCFRA_PDFASCFDA_PDFASFAFRA_PDFASFAFDA_PDFASMBFRA_PDFASMBFDA_PDFASUFRA_PDFASUFDA.json"
                )
                response = await amake_request(url, **kwargs)
                data += response.get("pd", {}).get("timeseries", [])  # type: ignore
            return data
        except Exception as e:  # pylint: disable=broad-except
            raise OpenBBError(
                "Failed to fetch data from the Federal Reserve API."
            ) from e

    @staticmethod
    def transform_data(
        query: FederalReservePrimaryDealerFailsQueryParams,
        data: list[dict],
        **kwargs: Any,
    ) -> list[FederalReservePrimaryDealerFailsData]:
        """Transform the raw data into the standard format."""
        # pylint: disable=import-outside-toplevel
        from pandas import NA, DataFrame, concat, to_datetime

        if not data:
            raise EmptyDataError("No data returned from the Federal Reserve API.")

        df = DataFrame(data)
        df["title"] = df.keyid.map(FAILS_SERIES_TO_TITLE)

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Inspect the chained exception (`e.__cause__`) for the real failure — the wrapper message alone is not diagnostic.
  2. Retry the request; transient network errors are the most common cause.
  3. Confirm the URL(s) respond in a browser/curl (the PDFAS* timeseries endpoints under /api/pd/get/SBP2013/timeseries/).
  4. If responses come back 200 but the error persists, the JSON shape likely changed — open a provider issue.
Defensive patterns

Strategy: retry

Try / catch

for attempt in range(3):
    try:
        res = obb.economy.fed.primary_dealer_fails()
        break
    except OpenBBError as e:
        cause = e.__cause__
        if attempt < 2 and not isinstance(cause, (KeyError, AttributeError)):
            continue  # transient network error -> retry
        raise RuntimeError('primary dealer fails fetch failed') from e

Prevention

When it happens

Trigger: Network failure, timeout, non-200 response, or malformed JSON while fetching one of the primary-dealer fails timeseries URLs; also any KeyError/AttributeError if the API response shape changes and .get('pd', {}).get('timeseries', []) assumptions break.

Common situations: Transient connectivity problems to markets.newyorkfed.org; proxy/firewall blocking the Fed API; upstream API shape change; rate limiting during backfills.

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/f58980026d47b4c0. Report an issue: GitHub.