{"record":{"id":"2e5e20abfd2fd4a0","repo":"OpenBB-finance/OpenBB","slug":"the-request-has-generated-a-url-that-is-too-long","errorCode":null,"errorMessage":"The request has generated a url that is too long. Please reduce the number of symbols or countries and try again.","messagePattern":"The request has generated a url that is too long\\. Please reduce the number of symbols or countries and try again\\.","errorType":"exception","errorClass":"OpenBBError","httpStatus":null,"severity":"error","filePath":"openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py","lineNumber":313,"sourceCode":"            )\n            error_message = (\n                \"No valid combination of indicator symbols and countries were supplied.\"\n                + f\"\\nValid countries for '{query.symbol}' are: {symbol_message}\"\n                + f\"\\nIf the symbol - {query.symbol} - is missing a country code.\"\n                + \" Please add the two-letter country code or use the country parameter.\"\n                + \"\\nIf already included, add '~' to the end of the symbol.\"\n            )\n            raise OpenBBError(error_message)\n        url = base_url + f\"%5B{','.join(new_symbols)}%5D&format=json&token={token}\"\n        if query.start_date:\n            url += f\"&from={query.start_date}\"\n        if query.end_date:\n            url += f\"&to={query.end_date}\"\n        # If too many indicators and countries are supplied the request url will be too long.\n        # Instead of chunking we request the user reduce the number of indicators and countries.\n        # This might be able to nudge higher, but it is a safe limit for all operating systems.\n        if len(url) > 2000:\n            raise OpenBBError(\n                \"The request has generated a url that is too long.\"\n                + \" Please reduce the number of symbols or countries and try again.\"\n            )\n\n        async def response_callback(response, session):\n            \"\"\"Response callback.\"\"\"\n            if response.status != 200:\n                warn(f\"Error: {response.status} - {response.reason}\")\n            response = await response.json()\n            if response.get(\"results\"):\n                data.extend(response[\"results\"])\n            while response.get(\"next\"):\n                response = await session.get(response[\"next\"])\n                response = await response.json()\n                if response.get(\"results\"):\n                    data.extend(response[\"results\"])\n            return data\n","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/providers/econdb/openbb_econdb/models/economic_indicators.py#L295-L331","documentation":"OpenBBError guard in EconDB extract: after URL-building, if the constructed GET URL exceeds 2000 characters the fetcher refuses to send it. The URL length grows with the number of symbols times expanded countries, plus token and date params; 2000 is a deliberately safe cross-OS cap, and the provider chose to error rather than chunk.","triggerScenarios":"Calling obb.economy.indicator(provider='econdb', symbol=<many indicators>, country='all' or a large group like 'g20') — each indicator×country combination is embedded in the URL, easily blowing past 2000 chars.","commonSituations":"Batch jobs requesting dozens of indicators across all countries; group aliases ('all', 'g20') silently expanding to 20+ countries per symbol; long date params adding the final overflow.","solutions":["Reduce the request size: fewer symbols per call, fewer/explicit countries instead of 'all'/'g20'.","Loop client-side: chunk symbols (e.g. 5 at a time) and/or countries, then concatenate the DataFrames.","Trim date ranges if they are the marginal overflow."],"exampleFix":"# before\nres = obb.economy.indicator(provider=\"econdb\", symbol=\",\".join(50_symbols), country=\"all\")\n\n# after\nimport pandas as pd\nframes = []\nfor i in range(0, len(symbols), 5):\n    frames.append(obb.economy.indicator(provider=\"econdb\", symbol=\",\".join(symbols[i:i+5]), country=\"us\").to_df())\nres = pd.concat(frames)","handlingStrategy":"validation","validationCode":"MAX_URL = 2000\n\ndef chunk_requests(symbols: list[str], countries: list[str]) -> list[tuple[list[str], list[str]]]:\n    # base URL + token + dates leave ~1200 chars; each symbol-country pair ~8-20 chars\n    budget = 1200\n    chunks, cur_syms, cur_len = [], [], 0\n    per_country = max(1, budget // (len(symbols) * 12))\n    for i in range(0, len(countries), per_country):\n        chunks.append((symbols, countries[i:i + per_country]))\n    return chunks","typeGuard":null,"tryCatchPattern":"from openbb_core.provider.utils.errors import OpenBBError\ntry:\n    res = obb.economy.indicator(provider=\"econdb\", symbol=syms, country=cs)\nexcept OpenBBError as e:\n    if \"url that is too long\" in str(e):\n        res = pd.concat([obb.economy.indicator(provider=\"econdb\", symbol=\",\".join(syms[i:i+5]), country=cs).to_df() for i in range(0, len(syms), 5)])\n    else:\n        raise","preventionTips":["Avoid country='all'/'g20' with many symbols — expand and chunk client-side.","Keep each request to a handful of symbols; concatenate results yourself."],"tags":["econdb","url-length","batching","rate-limit"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}