Integrations
External API integrations for financial data synchronization and trading.
Overview
| Integration | Purpose | Data |
|---|---|---|
| Monarch Money | Account aggregation | Accounts, transactions, categories |
| Plaid | Bank connections | Accounts, transactions, balances |
| Schwab | Brokerage | Holdings, trading, account info |
| FRED | Economic data | Interest rates, unemployment, CPI |
Monarch Money
Personal finance aggregation service.
Configuration
MONARCH_EMAIL=[email protected]
MONARCH_PASSWORD=your-password
MONARCH_MFA_SECRET=your-mfa-secret # For 2FA
Synced Data
- Account balances and details
- Transaction history
- Category mappings
- Merchant information
API
POST /api/integrations/monarch/sync/ # Trigger sync
GET /api/integrations/monarch/status/ # Connection status
Plaid
Bank account linking for multiple institutions.
Configuration
PLAID_CLIENT_ID=your-client-id
PLAID_SECRET=your-secret
PLAID_ENV=sandbox # sandbox, development, production
Linking Flow
- Request link token:
POST /api/integrations/plaid/link-token/ - User completes Plaid Link UI
- Exchange public token:
POST /api/integrations/plaid/exchange-token/ - Accounts are synced automatically
API
POST /api/integrations/plaid/link-token/ # Get link token
POST /api/integrations/plaid/exchange-token/ # Exchange token
GET /api/integrations/plaid/accounts/ # List linked accounts
DELETE /api/integrations/plaid/accounts/{id}/ # Unlink account
Schwab
Brokerage integration for investment accounts and trading.
Configuration
SCHWAB_API_KEY=your-api-key
SCHWAB_API_SECRET=your-api-secret
SCHWAB_CALLBACK_URL=http://localhost:8001/api/integrations/schwab/callback/
OAuth Flow
- Start authorization:
POST /api/integrations/schwab/authorize/ - User authorizes in Schwab portal
- Callback receives tokens
- Access portfolio and trading
Capabilities
| Capability | Description |
|---|---|
| Portfolio | Holdings, positions, account value |
| Orders | View pending and filled orders |
| Trading | Execute buy/sell orders |
| Quotes | Real-time stock quotes |
API
POST /api/integrations/schwab/authorize/ # Start OAuth
GET /api/integrations/schwab/portfolio/ # Get holdings
GET /api/integrations/schwab/orders/ # Get orders
POST /api/integrations/schwab/trade/ # Execute trade
Trade Request
{
"symbol": "AAPL",
"action": "buy",
"quantity": 10,
"order_type": "market",
"price": null
}
FRED (Federal Reserve)
Economic indicators from the Federal Reserve Economic Data.
Configuration
FRED_API_KEY=your-api-key
Indicators
| Series ID | Description |
|---|---|
DGS10 | 10-Year Treasury Rate |
UNRATE | Unemployment Rate |
CPIAUCSL | Consumer Price Index |
FEDFUNDS | Federal Funds Rate |
GDP | Gross Domestic Product |
API
GET /api/integrations/fred/indicators/ # Current values
GET /api/integrations/fred/series/{id}/ # Historical data
Sync Management
Manual Sync
# Trigger full sync via CLI
goblin app shell --service backend
>>> from apps.integrations.tasks import full_sync
>>> full_sync.delay()
API
POST /api/sync/trigger/ # Trigger manual sync
GET /api/sync/status/ # Sync status
GET /api/sync/logs/ # Sync history
Sync Log
class SyncLog:
source: str # monarch, plaid, schwab, fred
sync_type: str # full, incremental
status: str # running, success, failed
records_synced: int
started_at: datetime
completed_at: datetime
error_message: str
Scheduled Syncs
| Task | Schedule | Sources |
|---|---|---|
sync_accounts | Daily @ 6 AM | Monarch, Plaid |
sync_transactions_incremental | Every 30 min | Monarch, Plaid |
sync_schwab_portfolio | Hourly | Schwab |
sync_economic_data | Weekly | FRED |
full_sync | Monthly @ 1st | All |
Error Handling
When sync fails:
- Error logged to
SyncLog - Notification sent (if critical)
- Retry with exponential backoff
- Manual intervention if repeated failures
Related
- Finance - Data models
- AI Agent - Analysis using synced data
- Webapp Overview - Architecture