{"record":{"id":"f58980026d47b4c0","repo":"OpenBB-finance/OpenBB","slug":"failed-to-fetch-data-from-the-federal-reserve-api","errorCode":null,"errorMessage":"Failed to fetch data from the Federal Reserve API.","messagePattern":"Failed to fetch data from the Federal Reserve API\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/federal_reserve/openbb_federal_reserve/models/primary_dealer_fails.py","lineNumber":108,"sourceCode":"            data = response.get(\"pd\", {}).get(\"timeseries\", [])  # type: ignore\n            if query.start_date and query.start_date < datetime(2013, 4, 1).date():\n                # The data is broken into different series and the structure of the data is different over time.\n                if query.start_date < datetime(2001, 7, 1).date():\n                    url2 = (\n                        \"https://markets.newyorkfed.org/api/pd/get/SBP2001/timeseries/PDFASUFDA_PDFASUFRA\"\n                        + \"_PDFASFAFDA_PDFASFAFRA_PDFASMBFDA_PDFASMBFRA.json\"\n                    )\n                    response = await amake_request(url2, **kwargs)\n                    data += response.get(\"pd\", {}).get(\"timeseries\", [])  # type: ignore\n                url = (\n                    \"https://markets.newyorkfed.org/api/pd/get/SBP2013/timeseries/\"\n                    + \"PDFASCFRA_PDFASCFDA_PDFASFAFRA_PDFASFAFDA_PDFASMBFRA_PDFASMBFDA_PDFASUFRA_PDFASUFDA.json\"\n                )\n                response = await amake_request(url, **kwargs)\n                data += response.get(\"pd\", {}).get(\"timeseries\", [])  # type: ignore\n            return data\n        except Exception as e:  # pylint: disable=broad-except\n            raise OpenBBError(\n                \"Failed to fetch data from the Federal Reserve API.\"\n            ) from e\n\n    @staticmethod\n    def transform_data(\n        query: FederalReservePrimaryDealerFailsQueryParams,\n        data: list[dict],\n        **kwargs: Any,\n    ) -> list[FederalReservePrimaryDealerFailsData]:\n        \"\"\"Transform the raw data into the standard format.\"\"\"\n        # pylint: disable=import-outside-toplevel\n        from pandas import NA, DataFrame, concat, to_datetime\n\n        if not data:\n            raise EmptyDataError(\"No data returned from the Federal Reserve API.\")\n\n        df = DataFrame(data)\n        df[\"title\"] = df.keyid.map(FAILS_SERIES_TO_TITLE)","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/federal_reserve/openbb_federal_reserve/models/primary_dealer_fails.py#L90-L126","documentation":"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`.","triggerScenarios":"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.","commonSituations":"Transient connectivity problems to markets.newyorkfed.org; proxy/firewall blocking the Fed API; upstream API shape change; rate limiting during backfills.","solutions":["Inspect the chained exception (`e.__cause__`) for the real failure — the wrapper message alone is not diagnostic.","Retry the request; transient network errors are the most common cause.","Confirm the URL(s) respond in a browser/curl (the PDFAS* timeseries endpoints under /api/pd/get/SBP2013/timeseries/).","If responses come back 200 but the error persists, the JSON shape likely changed — open a provider issue."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    try:\n        res = obb.economy.fed.primary_dealer_fails()\n        break\n    except OpenBBError as e:\n        cause = e.__cause__\n        if attempt < 2 and not isinstance(cause, (KeyError, AttributeError)):\n            continue  # transient network error -> retry\n        raise RuntimeError('primary dealer fails fetch failed') from e","preventionTips":["Retry with backoff for transient network failures to markets.newyorkfed.org.","Inspect e.__cause__ — the wrapper message carries no diagnostic detail.","Cache responses; the series updates weekly, so long cache TTLs reduce exposure."],"tags":["federal-reserve","network","primary-dealers","wrapped-exception"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}