Skip to content

schemas

Monzo API 'balance' related schemas.

MonzoBalance

Bases: BaseModel

API schema for a 'balance' object.

Note

Monzo API docs: https://docs.monzo.com/#balance

Attributes:

Name Type Description
balance int

The currently available balance of the account, as a 64bit integer in minor units of the currency, eg. pennies for GBP, or cents for EUR and USD.

total_balance int

The sum of the currently available balance of the account and the combined total of all the user's pots.

currency str

The ISO 4217 currency code.

spend_today int

The amount spent from this account today (considered from approx 4am onwards), as a 64bit integer in minor units of the currency.

balance_including_flexible_savings Optional[int]

Whether balance includes flexible savings pots.

local_currency Optional[str]

Local currency.

local_exchange_rate Optional[float]

Local exchange rate.

local_spend Optional[list]

Local spend.

Source code in pymonzo/balance/schemas.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class MonzoBalance(BaseModel):
    """API schema for a 'balance' object.

    Note:
        Monzo API docs: https://docs.monzo.com/#balance

    Attributes:
        balance: The currently available balance of the account, as a 64bit integer in
            minor units of the currency, eg. pennies for GBP, or cents for EUR and USD.
        total_balance: The sum of the currently available balance of the account
            and the combined total of all the user's pots.
        currency: The ISO 4217 currency code.
        spend_today: The amount spent from this account today (considered from approx
            4am onwards), as a 64bit integer in minor units of the currency.
        balance_including_flexible_savings: Whether balance includes flexible
            savings pots.
        local_currency: Local currency.
        local_exchange_rate: Local exchange rate.
        local_spend: Local spend.
    """

    model_config = ConfigDict(extra="allow")

    balance: int
    total_balance: int
    currency: str
    spend_today: int

    # Undocumented in Monzo API docs
    balance_including_flexible_savings: Optional[int] = None
    local_currency: Optional[str] = None
    local_exchange_rate: Optional[float] = None
    local_spend: Optional[list] = None

    if RICH_AVAILABLE:

        def __rich__(self) -> Table:
            """Pretty printing support for `rich`."""
            balance = format_currency(self.balance / 100, self.currency)
            total_balance = format_currency(self.total_balance / 100, self.currency)
            spend_today = format_currency(self.spend_today / 100, self.currency)

            grid = Table.grid(padding=(0, 5))
            grid.add_column(style="bold magenta")
            grid.add_column()
            grid.add_row("Balance:", balance)
            grid.add_row("Total balance:", total_balance)
            grid.add_row("Currency:", self.currency)
            grid.add_row("Spend today:", spend_today)
            if self.local_currency:
                grid.add_row("Local currency:", self.local_currency)
            if self.local_exchange_rate:
                grid.add_row("Local exchange rate:", str(self.local_exchange_rate))

            return grid

__rich__()

Pretty printing support for rich.

Source code in pymonzo/balance/schemas.py
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
def __rich__(self) -> Table:
    """Pretty printing support for `rich`."""
    balance = format_currency(self.balance / 100, self.currency)
    total_balance = format_currency(self.total_balance / 100, self.currency)
    spend_today = format_currency(self.spend_today / 100, self.currency)

    grid = Table.grid(padding=(0, 5))
    grid.add_column(style="bold magenta")
    grid.add_column()
    grid.add_row("Balance:", balance)
    grid.add_row("Total balance:", total_balance)
    grid.add_row("Currency:", self.currency)
    grid.add_row("Spend today:", spend_today)
    if self.local_currency:
        grid.add_row("Local currency:", self.local_currency)
    if self.local_exchange_rate:
        grid.add_row("Local exchange rate:", str(self.local_exchange_rate))

    return grid