Skip to content

🧠 DogeAPI

The DogeAPI class provides a unified interface to all API endpoints in the DOGE SDK.

It wraps the lower-level client and injects SavingsAPI, and PaymentsAPI — all using a shared session and common flags.


📦 Class Reference

DogeAPI(fetch_all: bool = False, output_pydantic: bool = True, handle_response: bool = True, run_async: bool = False, client: Optional[DogeAPIClient] = None, **client_kwargs)

Unified entrypoint for interacting with all DOGE endpoints.

ATTRIBUTE DESCRIPTION
client

Shared client instance used across all endpoint classes.

TYPE: DogeAPIClient

savings

Access to /savings endpoints.

TYPE: SavingsAPI

payments

Access to /payments endpoints.

TYPE: PaymentsAPI

PARAMETER DESCRIPTION

fetch_all

Automatically fetch all pages for paginated endpoints.

TYPE: bool DEFAULT: False

output_pydantic

If True, return Pydantic models. If False, return plain dicts with .export().

TYPE: bool DEFAULT: True

handle_response

If True, decode responses. If False, return raw httpx.Response.

TYPE: bool DEFAULT: True

run_async

If True, use asyncio-based pagination (if supported).

TYPE: bool DEFAULT: False

client

Reuse an existing client. When provided, close() will not close it (the caller owns its lifecycle) and **client_kwargs are ignored.

TYPE: DogeAPIClient DEFAULT: None

**client_kwargs

Passed to DogeAPIClient (e.g. base_url, timeout, headers) when client is not supplied.

TYPE: dict DEFAULT: {}

METHOD DESCRIPTION
close

Close the internal client session (unless an external client was injected).

Source code in src/pydoge_api/api.py
Python
def __init__(
    self,
    fetch_all: bool = False,
    output_pydantic: bool = True,
    handle_response: bool = True,
    run_async: bool = False,
    client: Optional[DogeAPIClient] = None,
    **client_kwargs,
):
    """
    Initialize DogeAPI with a shared DogeAPIClient and global endpoint config flags.

    Parameters
    ----------
    fetch_all : bool
        Automatically fetch all pages for paginated endpoints.
    output_pydantic : bool
        If True, return Pydantic models. If False, return plain dicts with .export().
    handle_response : bool
        If True, decode responses. If False, return raw httpx.Response.
    run_async : bool
        If True, use asyncio-based pagination (if supported).
    client : DogeAPIClient, optional
        Reuse an existing client. When provided, `close()` will **not** close it
        (the caller owns its lifecycle) and `**client_kwargs` are ignored.
    **client_kwargs : dict
        Passed to DogeAPIClient (e.g. base_url, timeout, headers) when `client`
        is not supplied.
    """
    self.fetch_all = fetch_all
    self.output_pydantic = output_pydantic
    self.handle_response = handle_response
    self.run_async = run_async

    if client is not None:
        self.client = client
        self._owns_client = False
    else:
        self.client = DogeAPIClient(**client_kwargs)
        self._owns_client = True

    self.savings = SavingsAPI(client=self.client, api=self)
    self.payments = PaymentsAPI(client=self.client, api=self)
    logger.debug(
        f"DogeAPI initialized (base_url={self.client.base_url}, fetch_all={fetch_all}, "
        f"output_pydantic={output_pydantic}, handle_response={handle_response}, run_async={run_async})"
    )

close()

Close the internal client session (unless an external client was injected).

Source code in src/pydoge_api/api.py
Python
def close(self):
    """Close the internal client session (unless an external client was injected)."""
    if self._owns_client:
        logger.debug("Closing DogeAPI client session")
        self.client.close()