Skip to main content

YNAB transaction categorizer with Amazon order matching

Project description

YNAB TUI

CI codecov PyPI Python 3.11+ License: MIT Ruff

A terminal user interface for categorizing YNAB (You Need A Budget) transactions with Amazon order matching.

YNAB TUI Screenshot

Features

  • TUI for transaction review - Review and categorize uncategorized transactions
  • Amazon order matching - Scrapes your Amazon order history to identify purchased items
  • Split transaction support - Split Amazon orders into individual items with separate categories
  • Historical pattern learning - Learns from your categorization decisions for recurring payees
  • Git-style workflow - Pull transactions to local DB, categorize offline, push changes back
  • Multi-budget support - Switch between YNAB budgets
  • Advanced filtering - Filter transactions by category, payee, or status
  • Bulk tagging - Tag multiple transactions for batch operations
  • Undo support - Revert categorizations before pushing
  • CSV export - Export transaction data for external analysis
  • Mock mode - Test without real credentials using synthetic data

Installation

From PyPI (Recommended)

pip install ynab-tui

# Or with uv
uv pip install ynab-tui

From Source

git clone https://github.com/esterhui/ynab-tui.git
cd ynab-tui
uv sync --all-extras

Configuration

Initialize the configuration file:

ynab-tui init

This creates ~/.config/ynab-tui/config.toml. Edit it to add your credentials:

You can also use environment variables instead of the config file:

export YNAB_API_TOKEN="your-token"
export AMAZON_USERNAME="your-email"
export AMAZON_PASSWORD="your-password"

Usage

TUI (Terminal User Interface)

# Launch the TUI
ynab-tui

# Or use mock mode (no credentials needed)
ynab-tui --mock

# Show version
ynab-tui --version

Vim-style keybindings:

  • j/k or arrows - Navigate up/down
  • g/G - Go to top/bottom
  • Ctrl+d/u - Page down/up
  • c - Categorize selected transaction
  • a - Approve transaction
  • x - Split transaction (for Amazon orders)
  • u - Undo last change
  • p - Preview pending changes
  • / - Search transactions
  • f - Cycle filter (all/approved/uncategorized/pending)
  • t - Tag transaction for bulk operations
  • T - Clear all tags
  • b - Switch budget
  • s - Settings
  • ? - Help
  • q - Quit

CLI Commands

# Setup
ynab-tui init              # Create config file at ~/.config/ynab-tui/config.toml

# Sync commands (git-style pull/push)
ynab-tui pull              # Pull YNAB + Amazon data to local DB
ynab-tui pull --full       # Full pull of all data
ynab-tui push              # Push local categorizations to YNAB
ynab-tui push --dry-run    # Preview what would be pushed

# List uncategorized transactions
ynab-tui uncategorized

# Database inspection
ynab-tui db-status         # Show sync status and statistics
ynab-tui db-deltas         # Show pending changes before push
ynab-tui ynab-budgets      # List available budgets

# Category mappings (learn from history)
ynab-tui mappings          # Query learned item->category mappings
ynab-tui mappings-create   # Build mappings from approved transactions

# Test connections
ynab-tui ynab-test
ynab-tui amazon-test

Makefile

A Makefile is provided for common tasks. Run make help to see all available targets:

YNAB TUI

Make targets:
  make install    - Install dependencies
  make run        - Launch TUI application
  make test       - Run tests
  make coverage   - Run tests with coverage report
  make sloc       - Count lines of code (requires scc)
  make check      - Lint code
  make format     - Format code
  make mock-data  - Generate synthetic mock CSV data (deterministic)
  make mock-prod-data - Export production DB to mock CSV files
  make clean      - Remove cache files

Sync commands (git-style):
  make pull       - Pull YNAB + Amazon data to local DB (incremental)
  make pull-full  - Full pull of all data
  make push       - Push local categorizations to YNAB
  make push-dry   - Preview what would be pushed
  make db-status  - Show database sync status

