Fetcher Module

wbdata.fetcher: retrieve and cache queries

Result

Bases: List[Dict[str, Any]]

List with a last_updated attribute. The last_updated attribute is either a datetime.datetime object or None.

Fetcher dataclass

An object for making cached HTTP requests.

Parameters:
  • cache (MutableMapping[CacheKey, str]) –

    a dictlike container for caching responses

  • session (Session, default: Session() ) –

    a requests session to use to make the requests, if None, create a new session

fetch(url, params=None, skip_cache=False)

Fetch data from the World Bank API or from cache.

Given the base url, keep fetching results until there are no more pages.

Parameters:
  • url (str) –

    the base url to be queried

  • params (Union[Dict[str, Any], None], default: None ) –

    a dictionary of GET arguments

  • skip_cache (bool, default: False ) –

    bool: use the cache

Returns:
  • Result

    a list of dictionaries containing the response to the query