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-order-history-to-transactions Retail.OrderHistory.1.csv transactions.csv

Orders + returns combined:

amazon-order-history-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 .

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-order-history-to-transactions 0.1.1

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-order-history-to-transactions 0.1.1
File Size Uploaded
amazon_order_history_to_transactions-0.1.1.tar.gz 89.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for amazon-order-history-to-transactions 0.1.1
File Interpreter ABI Platform
amazon_order_history_to_transactions-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 124.8 kB

Release files / amazon_order_history_to_transactions-0.1.1.tar.gz

Download URL amazon_order_history_to_transactions-0.1.1.tar.gz
Size 89.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d679ea521db0cd9a467cc1a92d9b752a13592f11231394847704ba010a546727
BLAKE2b-256 checksum
How to use checksums
f0e0eb5af2e7799a63fb5df736634714bc787ddee58a0e388ae2fcbd50cc4130
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / amazon_order_history_to_transactions-0.1.1-py3-none-any.whl

Download URL amazon_order_history_to_transactions-0.1.1-py3-none-any.whl
Size 35.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d3f97b927a0e849145539d71ad206d7013d5697e3733144b43b5132eeca9ac7
BLAKE2b-256 checksum
How to use checksums
9aa8e442f1482bd684cdde1b522a628d67ff60e97719f47ee3af48dafc6f5bbc
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.1.1 This release

2 release files

0.1.0

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