Skip to main content
gmailstream

📧 Download Gmail messages matching your filters to local files 📥

gmailstream is a Python CLI for downloading Gmail messages through OAuth2. It uses named profiles so each export can keep its own Gmail search query, credentials, mode, and target directory.

Use it to archive full .eml messages or save attachments from messages matched by Gmail search filters such as from:, has:attachment, after:, labels, and other Gmail query syntax.

Install

git clone https://github.com/tsilva/gmailstream.git
cd gmailstream
uv tool install . --force --no-cache

Create and authorize a profile, then run it:

gmailstream profiles init my-profile
gmailstream --profile my-profile

The init flow prompts for a Gmail filter, output directory, download mode, and a Google OAuth credentials.json file. See Creating OAuth Credentials for the Google Cloud setup.

Commands

uv sync                                           # install development dependencies
uv tool install . --force --no-cache              # install the CLI from this checkout
gmailstream --profile <profile>                   # download new matching messages
gmailstream --profile <profile> --from 2024-01-01 # limit by start date
gmailstream --profile <profile> --to 2024-12-31   # limit by end date
gmailstream --verbose --profile <profile>         # enable debug logging
gmailstream --profile-dir /path --profile <name>  # use a custom profiles directory
gmailstream profiles list                         # list profiles
gmailstream profiles init <name>                  # create and authenticate a profile
gmailstream profiles show <name>                  # print profile config

Notes

  • Requires Python 3.12+ and uv.
  • Profiles live in ~/.config/gmailstream/profiles/ by default. Override this with --profile-dir or GMAIL_STREAMER_PROFILE_DIR.
  • Environment variables are loaded from ~/.config/gmailstream/.env when present. Existing shell environment variables take priority.
  • A profile can also be passed as a direct path to an existing profile directory.
  • The legacy gmailstream run <profile> command still works.
  • Each profile contains config.yaml, user-supplied credentials.json, and auto-generated token.json.
  • mode: full saves message.eml, attachments, and metadata.json. mode: attachments_only saves attachments plus metadata.json.
  • Downloads are organized under the target directory as YYYY-MM/YYYY-MM-DD - subject - shortid/.
  • Runs are incremental by default. Explicit --from or --to date ranges search that date range and skip files already present there.
  • credentials.json, token.json, and downloaded email exports are sensitive local files. On POSIX systems, gmailstream writes them with user-only permissions, and credentials/tokens are ignored by git.

Architecture

gmailstream architecture diagram

License

MIT

Metadata

Release files for gmailstream 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gmailstream 0.2.2
File Size Uploaded Provenance Actions
gmailstream-0.2.2.tar.gz 10.7 MB With provenance Details for gmailstream-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gmailstream 0.2.2
File Interpreter ABI Platform Actions
gmailstream-0.2.2-py3-none-any.whl Python 3 none any Details for gmailstream-0.2.2-py3-none-any.whl

Total release size: 10.7 MB

Release files / gmailstream-0.2.2.tar.gz

Download URL gmailstream-0.2.2.tar.gz
Size 10.7 MB
Tags Source
SHA-256 checksum
How to use checksums
892ceed0973244c794bb1e231cf61b01935ff4511e5f851170282d860092c769
BLAKE2b-256 checksum
How to use checksums
f0151c0e3c9a0a97e90ca192a2bc3c8105fb1b10ca8567a1fcdae18c3c9e00db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 6, 2026.

Transparency log

Release files / gmailstream-0.2.2-py3-none-any.whl

Download URL gmailstream-0.2.2-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f4ea378c60f845c1b68a0c39b8e1ff385197d7685374adf7445ce692f2c3ce93
BLAKE2b-256 checksum
How to use checksums
6d20646095a78eed596f52e54e3c591c34f1015e6e89659bb3b278b273bcca7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 6, 2026.

Transparency log

Security for gmailstream 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for gmailstream-0.2.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files Full provenance

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