Official Python SDK for the Wealthica Investment API.
Wealthica is an API for connecting with Canadian financial institutions and brokerages platforms. Instead of manually integrating with multiple institution APIs - you can simply use Wealthica for them all.
For our updated list of integrations, check out our list of Wealthica Integrations.
- Secure JWT-based token authentication with automatic refresh
- Investment positions with security details
- Transaction history across all connected institutions
- Balance history tracking over time
- Support for 150+ Canadian financial institutions
- Context manager support for automatic cleanup
- Typed exception classes for granular error handling
- Python >= 3.8
pip install wealthicaSet your credentials as environment variables:
export WEALTHICA_CLIENT_ID="your_client_id"
export WEALTHICA_CLIENT_SECRET="your_secret"To obtain API keys, reach out to the team at sales@wealthica.com.
from wealthica import Wealthica
# Initialize the client with your API credentials
wealthica = Wealthica(
client_id="your_client_id",
secret="your_secret"
)
# Get list of supported providers (no user login required)
providers = wealthica.providers.get_list()
print(f"Wealthica supports {len(providers)} providers")
# Get team information
team = wealthica.get_team()
print(f"Team: {team['name']}")To access user-specific data like institutions, positions, and transactions, you need to login as a user:
from wealthica import Wealthica
wealthica = Wealthica(
client_id="your_client_id",
secret="your_secret"
)
# Login as a specific user (use your internal user ID)
user = wealthica.login("user_123")
# Now you can access user-specific resources
institutions = user.institutions.get_list()
for inst in institutions:
print(f"Institution: {inst['provider']['display_name']}")
for balance in inst.get('balances', []):
print(f" {balance['ticker']}: {balance['amount']}")These APIs don't require user authentication:
providers = wealthica.providers.get_list()
# Each provider includes:
# - name: unique identifier
# - display_name: human-friendly name
# - auth_type: authentication type
# - credentials: required credential typesprovider = wealthica.providers.get_one("questrade")
print(f"Auth type: {provider['auth_type']}")These APIs require user authentication:
user = wealthica.login("user_123")
institutions = user.institutions.get_list()
for inst in institutions:
print(f"ID: {inst['id']}")
print(f"Provider: {inst['provider']['display_name']}")institution = user.institutions.get_one("603522490d2b02001233a5d6")Trigger a refresh to fetch the latest data from the provider:
institution = user.institutions.sync("603522490d2b02001233a5d6")user.institutions.remove("603522490d2b02001233a5d6")user = wealthica.login("user_123")
# Get all positions
positions = user.positions.get_list()
# Get positions for specific institutions
positions = user.positions.get_list(
institutions=["603522490d2b02001233a5d6"]
)
for pos in positions:
security = pos.get('security', {})
print(f"{security['name']} ({security['symbol']})")
print(f" Quantity: {pos['quantity']}")
print(f" Market Value: {pos['market_value']}")
print(f" Gain: {pos['gain_percent']}%")user = wealthica.login("user_123")
# Get all transactions
transactions = user.transactions.get_list(
institutions=["603522490d2b02001233a5d6"]
)
# With filters
transactions = user.transactions.get_list(
institutions=["603522490d2b02001233a5d6"],
from_date="2024-01-01",
to_date="2024-06-30",
limit=100
)tx = user.transactions.get_one(tx_id="603522490d2b02001233a5d7")user = wealthica.login("user_123")
history = user.history.get_list(
institutions=["603522490d2b02001233a5d6"],
from_date="2024-01-01",
to_date="2024-06-30"
)
for entry in history:
print(f"Date: {entry['date']}, Investment: {entry['investment']}")The SDK provides specific exception classes for different error types:
from wealthica import (
Wealthica,
WealthicaError,
WealthicaAuthenticationError,
WealthicaAPIError,
WealthicaValidationError,
WealthicaNotFoundError,
WealthicaRateLimitError,
)
try:
user = wealthica.login("user_123")
institution = user.institutions.get_one("invalid_id")
except WealthicaNotFoundError as e:
print(f"Institution not found: {e.message}")
except WealthicaAuthenticationError as e:
print(f"Authentication failed: {e.message}")
except WealthicaRateLimitError as e:
print(f"Rate limit exceeded: {e.message}")
except WealthicaAPIError as e:
print(f"API error [{e.status_code}]: {e.message}")
except WealthicaError as e:
print(f"Wealthica error: {e.message}")The SDK supports context managers for automatic cleanup:
with Wealthica(client_id="...", secret="...") as wealthica:
providers = wealthica.providers.get_list()
# Connection is automatically closed when exiting the blockwealthica = Wealthica(
client_id="your_client_id", # Required
secret="your_secret", # Required
base_url="https://api.wealthica.com/v1", # Optional, default API URL
connect_url="https://connect.wealthica.com", # Optional, Connect widget URL
timeout=30.0, # Optional, request timeout in seconds
)To connect user institutions, you'll need to use Wealthica Connect in your frontend. Here's how the flow works:
- Backend: Generate a user token
user = wealthica.login("user_123")
token = user.get_token()
# Send this token to your frontend- Frontend: Use the token with Wealthica Connect (JavaScript)
import Wealthica from 'wealthica-sdk-js';
const wealthica = Wealthica.init({
clientId: 'YOUR_CLIENT_ID',
authEndpoint: '/wealthica/auth',
});
const user = wealthica.login();
user.connect()
.onConnection((institution) => {
console.log('Connected:', institution);
})
.onError((error) => {
console.error('Error:', error);
});- Backend: Handle the callback to receive the connected institution
For full frontend integration, see the JavaScript SDK.
To release a new version of the SDK:
Update the version number in pyproject.toml:
version = "X.Y.Z"And in src/wealthica/__init__.py:
__version__ = "X.Y.Z"Add release notes to CHANGELOG.md.
git add -A
git commit -m "vX.Y.Z: Description of changes"
git tag -a vX.Y.Z -m "Release vX.Y.Z"
git push origin main --tags# Install build tools
pip install build twine
# Clean previous builds
rm -rf dist/ build/ src/*.egg-info
# Build
python3 -m build# Upload using twine (requires PyPI API token)
python3 -m twine upload dist/* -u __token__ -p YOUR_PYPI_TOKENTo get a PyPI API token:
- Go to https://pypi.org/manage/account/
- Create an API token with "Upload packages" scope
- Use
__token__as username and the token as password
See the examples directory for complete working examples including a CLI script and a Flask web server.
- Wealthica API Documentation
- JavaScript SDK
- Python SDK on PyPI
- GitHub Repository
- Integration Status
- Changelog
- Sales & API keys: sales@wealthica.com
- General inquiries: hello@wealthica.com
- Documentation: https://wealthica.com/docs
MIT License - see LICENSE for details.