Download purchase invoice emails and PDF attachments from Gmail (read-only)
Project description
gmail-invoice
Download purchase invoice emails and PDF attachments from Gmail (read-only).
For a given date, the tool searches Gmail's Purchases category, saves each email as JSON, and downloads any PDF attachments into a dated folder in your current working directory.
Install
pip install gmail-invoice
Setup
-
Create a Google Cloud OAuth desktop client with the Gmail API enabled and download
credentials.json. -
Create a config folder outside this project (so credentials are not in your repo or workspace):
mkdir -p ~/.config/gmail-invoice mv ~/Downloads/credentials.json ~/.config/gmail-invoice/
-
Copy the sample env file, paste your config folder path, and save as
.env:cp .env.example .env
# .env — do not commit; do not share with AI assistants CONFIG_DIR=/Users/you/.config/gmail-invoice # Optional: where to write invoice folders (default: ./invoices_YYYY_MM_DD) # GMAIL_INVOICE_OUTPUT_DIR=./invoices_2026_05_24
Replace
/Users/youwith your username (or use the full expanded path to~/.config/gmail-invoice). On first run, OAuth will createtoken.jsonin that config folder.
Usage
# Today's purchase emails → ./invoices_YYYY_MM_DD/
gmail-invoice
# Specific date
gmail-invoice --date 2026-05-04
Equivalent module invocation:
python -m gmail_invoice --date 2026-05-04
Output
Each run creates a folder (default: invoices_YYYY_MM_DD/ in the current directory) containing:
email_YYYY_MM_DD_HH_MM_SS.json— sender, subject, body text*.pdf— invoice attachments with a timestamp suffix
Development
git clone https://github.com/nish/gmail-invoice.git
cd gmail-invoice
pip install -e ".[dev]"
pytest
ruff check .
gmail-invoice --date 2026-05-04
License
MIT
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 gmail_invoice-0.1.0.tar.gz.
File metadata
- Download URL: gmail_invoice-0.1.0.tar.gz
- Upload date:
- Size: 7.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29ec54bd8b4329a81bd8abfadc7363728cad6c2b2bb707640fc6cfc6c0b09876
|
|
| MD5 |
ccef7ad823a89da0e1facc366c004d7d
|
|
| BLAKE2b-256 |
3bc22addb279723b0f3f3237aeefb590190eb7f85fe5ae0abfd7cb9604f0c2b0
|
File details
Details for the file gmail_invoice-0.1.0-py3-none-any.whl.
File metadata
- Download URL: gmail_invoice-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
95c71429cd13abd2743091e8d728d85629cfcf890537c0e371462353df0699e0
|
|
| MD5 |
809faf75d4b8cf2660572f1d2b055b64
|
|
| BLAKE2b-256 |
7350615da7b2c6bca086a3bd2a319f939772a0464dad22c2593643868ea93c15
|