Match Amazon orders to YNAB transactions 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
📚 Digital Orders: Recognizes physical, digital, and subscription order IDs
🌍 UTF-8 Support: Full emoji support in category names
📊 Rich Previews: Shows category names and transaction details before updating
The parser supports English-language Amazon order pages with month-first or
day-first English dates and $, CA$, US$, £, or € totals. Translated
order-page labels and comma-decimal totals are not currently supported.
Prerequisites
- Python 3.12+
- 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
For predictable credential selection, only the current working directory is
checked; parent directories are not searched for .env files.
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
- Go to YNAB Developer Settings
- Click "New Token"
- Copy the generated token
Budget ID
- Open your budget in YNAB
- Look at the URL:
https://app.ynab.com/[budget_id]/budget - Copy the budget_id part
Account ID (Optional)
- Click on a specific account in YNAB
- Look at the URL:
https://app.ynab.com/[budget_id]/accounts/[account_id] - 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
Dry run
Use --dry-run to walk through the full interactive flow and preview every
update without sending any changes to YNAB:
ynab-amazon-categorizer --dry-run
The tool still shows the JSON preview for each transaction but skips the API call, so it is safe for trying the tool out or verifying matches.
Batch mode
Use --batch to run non-interactively: for every transaction with a single
high-confidence order match (unique exact-amount match within ~7 days), the
tool sets the memo (items + order link) automatically and leaves the category
unchanged, so you can still review/categorize later. Transactions with no
match or an ambiguous match are skipped.
Existing memo text is preserved and the Amazon context is appended. If the existing memo is too long to retain in full alongside at least the order link, the transaction is skipped rather than truncating user data.
# Preview what batch mode would enrich
ynab-amazon-categorizer --batch --dry-run
# Apply memo enrichment
ynab-amazon-categorizer --batch
You still paste the Amazon orders page once when prompted; --batch only
removes the per-transaction prompting.
Workflow
-
Provide Amazon Orders Data (optional but recommended):
- Copy your Amazon orders page content
- For example go to https://www.amazon.ca/gp/css/order-history?ref_=nav_orders_first and select all and copy the text
- Run the tool and paste Amazon order info when prompted
- The script will automatically match transactions with orders
- Copy your Amazon orders page content
-
Review Matched Transactions:
- The script shows order details, items, and links before asking to categorize
- For multiple items, it suggests splitting the transaction
-
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
.envto your.gitignoreif 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
.envfile 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 utf8on 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ynab_amazon_categorizer-2.4.0.tar.gz.
File metadata
- Download URL: ynab_amazon_categorizer-2.4.0.tar.gz
- Upload date:
- Size: 89.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f24475df5040a63bc2d3f5f351e7ff4df5186896e63035112b2d8eeecd1b8a51
|
|
| MD5 |
bd0a791103f1229368630fc68192829c
|
|
| BLAKE2b-256 |
c574d293a27d51e909a2aab88486278e11f7a7b56f3ac4187f2f949de89d2883
|
Provenance
The following attestation bundles were made for ynab_amazon_categorizer-2.4.0.tar.gz:
Publisher:
release.yml on dizzlkheinz/ynab-amazon-categorizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ynab_amazon_categorizer-2.4.0.tar.gz -
Subject digest:
f24475df5040a63bc2d3f5f351e7ff4df5186896e63035112b2d8eeecd1b8a51 - Sigstore transparency entry: 2138507833
- Sigstore integration time:
-
Permalink:
dizzlkheinz/ynab-amazon-categorizer@7a55b7c2a71e005e00f6cd8241ad04a3d7158825 -
Branch / Tag:
refs/tags/v2.4.0 - Owner: https://github.com/dizzlkheinz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7a55b7c2a71e005e00f6cd8241ad04a3d7158825 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ynab_amazon_categorizer-2.4.0-py3-none-any.whl.
File metadata
- Download URL: ynab_amazon_categorizer-2.4.0-py3-none-any.whl
- Upload date:
- Size: 42.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81b2af645c88c3a49bafc0cf1f39d41ee2bf329ad61b33df3583522a64ff2df1
|
|
| MD5 |
7a70c409c44a5cf27e2cdd605b4a4a9c
|
|
| BLAKE2b-256 |
d63cea587b048e6dfe05e6b1194f39a99f76f1f5bd6383f7f7fecda4432fe0a3
|
Provenance
The following attestation bundles were made for ynab_amazon_categorizer-2.4.0-py3-none-any.whl:
Publisher:
release.yml on dizzlkheinz/ynab-amazon-categorizer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ynab_amazon_categorizer-2.4.0-py3-none-any.whl -
Subject digest:
81b2af645c88c3a49bafc0cf1f39d41ee2bf329ad61b33df3583522a64ff2df1 - Sigstore transparency entry: 2138507857
- Sigstore integration time:
-
Permalink:
dizzlkheinz/ynab-amazon-categorizer@7a55b7c2a71e005e00f6cd8241ad04a3d7158825 -
Branch / Tag:
refs/tags/v2.4.0 - Owner: https://github.com/dizzlkheinz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7a55b7c2a71e005e00f6cd8241ad04a3d7158825 -
Trigger Event:
push
-
Statement type: