Skip to main content

Integrations

External API integrations for financial data synchronization and trading.

Overview

IntegrationPurposeData
Monarch MoneyAccount aggregationAccounts, transactions, categories
PlaidBank connectionsAccounts, transactions, balances
SchwabBrokerageHoldings, trading, account info
FREDEconomic dataInterest 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

  1. Request link token: POST /api/integrations/plaid/link-token/
  2. User completes Plaid Link UI
  3. Exchange public token: POST /api/integrations/plaid/exchange-token/
  4. 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

  1. Start authorization: POST /api/integrations/schwab/authorize/
  2. User authorizes in Schwab portal
  3. Callback receives tokens
  4. Access portfolio and trading

Capabilities

CapabilityDescription
PortfolioHoldings, positions, account value
OrdersView pending and filled orders
TradingExecute buy/sell orders
QuotesReal-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 IDDescription
DGS1010-Year Treasury Rate
UNRATEUnemployment Rate
CPIAUCSLConsumer Price Index
FEDFUNDSFederal Funds Rate
GDPGross 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

TaskScheduleSources
sync_accountsDaily @ 6 AMMonarch, Plaid
sync_transactions_incrementalEvery 30 minMonarch, Plaid
sync_schwab_portfolioHourlySchwab
sync_economic_dataWeeklyFRED
full_syncMonthly @ 1stAll

Error Handling

When sync fails:

  1. Error logged to SyncLog
  2. Notification sent (if critical)
  3. Retry with exponential backoff
  4. Manual intervention if repeated failures