Skip to main content

Amazon Invoice Downloader

PyPI - Version PyPI - Python Version


Table of Contents

What it does

This program amazon-invoice-downloader.py is a utility script that uses the Playwright library to spin up a Chromium instance and automate the process of downloading invoices for Amazon purchases within a specified date range. The script logs into Amazon using the provided email and password, navigates to the "Returns & Orders" section, and retrieves invoices for the specified year or date range.

The user can provide their Amazon login credentials either through command line arguments (--email= --password=) or as environment variables ($AMAZON_EMAIL and $AMAZON_PASSWORD).

The script accepts the date range either as a specific year (--year=) or as a date range (--date-range=). If no date range is provided, the script defaults to the current year.

Once the invoices are retrieved, they are saved as PDF files in a local "downloads" directory. The filename of each PDF is formatted as YYYYMMDD_<total>_amazon_<orderid>.pdf, where YYYYMMDD is the date of the order, total is the total amount of the order (with dollar signs and commas removed), and orderid is the unique Amazon order ID.

The program has a built-in "human latency" function, sleep(), to mimic human behavior by introducing random pauses between certain actions. This can help prevent the script from being detected and blocked as a bot by Amazon.

The script will skip downloading a file if it already exists in the ./downloads directory.

Installation

pip install amazon-invoice-downloader
playwright install

Usage

When running this program, Amazon may detect you are automation and introduce CAPTCHA's or make you login again. Just do so, and once successfully logged in, the script will continue.

$ amazon-invoice-downloader -h
Amazon Invoice Downloader

Usage:
  amazon-invoice-downloader.py \
    [--email=<email> --password=<password>] \
    [--year=<YYYY> | --date-range=<YYYYMMDD-YYYYMMDD>]
  amazon-invoice-downloader.py (-h | --help)

Login Options:
  --email=<email>          Amazon login email  [default: $AMAZON_EMAIL].
  --password=<password>    Amazon login password  [default: $AMAZON_PASSWORD].

Date Range Options:
  --date-range=<YYYYMMDD-YYYYMMDD>  Start and end date range
  --year=<YYYY>            Year, formatted as YYYY  [default: <CUR_YEAR>].

Options:
  -h --help                Show this screen.

Examples:
  amazon-invoice-downloader.py --year=2022  # This uses env vars $AMAZON_EMAIL and $AMAZON_PASSWORD
  amazon-invoice-downloader.py --date-range=20220101-20221231
  amazon-invoice-downloader.py --email=user@example.com --password=secret  # Defaults to current year
  amazon-invoice-downloader.py --email=user@example.com --password=secret --year=2022
  amazon-invoice-downloader.py --email=user@example.com --password=secret --date-range=20220101-20221231

License

amazon-invoice-downloader is distributed under the terms of the MIT license.

Metadata

Release files for amazon-invoice-downloader 0.4.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-invoice-downloader 0.4.0
File Size Uploaded
amazon_invoice_downloader-0.4.0.tar.gz 10.1 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for amazon-invoice-downloader 0.4.0
File Interpreter ABI Platform
amazon_invoice_downloader-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 10.1 MB

Release files / amazon_invoice_downloader-0.4.0.tar.gz

Download URL amazon_invoice_downloader-0.4.0.tar.gz
Size 10.1 MB
Tags Source
SHA-256 checksum
How to use checksums
1c536f511ca44b51c1f41e68a105618e13c44afe4edbf277c0878a66583c668d
BLAKE2b-256 checksum
How to use checksums
b51216ba49ef812c763429df4d0b6dcea4a62fc1bba3c7ca025e516fa053363d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release files / amazon_invoice_downloader-0.4.0-py3-none-any.whl

Download URL amazon_invoice_downloader-0.4.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdd5bdb372709eaa49d4e89cd489a7cce8fbdd25a2d2091cf29e21cd258c3f31
BLAKE2b-256 checksum
How to use checksums
ac3d42b13e734ddba89d2557a314067ecbde425408b53aa8ab4010031e60508a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-httpx/0.26.0

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

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