Skip to main content

Empower Personal Capital

A modern Python library for accessing your Personal Capital (Empower) data, with built-in support for session persistence, two-factor authentication, and convenient account and transaction retrieval.

Features

  • Simple login: Email/password authentication
  • Two-factor authentication: SMS and email support
  • Session persistence: Avoids 2FA every run
  • Fetch financial data: Account details, transactions, net worth
  • Easy automation: Ideal for scripts and data analysis

Installation

With pip

pip install empower_personal_capital

From Source

Clone the repo:

git clone https://github.com/ChocoTonic/personalcapital-py.git
cd personalcapital-py

Install dependencies and the package:

pip install -r requirements.txt
python setup.py install

Usage

Quick Example

from personalcapital import PersonalCapital, RequireTwoFactorException, TwoFactorVerificationModeEnum

pc = PersonalCapital()
email, password = "you@example.com", "your_password"

try:
    pc.login(email, password)
except RequireTwoFactorException:
    pc.two_factor_challenge(TwoFactorVerificationModeEnum.SMS)
    code = input("Enter 2FA code: ")
    pc.two_factor_authenticate(TwoFactorVerificationModeEnum.SMS, code)
    pc.authenticate_password(password)

accounts_response = pc.fetch('/newaccount/getAccounts')
accounts = accounts_response.json()['spData']
print('Net worth:', accounts['networth'])

Session Persistence

You can avoid having to enter 2FA every time by storing your session:

session = pc.get_session()
# Save session to a file

# Later...
pc.set_session(session)

See main.py for a complete script with persistent sessions.

Running the Example Script

The included main.py script provides a full working example with session saving/loading.

To run:

python main.py

You can also set environment variables to avoid entering your email and password each time:

PEW_EMAIL="you@example.com" PEW_PASSWORD="your_password" python main.py

If you do not set environment variables, the script will prompt for your credentials.

Absolutely. Here’s a clear section you can add to your README that explains the .env file usage and lists the required variables.

Environment Variables and the .env File

You can define your credentials in a .env file at the root of your project to avoid entering your email and password every time you run the script. The package will automatically load these using python-dotenv.

Create a file named .env and add your credentials:

PEW_EMAIL=your_email@example.com
PEW_PASSWORD=your_password

.env.example is included as a template. Never commit your real .env file with credentials to version control.

If these variables are set, the script will use them and will not prompt for your email or password.

Fetching Transactions

You can fetch transactions by making an API call. For example, to get transactions from the past 90 days (as shown in main.py):

from datetime import datetime, timedelta

now = datetime.now()
start_date = (now - timedelta(days=91)).strftime('%Y-%m-%d')
end_date = (now - timedelta(days=1)).strftime('%Y-%m-%d')

transactions_response = pc.fetch(
    '/transaction/getUserTransactions',
    {
        "sort_cols": "transactionTime",
        "sort_rev": "true",
        "page": "0",
        "rows_per_page": "100",
        "startDate": start_date,
        "endDate": end_date,
        "component": "DATAGRID",
    },
)
transactions = transactions_response.json()['spData']['transactions']
print(f"Found {len(transactions)} transactions")

Advanced Usage

  • Handling two-factor via Email: Replace TwoFactorVerificationModeEnum.SMS with TwoFactorVerificationModeEnum.EMAIL in the challenge and authenticate methods.

  • Other API endpoints: You can inspect your browser’s network requests while using Personal Capital, or refer to the code and experiment with additional endpoints using pc.fetch(endpoint, data).

Release files for empower-personal-capital 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for empower-personal-capital 0.0.2
File Interpreter ABI Platform
empower_personal_capital-0.0.2-py3-none-any.whl Python 3 none any Details

Release files / empower_personal_capital-0.0.2-py3-none-any.whl

Download URL empower_personal_capital-0.0.2-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
700e2dadfc69b015f52e40b0d3f83e6202f64224bec3b5f2214504e7667f2b3c
BLAKE2b-256 checksum
How to use checksums
ac8776b03aaf3167668124eefd093986d3e04363b48ed913203470312aad48bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.14.0a4

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page