CLI examples:
  uv run python -m ynab_tui.main                     # Launch TUI
  uv run python -m ynab_tui.main amazon-match        # Match Amazon transactions
  uv run python -m ynab_tui.main uncategorized       # List uncategorized transactions
  uv run python -m ynab_tui.main --help              # Show all commands

Mock mode (no live APIs):
  uv run python -m ynab_tui.main --mock              # Launch TUI with mock data
  uv run python -m ynab_tui.main --mock db-clear     # Only clears mock DB

How It Works

  1. Pull transactions from YNAB and orders from Amazon to local SQLite database
  2. Match Amazon transactions to orders by amount and date (fuzzy matching)
  3. Review uncategorized transactions in the TUI
  4. Categorize using the category picker or split into individual items
  5. Push your changes back to YNAB

Data Storage

Transaction and order data is stored locally in an unencrypted SQLite database at ~/.config/ynab-tui/categorizer.db. This includes your YNAB transactions, Amazon order history, and categorization decisions.

For security, ensure appropriate file permissions:

chmod 600 ~/.config/ynab-tui/*.db

Database encryption is planned for a future release.

Typical Workflow

First time setup:

# Do a full pull to download all YNAB transactions and Amazon order history
ynab-tui pull --full

Ongoing usage:

# 1. Pull new transactions (incremental - only fetches recent changes)
ynab-tui pull

# 2. Launch the TUI to review and categorize
ynab-tui

# 3. In the TUI: navigate with j/k, categorize with 'c', approve with 'a'
#    For Amazon orders, use 'x' to split into individual items

# 4. Push your changes back to YNAB (from CLI or use 'P' in TUI)
ynab-tui push

# Optional: preview changes before pushing
ynab-tui push --dry-run

Amazon Order Matching

YNAB transactions from Amazon typically show as "Amazon.com" with just the total amount, making it difficult to know what you actually purchased. This tool uses amazon-orders to scrape your Amazon order history and match transactions to specific orders.

How matching works:

  • Matches by amount (within $0.10 tolerance) and date (7-day window, extended to 24 days if needed)
  • Once matched, the TUI shows the actual items purchased instead of just "Amazon.com"
  • You can then categorize the whole order, or use split (x) to break it into individual items with separate categories

Example: A $45.67 Amazon transaction gets matched to an order containing:

  • Book: "Clean Code" - $29.99 → Categorize as "Books"
  • USB Cable - $15.68 → Categorize as "Electronics"

This makes Amazon transactions much easier to categorize accurately.

Development

# Run tests
uv run pytest tests/ -v

# Lint and format
uv run ruff check ynab_tui/ tests/
uv run ruff format ynab_tui/ tests/

# Run with mock data (no credentials needed)
ynab-tui --mock

# Build package
make build

# Full release check (lint, test, build)
make release

License

MIT

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

ynab_tui-0.1.0.tar.gz (446.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ynab_tui-0.1.0-py3-none-any.whl (156.2 kB view details)

Uploaded Python 3

File details

Details for the file ynab_tui-0.1.0.tar.gz.

File metadata

  • Download URL: ynab_tui-0.1.0.tar.gz
  • Upload date:
  • Size: 446.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ynab_tui-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c830b0a3c599b6891a70f7390532ca46f9524abc76c1ef2b87fe657f0f1d0c74
MD5 09ec5b2443591a831c4ced9274aebecd
BLAKE2b-256 582878ec327e82c39575dc813a079073083d1ba083341358d239970b4396e77d

See more details on using hashes here.

Provenance

The following attestation bundles were made for ynab_tui-0.1.0.tar.gz:

Publisher: publish.yml on esterhui/ynab-tui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ynab_tui-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ynab_tui-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 156.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ynab_tui-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 761d6c42ea378827ba13b2dccbed5ba524d25a58120bac5295aeb8c209c82a06
MD5 2e87c72e9a46b33bd780ea530ec44ec6
BLAKE2b-256 fbf702055e008b955162d1683eb7ae82bde8f715342246a9c29f4bcf9444e8d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for ynab_tui-0.1.0-py3-none-any.whl:

Publisher: publish.yml on esterhui/ynab-tui

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page