amazon-price-watch is a small Python CLI for tracking Amazon product prices, storing price history in SQLite, and optionally sending email alerts when a product drops below the price it had when you added it.
- Add an Amazon product to the local watch list from a product URL
- Store tracked products and price history in a SQLite database
- Update the latest price for every tracked product
- List tracked products, including current and lowest observed prices
- Remove tracked products by product ID
- Reset a tracked product by product ID, refreshing its initial price and price history
- Send an HTML email alert for products now cheaper than their original tracked price
- Write logs to both the console and
logs/app.log
- Python 3.10 or newer
- Internet access to fetch Amazon product pages
- SMTP credentials if you want to send email alerts
- Create and activate a virtual environment.
- Install dependencies from
requirements.txt.
python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txtEmail alerts are configured through a .env file in the project root.
Example:
APP_EMAIL_NAME="Amazon Price Watch"
APP_EMAIL_ADDR="your-email@example.com"
EMAIL_PASS="your-app-password"
EMAIL_SMTP_SERVER="smtp.example.com"
EMAIL_SMTP_PORT=587Notes:
- Use an app password or equivalent SMTP credential, not your normal mailbox password.
- The
.envfile is ignored by git. - Email settings are only needed when using
--send.
Run the main script with one of the supported options:
python amazon_price_watch.py --helppython amazon_price_watch.py --add "https://www.amazon.com/dp/ASIN"This fetches the product title and current price from Amazon, then stores:
- product URL
- product name
- price when added
- date added
- initial lowest price
- initial price history entry
python amazon_price_watch.py --remove 1This removes the product with the given ID from both the products and price_history tables.
python amazon_price_watch.py --reset_product 1This removes the product with the given ID, fetches it again from its stored URL, and recreates its initial product and price history records using the current Amazon price.
python amazon_price_watch.py --listThe output includes:
- product ID
- name
- URL
- price when added
- date added
- last recorded price
- date of the last recorded price
- lowest recorded price
- date of the lowest recorded price
python amazon_price_watch.py --updateThis fetches the current price for each tracked product and appends a new record to price_history. If the new price is the lowest seen so far, the products table is updated as well.
python amazon_price_watch.py --update --sendAfter updating prices, the script emails a summary of any products whose latest price is lower than the price recorded when they were first added.
The project creates these directories automatically:
database/for the SQLite database atdatabase/products.dblogs/for the rotating log file atlogs/app.log
Both directories are ignored by git.
amazon_price_watch.py Main CLI entry point
amazon.py Amazon scraping helpers
product_database.py SQLite database layer
send_email.py Email generation and delivery
logging_config.py Console and rotating file logging
templates/ HTML email templates
database/ Generated SQLite database
logs/ Generated log files
- Amazon page markup can change, which may break product name or price parsing.
- Some Amazon pages may block requests or return content that does not include the expected price fields.
- Alerts are triggered only when the latest price is lower than the original added price, not when the price merely drops relative to the previous check.