Python client for the Empower (Personal Capital) unofficial API
Project description
personalcapital2
Get your financial data out of Empower (formerly Personal Capital) and into your own tools. Track net worth over time, analyze spending, monitor investment performance, or let an AI agent answer questions about your finances.
Three interfaces, one library:
- Python API — frozen dataclasses with
Decimalprecision, not raw JSON - CLI (
pc2) — structured JSON to stdout, pipe tojq, scripts, or spreadsheets - MCP server — drop into Claude Desktop, ask "how much did I spend on dining last quarter?"
Built on the reverse-engineering work of haochi/personalcapital and traviscook21/personalcapital (both MIT). Adds typed dataclasses, an agent-first CLI, and an MCP server on top.
Install
pip install personalcapital2
# or with uv
uv add personalcapital2
Quick start
from datetime import date, timedelta
from personalcapital2 import authenticate
client = authenticate() # interactive login with 2FA
result = client.get_accounts()
for acct in result.accounts:
print(f"{acct.name:<30} ${acct.balance}")
print(f"Net worth: ${result.summary.networth:,.2f}")
result = client.get_transactions(date.today() - timedelta(days=90), date.today())
for txn in result.transactions:
print(f"{txn.date} {txn.description:<30} ${txn.amount:.2f}")
print(f"Net cashflow: ${result.summary.net_cashflow:,.2f}")
Authentication
authenticate() reads credentials from environment variables, falling back to interactive prompts:
| Variable | Purpose |
|---|---|
EMPOWER_EMAIL |
Empower account email |
EMPOWER_PASSWORD |
Empower account password |
EMPOWER_2FA_MODE |
sms (the only method Empower still offers) — optional; 2FA defaults to SMS |
PC2_SESSION_PATH |
Custom session file location (default: ~/.config/personalcapital2/session.json) |
Credentials go to Empower over HTTPS only — never stored, logged, or transmitted elsewhere.
Note: Empower removed email 2FA — verification codes are sent by SMS only.
EMPOWER_2FA_MODEis kept for compatibility but now only acceptssms; a stale
Sessions live ~24 hours. Set EMPOWER_EMAIL and EMPOWER_PASSWORD so commands self-heal when a session expires; otherwise re-run pc2 login. Override the session path per-command with --session.
Headless authentication
For unattended invocation, pipe the verification code on stdin:
EMPOWER_EMAIL=... EMPOWER_PASSWORD=... \
printf '%s\n' "$CODE" | pc2 login
The orchestrator handles SMS code pickup; pc2 reads the code from stdin.
CLI
The pc2 command outputs structured JSON (data to stdout, errors to stderr) and follows an agent-first design: every error has a machine-readable type and recovery suggestion, exit codes are meaningful, and the help text is self-documenting.
pc2 accounts # all linked accounts
pc2 transactions --start 90d # last 90 days of transactions
pc2 holdings # current investment positions
pc2 net-worth --start yb --format csv # YTD net worth as CSV
pc2 performance --start mb-6 --account-ids 123,456
pc2 spending # current month/week/year spending
Date shortcuts: 30d (days ago), mb / me (month begin/end), yb / ye (year begin/end), mb-3 (3 months ago). See CLI Reference for the full list.
Python API
Methods return response containers with typed dataclass fields and a pre-computed summary, not bare lists:
result = client.get_accounts()
result.accounts # tuple[Account, ...]
result.summary # AccountsSummary — networth, assets, liabilities, ...
result = client.get_transactions(start, end)
result.transactions # tuple[Transaction, ...]
result.categories # tuple[Category, ...]
result.summary # TransactionsSummary — money_in, money_out, net_cashflow, ...
All fields use datetime.date and decimal.Decimal. See the API Reference for the full method list and the Model Reference for every field and type.
MCP Server
An MCP tool server gives AI agents (Claude Code, Claude Desktop, etc.) direct access to your financial data. The agent can call tools like get_transactions or get_holdings and reason over the results.
pip install "personalcapital2[mcp]"
pc2 login # authenticate first
pc2 mcp # start the server
Client config (Claude Code / Claude Desktop):
{
"mcpServers": {
"empower": {
"type": "stdio",
"command": "pc2",
"args": ["mcp"],
"env": {
"PC2_SESSION_PATH": "~/.config/personalcapital2/session.json",
"EMPOWER_EMAIL": "you@example.com",
"EMPOWER_PASSWORD": "..."
}
}
}
}
When the cached session expires mid-conversation, the agent recovers in chat without dropping to a terminal: it calls start_authentication, asks you for the SMS verification code, then calls complete_authentication with the code. The server reads the credentials from this env block.
Note:
EMPOWER_PASSWORDsits plaintext in the MCP client config — standard pattern for MCP servers, but worth knowing.
The server is token-aware — large responses are automatically truncated to fit within context limits (~12,500 tokens by default, configurable via PC2_MCP_MAX_CHARS), while summaries are always preserved in full.
Known API quirks
This library uses Empower's unofficial internal web API, which is not affiliated with Empower and may change without notice.
is_spendingis unreliable on refunds. Usetransaction_type(e.g."Refund") instead.performanceandbenchmarksshare one API call.get_performance()returns both in a singlePerformanceResult.get_accountsmay not list all accounts with holdings. Some accounts (employer 401k plans, crypto exchanges) can appear inget_holdings,get_account_balances, andget_performancebut not inget_accounts. Useget_holdingsto discover investment account IDs.- Fee fields can be
NaN. The API returns"NaN"forfees_per_year,fund_fees,total_fee, andadvisory_fee_percentageon some investment accounts (401k plans, crypto, RSUs). These are coerced toNone— the account is not dropped. get_spendingignores date range and interval. The API always returns current-period spending for all three interval types (MONTH, WEEK, YEAR), regardless of thestart_date,end_date, orintervalparameters.- Sessions expire. Typically ~24 hours, sometimes sooner. CLI users run
pc2 loginagain; MCP users let the agent callstart_authentication/complete_authentication. Stale-session recovery handles this automatically whenEMPOWER_EMAIL/EMPOWER_PASSWORDare set.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file personalcapital2-0.4.0.tar.gz.
File metadata
- Download URL: personalcapital2-0.4.0.tar.gz
- Upload date:
- Size: 142.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e6d400ea5c9a023553c7e0983c6c98dcd7893678576179b2a7d57ee4af61d00
|
|
| MD5 |
8cbe01123911b3a58f8c6c1a21d9c0aa
|
|
| BLAKE2b-256 |
f8420f4b61eed794e906dad1c0c4b3f5f794b2f73584c78344e22a0fae15ce7f
|
Provenance
The following attestation bundles were made for personalcapital2-0.4.0.tar.gz:
Publisher:
release.yml on wpwilson10/personalcapital2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
personalcapital2-0.4.0.tar.gz -
Subject digest:
6e6d400ea5c9a023553c7e0983c6c98dcd7893678576179b2a7d57ee4af61d00 - Sigstore transparency entry: 1685073787
- Sigstore integration time:
-
Permalink:
wpwilson10/personalcapital2@614afb4d3be0667a5b02f44479ee8af3df76eb55 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/wpwilson10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@614afb4d3be0667a5b02f44479ee8af3df76eb55 -
Trigger Event:
push
-
Statement type:
File details
Details for the file personalcapital2-0.4.0-py3-none-any.whl.
File metadata
- Download URL: personalcapital2-0.4.0-py3-none-any.whl
- Upload date:
- Size: 54.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
076806d227f2c99f5ae883483ef6fa0aaa0408d5d099870eca1ff4493139f889
|
|
| MD5 |
ce326c61a9c4421d123ba69dc3b7f70d
|
|
| BLAKE2b-256 |
27d0d0305affdbdd48cc8ca22d91bb283826b7431ac94b472007fb75dbf67057
|
Provenance
The following attestation bundles were made for personalcapital2-0.4.0-py3-none-any.whl:
Publisher:
release.yml on wpwilson10/personalcapital2
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
personalcapital2-0.4.0-py3-none-any.whl -
Subject digest:
076806d227f2c99f5ae883483ef6fa0aaa0408d5d099870eca1ff4493139f889 - Sigstore transparency entry: 1685074084
- Sigstore integration time:
-
Permalink:
wpwilson10/personalcapital2@614afb4d3be0667a5b02f44479ee8af3df76eb55 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/wpwilson10
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@614afb4d3be0667a5b02f44479ee8af3df76eb55 -
Trigger Event:
push
-
Statement type: