Advanced API Reference

The following section outlines the API of gd.py for advanced usage.

HTTP Client

class gd.HTTPClient(*, url: Union[str, yarl.URL] = 'http://www.boomlings.com/database', proxy: Optional[str] = None, proxy_auth: Optional[aiohttp.helpers.BasicAuth] = None, timeout: Union[float, int] = 150, game_version: gd.converters.GameVersion = <GameVersion major=2 minor=1>, binary_version: gd.converters.Version = <Version major=3 minor=5>, gd_world: bool = False, forwarded_for: Optional[str] = None, use_user_agent: bool = False)[source]
async download(url: Union[yarl.URL, str], method: str = 'GET', chunk_size: int = 65536, with_bar: bool = False, close: bool = False, file: Optional[Union[str, pathlib.Path, IO]] = None, **kwargs)Optional[bytes][source]

Download the file at url with method.

Parameters
  • method (str) – HTTP method to send request with. Default is GET.

  • url (Union[URL, str]) – URL to request file from.

  • chunk_size (int) – Amount of data to read for one chunk. -1 to read until EOF.

  • with_bar (bool) – Whether to show progress bar when downloading. False by default.

  • close (bool) – Whether to close the underlying file after finishing.

  • file (Optional[Union[str, Path, IO]]) – File to write downloaded data to. If not given, this function returns all the data as the result.

  • **kwargs – Keywoard arguments to pass to aiohttp.ClientSession.request().

Returns

Data downloaded, if file is not given or None. Otherwise, returns None.

Return type

Optional[bytes]

Session

class gd.Session(**http_args)[source]