Skip to main content

Convert exported Amazon order and return history into something close to credit card transactions.

Why

To better track my finances, I wanted to identify which Amazon orders / products each of my credit card transactions corresponded to so I could categorize the transactions and figure out where my spending is going.

Amazon has a transactions page, but it does not allow navigating directly to specific time periods, instead requiring you to hit the 'Next' page button as many times as needed to go back in time. Worse, you cannot link to transactions pages as they do not modify the URL, so if you lose your place (or Amazon gives the dreaded "you have no transactions" error) and you have to start all over again.

There are other tools like the Chrome extension Amazon Order History Reporter (Azad) which can export your order history by scraping Amazon pages, but I found them all to output lots of missing data to the point of being nearly unusable. To be fair, Amazon order history and transacions pages are an ever moving target.

Working directly with official Amazon exported data like this script does is much easier and in principle fully complete. Plus it comes in a convenient CSV format that you may find useful for your own quick lookups and analysis.

I personally use this tool to track my spending with Lunch Money, categorizing Amazon transactions based on what I bought. In the near future I plan to create a tool that makes use of the exported data from this tool to directly update corresponding transactions in Lunch Money since it has an open API.

Quick Start

  1. Export your Amazon order history (may take an hour or longer): https://www.amazon.com/hz/privacy-central/data-requests/preview.html
  2. While you wait, install this script using pipx install ., uv tool install ., or a similar Python app manager.
  3. Once export is complete, download the resulting ZIP file and extract the Retail.OrderHistory.1.csv and Retail.OrdersReturned.Payments.1.csv files, ideally to the same location as the script to avoid specifiying paths.
  4. Run the script, pointing it to your files and desired output filename.
  5. Done! The output transactions CSV file will not perfectly match you credit card transactions since Amazon sometimes charges one transaction per shipment and other times charges the whole order as one transaction. Hence the reason both transaction amounts (cost of a shipment or refund) and overall order totals are given.

Usage

Order transactions only:

amazon-orders-to-transactions Retail.OrderHistory.1.csv transactions.csv

Orders + returns combined:

amazon-orders-to-transactions Retail.OrderHistory.1.csv transactions.csv --returns Retail.OrdersReturned.Payments.1.csv

Output

The script produces a CSV file with the following columns:

Column Description
Ship Date Date when the order shipped (YYYY-MM-DD format). For returns, this is the refund completion date.
Order ID Amazon order identifier that links to the original order
Transaction Amount Total amount charged/refunded for a single shipment/return. Positive values are charges, negative values are refunds.
Order Total Total cost of the entire order (sum of all items for that Order ID). Useful when the whole order was charged to your card as one transaction, rather than one transaction per shipment.
Product Names Semicolon-separated list of product names. Each product name is truncated to 60 characters max for readability.
Order URL Direct link to Amazon order details page

Transaction Grouping

The script groups individual order items into transactions based on:

  • Order ID + Shipment Item Subtotal (to handle partial charges/refunds)
  • Items with the same Order ID and subtotal amount are combined into a single transaction row
  • Product names from grouped items are concatenated with semicolons

Example Output

Ship Date,Order ID,Transaction Amount,Order Total,Product Names,Order URL
2025-08-10,111-1111111-1111111,-13.99,61.58,Watermelon,https://amazon.com/gp/your-account/order-details?orderID=111-1111111-1111111
2025-08-05,111-1111111-1111111,61.58,61.58,Watermelon; Organic Red Onion,https://amazon.com/gp/your-account/order-details?orderID=111-1111111-1111111
2025-08-04,222-2222222-2222222,25.99,25.99,Wireless Headphones,https://amazon.com/gp/your-account/order-details?orderID=222-2222222-2222222

Note: Returns appear as separate rows with negative Transaction Amount values, but maintain the same Order Total as the original order for context.

Develop

To make development easier, I prefer to install via pipx with the --editable flag so that all updates to the code automatically reflect in the installed tool:

pipx install --editable .

To run tests:

uv run -m pytest

Publishing to PyPI

The package is configured for PyPI publication. To publish a new version:

  1. Update version in pyproject.toml
  2. Build the package:
    uv run python -m build
    
  3. Validate the build:
    uv run python -m twine check dist/*
    
  4. Upload to PyPI:
    # Test upload (recommended first)
    uv run python -m twine upload --repository testpypi dist/*
    
    # Production upload
    uv run python -m twine upload dist/*
    

Prerequisites:

  • PyPI account with API token configured
  • Install dev dependencies: uv sync --group dev

Metadata

Release files for amazon-orders-to-transactions 0.2.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-orders-to-transactions 0.2.0
File Size Uploaded
amazon_orders_to_transactions-0.2.0.tar.gz 89.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for amazon-orders-to-transactions 0.2.0
File Interpreter ABI Platform
amazon_orders_to_transactions-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 124.7 kB

Release files / amazon_orders_to_transactions-0.2.0.tar.gz

Download URL amazon_orders_to_transactions-0.2.0.tar.gz
Size 89.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6f4ce5d572152b26a5bbb4d90dd9a76238e214378341eb5797ad250e10322d48
BLAKE2b-256 checksum
How to use checksums
9e529fe14a4307e6e23787cb2acbe69134c5f021d3af8eaeef380e94d910eb35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / amazon_orders_to_transactions-0.2.0-py3-none-any.whl

Download URL amazon_orders_to_transactions-0.2.0-py3-none-any.whl
Size 35.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c9cf98fc7c74a77d47e396542828815c05734f3a1e83829e26702a5810dbbda5
BLAKE2b-256 checksum
How to use checksums
a1ebdb025f13c5cfeb83c7fd03fe441ae45823d3ee26bab3d1861614133e2653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

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