Skip to main content

Automatically categorize Amazon transactions in YNAB with rich item information

Project description

YNAB Amazon Categorizer

A Python package that assists in categorizing Amazon transactions in YNAB (You Need A Budget) with rich item information, automatic memo generation, and tab-completion for categories.

Features

When you paste in the text from your Amazon order page:

🎯 Smart Order Matching: Automatically matches YNAB transactions with Amazon orders by amount and date
📝 Enhanced Memos: Generates detailed memos with item names and direct Amazon order links
🔄 Intelligent Splitting: Suggests splitting transactions with multiple items into separate categories
Streamlined Workflow: Smart defaults and tab completion for fast categorization
🌍 UTF-8 Support: Full emoji support in category names
📊 Rich Previews: Shows category names and transaction details before updating

Prerequisites

  • Python 3.12+ (recommended; 3.10+ supported)
  • uv (recommended) or standard Python tooling
  • YNAB account with API access

Installation

Method 1: Run with uvx (Recommended)

# Run directly without installing (fastest and cleanest)
uvx ynab-amazon-categorizer

Method 2: Install as a tool

# Install globally with uv
uv tool install ynab-amazon-categorizer

# Then run
ynab-amazon-categorizer

Method 3: Development Installation

# Clone the repository
git clone https://github.com/dizzlkheinz/ynab-amazon-categorizer.git
cd ynab-amazon-categorizer

# Install in development mode
uv pip install -e .

Configuration Setup

After installation, you'll need to set up your YNAB API credentials:

Configuration File (.env)

Create a .env file in your working directory with your credentials:

YNAB_API_KEY=your_api_key_here
YNAB_BUDGET_ID=your_budget_id_here
YNAB_ACCOUNT_ID=none

Alternative: Environment Variables

# Windows
set YNAB_API_KEY=your_api_key_here
set YNAB_BUDGET_ID=your_budget_id_here

# Mac/Linux
export YNAB_API_KEY=your_api_key_here
export YNAB_BUDGET_ID=your_budget_id_here

Getting Your YNAB Credentials

API Key

  1. Go to YNAB Developer Settings
  2. Click "New Token"
  3. Copy the generated token

Budget ID

  1. Open your budget in YNAB
  2. Look at the URL: https://app.ynab.com/[budget_id]/budget
  3. Copy the budget_id part

Account ID (Optional)

  1. Click on a specific account in YNAB
  2. Look at the URL: https://app.ynab.com/[budget_id]/accounts/[account_id]
  3. Copy the account_id part (or leave as 'none' to process all accounts)

Usage

Basic Usage

# Run with uvx (no installation needed)
uvx ynab-amazon-categorizer

# Or if installed as a tool
ynab-amazon-categorizer

# Or run as a Python module
python -m ynab_amazon_categorizer

Workflow

  1. Provide Amazon Orders Data (optional but recommended):

  2. Review Matched Transactions:

    • The script shows order details, items, and links before asking to categorize
    • For multiple items, it suggests splitting the transaction
  3. Categorize Transactions:

    • Use tab completion to select categories
    • Accept suggested memos or customize them
    • Confirm updates with enhanced previews

Keyboard Shortcuts

  • Tab: Auto-complete category names
  • Enter: Accept defaults (categorize, use suggested memo, confirm update)
  • Alt+Enter: Submit multiline input (Amazon orders data, custom memos)
  • Ctrl+C: Cancel current operation

Example Output

🎯 MATCHED ORDER FOUND:
   Order ID: 702-8237239-1234567
   Total: $57.57
   Date: July 31, 2025
   Order Link: https://www.amazon.ca/gp/your-account/order-details?ie=UTF8&orderID=702-8237239-1234567
   Items:
     - Fancy Feast Grilled Wet Cat Food, Tuna Feast - 85 g Can (24 Pack)
     - Fancy Feast Grilled Wet Cat Food, Salmon & Shrimp Feast in Gravy - 85 g Can (24 Pack)

Action? (c = categorize/split, s = skip, q = quit, default c): 
There is more than one item in this transaction.
Split this transaction? (y/n, default n): y

Generated Memos

Single Item Transaction

Fancy Feast Grilled Wet Cat Food, Tuna Feast - 85 g Can (24 Pack)
 https://www.amazon.ca/gp/your-account/order-details?ie=UTF8&orderID=702-8237239-0563450

Split Transaction Main Memo

2 Items:
- Fancy Feast Grilled Wet Cat Food, Tuna Feast - 85 g Can (24 Pack)
- Fancy Feast Grilled Wet Cat Food, Salmon & Shrimp Feast in Gravy - 85 g Can (24 Pack)

Security Notes

⚠️ Important: Never commit your .env file to version control!

  • The script loads credentials from environment variables or config file
  • Your API key is never hardcoded in the script
  • Add .env to your .gitignore if using git

Troubleshooting

"No orders could be parsed"

  • Make sure you're copying the full Amazon orders page content
  • Try copying from a different browser or clearing browser cache

"API Key not found"

  • Verify your .env file exists and has the correct format
  • Check that your API key is valid in YNAB Developer Settings

"No transactions found"

  • Ensure you have uncategorized Amazon transactions in YNAB
  • Check that the payee names contain "amazon", "amzn", or "amz"

Emoji display issues

  • Use python -X utf8 on Windows for proper emoji support
  • Ensure your terminal supports UTF-8 encoding

Contributing

This package was developed to streamline YNAB Amazon transaction categorization. Feel free to suggest improvements or report issues!

License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.

Please respect YNAB's API terms of service when using this software.

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_amazon_categorizer-2.1.8.tar.gz (68.4 kB view details)

Uploaded Source

Built Distribution

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

ynab_amazon_categorizer-2.1.8-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file ynab_amazon_categorizer-2.1.8.tar.gz.

File metadata

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

File hashes

Hashes for ynab_amazon_categorizer-2.1.8.tar.gz
Algorithm Hash digest
SHA256 8dd5984e1c741e8ac950c48c0ae4946921190c89686cd33eeb9ba1d919290553
MD5 3ba587f7cb0fa670255eb4ede95e51ad
BLAKE2b-256 c04233e7c4cdbcf471530032109b0d80ab1c202a10a494bc26616a2c3cfc2d09

See more details on using hashes here.

Provenance

The following attestation bundles were made for ynab_amazon_categorizer-2.1.8.tar.gz:

Publisher: release.yml on dizzlkheinz/ynab-amazon-categorizer

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_amazon_categorizer-2.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for ynab_amazon_categorizer-2.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 b8bd16d8513352eed735d5c93aeeef3bd6db0af3074f2c092f5ef5a9ff2e28bc
MD5 ebb6f24a35ef02268ed97810c05636e2
BLAKE2b-256 b25131ef4fcdcdc22e3f084cdec61c36ab52193381b01be977785bab46a006ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for ynab_amazon_categorizer-2.1.8-py3-none-any.whl:

Publisher: release.yml on dizzlkheinz/ynab-amazon-categorizer

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