Skip to content

plaid_accounts#

Lunch Money - Plaid Accounts

https://lunchmoney.dev/#plaid-accounts

PlaidAccountObject #

Bases: LunchableModel

Assets synced from Plaid

Similar to AssetObjects, these accounts are linked to remote sources in Plaid.

https://lunchmoney.dev/#plaid-accounts-object

Parameters:

Name Type Description Default
id int

Unique identifier of Plaid account

required
date_linked date

Date account was first linked in ISO 8601 extended format

required
name str

Name of the account. Can be overridden by the user. Field is originally set by Plaid

required
type str

Primary type of account. Typically one of: [credit, depository, brokerage, cash, loan, investment]. This field is set by Plaid and cannot be altered.

required
subtype str

Optional subtype name of account. This field is set by Plaid and cannot be altered

required
mask str | None

Mask (last 3 to 4 digits of account) of account. This field is set by Plaid and cannot be altered

None
institution_name str

Name of institution associated with account. This field is set by Plaid and cannot be altered

required
status str

Denotes the current status of the account within Lunch Money. Must be one of: active (Account is active and in good state), inactive (Account marked inactive from user. No transactions fetched or balance update for this account), relink (Account needs to be relinked with Plaid), syncing (Account is awaiting first import of transactions), error (Account is in error with Plaid), not found (Account is in error with Plaid), not supported (Account is in error with Plaid)

required
last_import datetime | None

Date of last imported transaction in ISO 8601 extended format (not necessarily date of last attempted import)

None
balance float | None

Current balance of the account in numeric format to 4 decimal places. This field is set by Plaid and cannot be altered

None
currency str

Currency of account balance in ISO 4217 format. This field is set by Plaid and cannot be altered

required
balance_last_update datetime

Date balance was last updated in ISO 8601 extended format. This field is set by Plaid and cannot be altered

required
limit int | None

Optional credit limit of the account. This field is set by Plaid and cannot be altered

None
Source code in lunchable/models/plaid_accounts.py
class PlaidAccountObject(LunchableModel):
    """
    Assets synced from Plaid

    Similar to AssetObjects, these accounts are linked to remote sources in Plaid.

    https://lunchmoney.dev/#plaid-accounts-object
    """

    id: int = Field(description="Unique identifier of Plaid account")
    date_linked: datetime.date = Field(
        description=_PlaidAccountDescriptions.date_linked
    )
    name: str = Field(description=_PlaidAccountDescriptions.name)
    type: str = Field(description=_PlaidAccountDescriptions.type)
    subtype: str = Field(description=_PlaidAccountDescriptions.subtype)
    mask: Optional[str] = Field(None, description=_PlaidAccountDescriptions.mask)
    institution_name: str = Field(
        description=_PlaidAccountDescriptions.institution_name
    )
    status: str = Field(description=_PlaidAccountDescriptions.status)
    last_import: Optional[datetime.datetime] = Field(
        None, description=_PlaidAccountDescriptions.last_import
    )
    balance: Optional[float] = Field(
        None, description=_PlaidAccountDescriptions.balance
    )
    currency: str = Field(description=_PlaidAccountDescriptions.currency)
    balance_last_update: datetime.datetime = Field(
        description=_PlaidAccountDescriptions.balance_last_update
    )
    limit: Optional[int] = Field(None, description=_PlaidAccountDescriptions.limit)

PlaidAccountsClient #

Bases: LunchMoneyAPIClient

Lunch Money Plaid Accounts Interactions

Source code in lunchable/models/plaid_accounts.py
class PlaidAccountsClient(LunchMoneyAPIClient):
    """
    Lunch Money Plaid Accounts Interactions
    """

    def get_plaid_accounts(self) -> List[PlaidAccountObject]:
        """
        Get Plaid Synced Assets

        Get a list of all synced Plaid accounts associated with the user's account.

        Plaid Accounts are individual bank accounts that you have linked to Lunch Money via Plaid.
        You may link one bank but one bank might contain 4 accounts. Each of these
        accounts is a Plaid Account. (https://lunchmoney.dev/#plaid-accounts-object)

        Returns
        -------
        List[PlaidAccountObject]
        """
        response_data = self.make_request(
            method=self.Methods.GET, url_path=APIConfig.LUNCHMONEY_PLAID_ACCOUNTS
        )
        accounts = response_data.get(APIConfig.LUNCHMONEY_PLAID_ACCOUNTS)
        account_objects = [PlaidAccountObject.model_validate(item) for item in accounts]
        return account_objects

    def trigger_fetch_from_plaid(
        self,
        start_date: Optional[datetime.date] = None,
        end_date: Optional[datetime.date] = None,
        plaid_account_id: Optional[int] = None,
    ) -> bool:
        """
        Trigger Fetch from Plaid

        ** This is an experimental endpoint and parameters and/or response may change. **

        Use this endpoint to trigger a fetch for latest data from Plaid.

        Returns true if there were eligible Plaid accounts to trigger a fetch for. Eligible
        accounts are those who last_fetch value is over 1 minute ago. (Although the limit
        is every minute, please use this endpoint sparingly!)

        Note that fetching from Plaid is a background job. This endpoint simply queues up
        the job. You may track the plaid_last_successful_update, last_fetch and last_import
        properties to verify the results of the fetch.

        Parameters
        ----------
        start_date: Optional[datetime.date]
            Start date for fetch (ignored if end_date is null)
        end_date: Optional[datetime.date]
            End date for fetch (ignored if start_date is null)
        plaid_account_id: Optional[int]
            Specific ID of a plaid account to fetch. If left empty,
            endpoint will trigger a fetch for all eligible accounts

        Returns
        -------
        bool
            Returns true if there were eligible Plaid accounts to trigger a fetch for.
        """
        fetch_request = _PlaidFetchRequest(
            start_date=start_date, end_date=end_date, plaid_account_id=plaid_account_id
        )
        response: bool = self.make_request(
            method=self.Methods.POST,
            url_path=[APIConfig.LUNCHMONEY_PLAID_ACCOUNTS, "fetch"],
            data=fetch_request.model_dump(exclude_none=True),
        )
        return response

get_plaid_accounts() #

Get Plaid Synced Assets

Get a list of all synced Plaid accounts associated with the user's account.

Plaid Accounts are individual bank accounts that you have linked to Lunch Money via Plaid. You may link one bank but one bank might contain 4 accounts. Each of these accounts is a Plaid Account. (https://lunchmoney.dev/#plaid-accounts-object)

Returns:

Type Description
List[PlaidAccountObject]
Source code in lunchable/models/plaid_accounts.py
def get_plaid_accounts(self) -> List[PlaidAccountObject]:
    """
    Get Plaid Synced Assets

    Get a list of all synced Plaid accounts associated with the user's account.

    Plaid Accounts are individual bank accounts that you have linked to Lunch Money via Plaid.
    You may link one bank but one bank might contain 4 accounts. Each of these
    accounts is a Plaid Account. (https://lunchmoney.dev/#plaid-accounts-object)

    Returns
    -------
    List[PlaidAccountObject]
    """
    response_data = self.make_request(
        method=self.Methods.GET, url_path=APIConfig.LUNCHMONEY_PLAID_ACCOUNTS
    )
    accounts = response_data.get(APIConfig.LUNCHMONEY_PLAID_ACCOUNTS)
    account_objects = [PlaidAccountObject.model_validate(item) for item in accounts]
    return account_objects

trigger_fetch_from_plaid(start_date=None, end_date=None, plaid_account_id=None) #

Trigger Fetch from Plaid

** This is an experimental endpoint and parameters and/or response may change. **

Use this endpoint to trigger a fetch for latest data from Plaid.

Returns true if there were eligible Plaid accounts to trigger a fetch for. Eligible accounts are those who last_fetch value is over 1 minute ago. (Although the limit is every minute, please use this endpoint sparingly!)

Note that fetching from Plaid is a background job. This endpoint simply queues up the job. You may track the plaid_last_successful_update, last_fetch and last_import properties to verify the results of the fetch.

Parameters:

Name Type Description Default
start_date Optional[date]

Start date for fetch (ignored if end_date is null)

None
end_date Optional[date]

End date for fetch (ignored if start_date is null)

None
plaid_account_id Optional[int]

Specific ID of a plaid account to fetch. If left empty, endpoint will trigger a fetch for all eligible accounts

None

Returns:

Type Description
bool

Returns true if there were eligible Plaid accounts to trigger a fetch for.

Source code in lunchable/models/plaid_accounts.py
def trigger_fetch_from_plaid(
    self,
    start_date: Optional[datetime.date] = None,
    end_date: Optional[datetime.date] = None,
    plaid_account_id: Optional[int] = None,
) -> bool:
    """
    Trigger Fetch from Plaid

    ** This is an experimental endpoint and parameters and/or response may change. **

    Use this endpoint to trigger a fetch for latest data from Plaid.

    Returns true if there were eligible Plaid accounts to trigger a fetch for. Eligible
    accounts are those who last_fetch value is over 1 minute ago. (Although the limit
    is every minute, please use this endpoint sparingly!)

    Note that fetching from Plaid is a background job. This endpoint simply queues up
    the job. You may track the plaid_last_successful_update, last_fetch and last_import
    properties to verify the results of the fetch.

    Parameters
    ----------
    start_date: Optional[datetime.date]
        Start date for fetch (ignored if end_date is null)
    end_date: Optional[datetime.date]
        End date for fetch (ignored if start_date is null)
    plaid_account_id: Optional[int]
        Specific ID of a plaid account to fetch. If left empty,
        endpoint will trigger a fetch for all eligible accounts

    Returns
    -------
    bool
        Returns true if there were eligible Plaid accounts to trigger a fetch for.
    """
    fetch_request = _PlaidFetchRequest(
        start_date=start_date, end_date=end_date, plaid_account_id=plaid_account_id
    )
    response: bool = self.make_request(
        method=self.Methods.POST,
        url_path=[APIConfig.LUNCHMONEY_PLAID_ACCOUNTS, "fetch"],
        data=fetch_request.model_dump(exclude_none=True),
    )
    return response