A Python libray (and CLI) for Amazon order history
Project description
amazon-orders is an unofficial library that provides a Python API (and CLI) for Amazon order history.
This package works by parsing data from Amazon's consumer-facing website. A periodic build validates functionality to ensure its stability, but as Amazon provides no official API to use, this package may break at any time (so check often to ensure you're on the latest version).
Only the English, .com version of Amazon is officially supported.
Installation
amazon-orders is available on PyPI and can be installed and/or upgraded using pip:
pip install amazon-orders --upgrade
That's it! amazon-orders is now available as a package to your Python projects and from the command line.
If pinning, be sure to use a wildcard for the minor version (ex. ==4.0.*, not ==4.0.18) to
ensure you always get the latest stable release.
Basic Usage
You'll use AmazonSession to
authenticate your Amazon account, then AmazonOrders
and AmazonTransactions
to interact with account data. get_order_history
and get_order are good places to start.
from amazonorders.session import AmazonSession
from amazonorders.orders import AmazonOrders
amazon_session = AmazonSession("<AMAZON_EMAIL>",
"<AMAZON_PASSWORD>")
amazon_session.login()
amazon_orders = AmazonOrders(amazon_session)
# Get orders from a specific year
orders = amazon_orders.get_order_history(year=2023)
# Or use time filters for recent orders
orders = amazon_orders.get_order_history(time_filter="last30") # Last 30 days
orders = amazon_orders.get_order_history(time_filter="months-3") # Past 3 months
for order in orders:
print(f"{order.order_number} - {order.grand_total}")
If the fields you're looking for aren't populated with the above, set full_details=True (or pass --full-details to
the history CLI command), since by default it is False (enabling it slows down querying, since an additional
request for each order is necessary). Have a look at the Order entity's docs to see what fields are only
populated with full details.
Command Line Usage
You can also run any command available to the main Python interface from the command line:
amazon-orders login
amazon-orders history --year 2023
amazon-orders history --last-30-days
amazon-orders history --last-3-months
Automating Authentication
Authentication can be automated by (in order of precedence) storing credentials in environment variables, passing them
to AmazonSession, or storing them
in AmazonOrdersConfig. The
environment variables amazon-orders looks for are:
AMAZON_USERNAMEAMAZON_PASSWORDAMAZON_OTP_SECRET_KEY(see docs for usage)
Documentation
For more advanced usage, amazon-orders's official documentation is available
at Read the Docs.
Contributing
If you would like to get involved, be sure to review the Contribution Guide.
Want to contribute financially? If you've found amazon-orders
useful, sponsorship would
also be greatly appreciated!
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 amazon_orders-4.0.18.tar.gz.
File metadata
- Download URL: amazon_orders-4.0.18.tar.gz
- Upload date:
- Size: 42.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4020e9fa07555262e4b6b6bcb22726a9059e73a65b74b82ebc00824cc0314368
|
|
| MD5 |
e9b692a947d2f62ab61722e66ffe6914
|
|
| BLAKE2b-256 |
0a2603d823483c1b1761bd269ce5adb784ce99ea0ccff610a185bda7bb789f3e
|
File details
Details for the file amazon_orders-4.0.18-py3-none-any.whl.
File metadata
- Download URL: amazon_orders-4.0.18-py3-none-any.whl
- Upload date:
- Size: 42.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9af5123098d3bfafed1d8e5f275c2d2b98d5fc04cd66b4a9e24e0f51032f32de
|
|
| MD5 |
5d4333fffdf8f4860f154a69b65dbb0e
|
|
| BLAKE2b-256 |
35b5e3eb25ceb595ea3a37e3922026b1dc46b6941a809f18ac0c35db8aa8b344
|