OpenBB-finance/OpenBB · error · OpenBBError

The temporary EconDB token could not be retrieved. Please tr

Error message

The temporary EconDB token could not be retrieved. Please try again later or provide your own token. Sign-up at: https://www.econdb.com/ Your IP address may have been flagged by Cloudflare.

What it means

create_token fetches a free temporary token from https://www.econdb.com/user/create_token/ so unauthenticated calls can proceed; the response callback tries response.json() and raises OpenBBError when parsing fails. A non-JSON body at this endpoint is almost always a Cloudflare challenge/block page, meaning your IP has been flagged or EconDB is refusing automated token creation.

Source

Thrown at openbb_platform/providers/econdb/openbb_econdb/utils/helpers.py:402

    if unit == "trillions":
        return 1000000000000
    return 1


def get_indicator_countries(indicator: str) -> list[str]:
    """Get the list of countries for a given indicator."""
    return INDICATOR_COUNTRIES.get(indicator, [])


async def create_token(use_cache: bool = True) -> str:
    """Create a temporary token for the EconDB API."""

    async def _callback(_response, _):
        """Response callback function."""
        try:
            return await _response.json()
        except Exception as e:
            raise OpenBBError(
                "The temporary EconDB token could not be retrieved."
                + " Please try again later or provide your own token."
                + " Sign-up at: https://www.econdb.com/"
                + " Your IP address may have been flagged by Cloudflare."
            ) from e

    response: dict | list[dict] = {}
    url = "https://www.econdb.com/user/create_token/?reset=0"
    if use_cache:
        cache_dir = f"{get_user_cache_directory()}/http/econdb_indicators_temp_token"
        async with CachedSession(
            cache=SQLiteBackend(cache_dir, expire_after=3600 * 12)
        ) as session:
            try:
                response = await amake_request(
                    url,
                    response_callback=_callback,
                    session=session,  # type: ignore

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Register at https://www.econdb.com/ and set your own key as the 'econdb_api_key' credential for the provider.
  2. Retry later from the same IP once the Cloudflare flag expires, or from a different network.
  3. Clear the cached token dir (~/.cache/openbb/http/econdb_indicators_temp_token) so a stale bad response is not reused.
  4. Route automated workloads through a residential/office IP instead of a datacenter IP.

Example fix

# before - relies on temp token (Cloudflare-blocked on datacenter IP)
obb.economy.yield_curve(provider='econdb', country='united_states')

# after - supply your own key once
obb.user.credentials.put('econdb_api_key', '<your-key-from-econdb.com>')
obb.economy.yield_curve(provider='econdb', country='united_states')
Defensive patterns

Strategy: retry

Validate before calling

from openbb_core.app.provider.object import get_credentials  # or read your config
if not (obb.user.credentials.get('econdb_api_key')):
    logger.warning('no econdb_api_key set - temp-token path may hit Cloudflare blocks')

Try / catch

from openbb_core.app.model.obbject import OpenBBError
try:
    res = obb.economy.yield_curve(provider='econdb', country='united_states', use_cache=False)
except OpenBBError as e:
    if 'temporary EconDB token' in str(e):
        # register at econdb.com and set your own key, then retry
        raise RuntimeError('set obb.user.credentials econdb_api_key') from e
    raise

Prevention

When it happens

Trigger: Any econdb fetcher call (yield_curve, economy/econdb series endpoints) without an econdb_api_key credential while the token endpoint returns HTML — datacenter IPs, VPNs, and high request volume are frequently flagged. The token is cached for 12h, so failures can repeat until the cache entry expires or the block lifts.

Common situations: CI runners and cloud servers on shared IPs; aggressive scraping triggering Cloudflare; users who never registered a key relying on the temp-token path.

Related errors


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