Skip to main content

Release Notes Downloads GitHub CI Status License: MIT

Enhance and Categorize Amazon Transactions in LunchMoney

LunchMoney is a indie-developed personal finance application. I spend a lot on Amazon, and always thought it would be neat to break open the massive black bucket of money that's funneled into Amazon to understand what categories of spending it represents.

The trick is, Amazon doesn't have an order export. There's a sneaky extension that allows you to export your orders to a CSV file. This tool ingests that CSV and categorizes your Amazon transactions in Lunch Money.

However, in order to match orders to transactions in Lunch Money, you have to match orders not items, which eliminates a clear 1:1 mapping between transaction and category. To solve this, we pipe the list of items to an LLM via Pydantic AI and ask it to categorize the items based on the categories available in your LunchMoney account.

Features

  • Marked as gift if recipient is not the owner name passed to the CLI
  • Support for multiple AI providers via Pydantic AI, with Google Gemini as the default (google:gemini-3.8-flash)
  • Summary of items purchased and order number is added to the transaction notes.

Installation

uv add amazon-lunchmoney

Note: OpenAI, Anthropic, and Gemini (Google) are supported by default. To install all providers supported by Pydantic AI, use pip install "amazon-lunchmoney[all-providers]".

Or for local development:

mise install
just setup

Usage

  1. Use the amazon order scraper to pull your amazon history.
    1. You want order view, not items, so we can match up charges to orders.azad example
  2. Get a lunch money API key. Run cp .env-example .env and add your API key to .env, or input it directly via the command line.
  3. Configure your AI provider:
export AMAZON_LUNCHMONEY_AI_KEY=<YOUR API KEY>
export AMAZON_LUNCHMONEY_MODEL=google:gemini-3.8-flash

Or configure provider-specific keys directly (e.g. GOOGLE_API_KEY, OPENAI_API_KEY, or ANTHROPIC_API_KEY).

Usage: amazon-lunchmoney [OPTIONS]

Options:
  --version                       Show the version and configured model and
                                  exit.
  -v, --verbose                   output verbose logs
  -f, --file FILE                 amazon history file  [required]
  --format [azad|amazon-shopping-mcp]
                                  order history file format  [default: azad]
  -k, --lunch-money-key TEXT      lunch money api key
  -d, --dry-run                   dry run mode
  -n, --owner-names TEXT          name of the owner(s) of the account, used to
                                  determine if a order is a gift
  -c, --default-category TEXT     default category  [required]
  -l, --limit INTEGER RANGE       limit the number of input order transactions
                                  to process  [x>=1]
  -a, --after-date [%Y-%m-%d]     only process transactions on or after this
                                  date (YYYY-MM-DD)
  -h, --help                      Show this message and exit.

Two order history formats are supported via --format:

  • azad (default): CSV exported by the azad extension in order view.
  • amazon-shopping-mcp: JSONL of OrderSummary objects exported by amazon-shopping-mcp. This format carries no recipient data, so gift detection is inactive for these orders.

Here's an example command:

amazon-lunchmoney -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco"

You'll probably want to dry run it first, to setup missing categories.

amazon-lunchmoney -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco" -d

OpenAI Costs

The most amazing thing about this approach is it costs effectively nothing.

In order to test the system, I ran this multiple times in dry-run mode against my full-year amazon transactions (~200). It consumed about 200k tokens, which is below the minimum billing threshold for OpenAI, so running this was free. Amazing.

Development

Update the package and run the tests:

just test
just lint

Or open up a repl and play around:

import os

from amazon_lunchmoney.formats import read_orders
from amazon_lunchmoney.lunchmoney import LunchMoneyClient

client = LunchMoneyClient(token=os.environ["LUNCH_MONEY_API_KEY"])

all_amazon_transactions = read_orders("path/to/amazon_order_history.csv", "azad")

You can log loudly as well:

LOG_LEVEL=debug amazon-lunchmoney -f '~/Downloads/amazon_order_history.csv' -c Shopping -n "Michael Bianco"

TODO

  • Indicate which purchases are HSA/FSA eligible and maybe generate receipt? This would need to be added to the scraper
  • Should match up refunds and categorize them appropriately

This project was created from iloveitaly/python-package-template

Metadata

Release files for amazon-lunchmoney 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for amazon-lunchmoney 0.1.0
File Size Uploaded Provenance
amazon_lunchmoney-0.1.0.tar.gz 14.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for amazon-lunchmoney 0.1.0
File Interpreter ABI Platform
amazon_lunchmoney-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 35.0 kB

Release files / amazon_lunchmoney-0.1.0.tar.gz

Download URL amazon_lunchmoney-0.1.0.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c23a196c446409a39a7d008667e8837b3435cf8f5b8e11b91cc2741a9d7ff725
BLAKE2b-256 checksum
How to use checksums
a5df8fa1bd10bce05795bb0df32311203276e39b8e182cb3d5794879691e7b5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / amazon_lunchmoney-0.1.0-py3-none-any.whl

Download URL amazon_lunchmoney-0.1.0-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4b138d39f05f342bca0420eb75ed05527c97cce259282cf22b46e00189c5fe7d
BLAKE2b-256 checksum
How to use checksums
fa1e46a4ed470123d2efb4dc8a54c13d0e9755ece1b61e04928e5e3efda917b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.19 {"installer":{"name":"uv","version":"0.12.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for amazon-lunchmoney 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page