Skip to content

Commit

Permalink
Merge pull request #68 from pazwicker/add-get-institutions-method
Browse files Browse the repository at this point in the history
  • Loading branch information
hammem authored Jan 12, 2024
2 parents 443e2da + 8df8aba commit 878801d
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ As of writing this README, the following methods are supported:
- `get_accounts` - gets all the accounts linked to Monarch Money
- `get_account_holdings` - gets all of the securities in a brokerage or similar type of account
- `get_account_type_options` - all account types and their subtypes available in Monarch Money-
- `get_institutions` -- gets institutions linked to Monarch Money
- `get_budgets` — all the budgets and the corresponding actual amounts
- `get_subscription_details` - gets the Monarch Money account's status (e.g. paid or trial)
- `get_transactions_summary` - gets the transaction summary data from the transactions page
Expand Down
5 changes: 5 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def main() -> None:
with open("data.json", "w") as outfile:
json.dump(accounts, outfile)

# Institutions
institutions = asyncio.run(mm.get_institutions())
with open("institutions.json", "w") as outfile:
json.dump(institutions, outfile)

# Budgets
budgets = asyncio.run(mm.get_budgets())
with open("budgets.json", "w") as outfile:
Expand Down
87 changes: 87 additions & 0 deletions monarchmoney/monarchmoney.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,93 @@ async def get_account_holdings(self, account_id: int) -> Dict[str, Any]:
variables=variables,
)

async def get_institutions(self) -> Dict[str, Any]:
"""
Gets institution data from the account.
"""

query = gql(
"""
query Web_GetInstitutionSettings {
credentials {
id
...CredentialSettingsCardFields
__typename
}
accounts(filters: {includeDeleted: true}) {
id
displayName
subtype {
display
__typename
}
mask
credential {
id
__typename
}
deletedAt
__typename
}
subscription {
isOnFreeTrial
hasPremiumEntitlement
__typename
}
}
fragment CredentialSettingsCardFields on Credential {
id
updateRequired
disconnectedFromDataProviderAt
...InstitutionInfoFields
institution {
id
name
logo
url
__typename
}
__typename
}
fragment InstitutionInfoFields on Credential {
id
displayLastUpdatedAt
dataProvider
updateRequired
disconnectedFromDataProviderAt
...InstitutionLogoWithStatusFields
institution {
id
name
hasIssuesReported
hasIssuesReportedMessage
__typename
}
__typename
}
fragment InstitutionLogoWithStatusFields on Credential {
dataProvider
updateRequired
institution {
hasIssuesReported
logo
status
balanceStatus
transactionsStatus
__typename
}
__typename
}
"""
)
return await self.gql_call(
operation="Web_GetInstitutionSettings",
graphql_query=query,
)

async def get_budgets(
self,
start_date: Optional[str] = None,
Expand Down

0 comments on commit 878801d

Please sign in to comment.