Skip to main content

Download Thai bank PDF statements from email (Gmail)

Project description

thanakan-mail

Download Thai bank PDF statements from email (Gmail).

Features

  • OAuth 2.0 authentication with Gmail API
  • Download PDF statement attachments from KBank, BBL, and SCB emails
  • Filter by bank-specific sender addresses and filename patterns
  • Extensible provider architecture for future email services

Environment Variables

  • GMAIL_CLIENT_SECRET: Path to Google OAuth client_secret.json (required)
  • GMAIL_TOKEN_PATH: Path to store OAuth token (default: ~/.thanakan/gmail_token.json)

CLI Usage

# Authenticate with Gmail
thanakan mail auth

# Download statements from a specific bank
thanakan mail download kbank
thanakan mail download bbl --output ./statements
thanakan mail download scb --max 50

# Download from all supported banks
thanakan mail download all

# Download and parse PDFs in one step
thanakan mail download kbank --parse

Library Usage

from thanakan_mail import GmailProvider, StatementDownloader, BANK_CONFIGS

# Initialize provider and downloader
provider = GmailProvider()
downloader = StatementDownloader(provider, BANK_CONFIGS["kbank"], "./downloads")

# Download statements
results = downloader.download_statements(max_emails=100, verbose=True)

# Check results
for result in results:
    print(f"Email: {result.message.subject}")
    print(f"  Downloaded: {result.downloaded_files}")
    print(f"  Skipped: {result.skipped_attachments}")
    print(f"  Errors: {result.errors}")

Setup

  1. Create a Google Cloud project and enable the Gmail API
  2. Create OAuth 2.0 credentials (Desktop application)
  3. Download the client_secret.json file
  4. Set the GMAIL_CLIENT_SECRET environment variable to the file path
  5. Run thanakan mail auth to complete OAuth flow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thanakan_mail-0.2.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thanakan_mail-0.2.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file thanakan_mail-0.2.0.tar.gz.

File metadata

  • Download URL: thanakan_mail-0.2.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for thanakan_mail-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c2ce3ee6d789b7ba203905a243cd16adc7cea1e10af7d9ee4f00a36a3d21b8d4
MD5 26d0be1c59b07d75e9e8c4ab0593d7a5
BLAKE2b-256 9d14c0c8f954dbd88f4f066a9c42a2c231a55e21cb0e438ade234bfe4ab0606f

See more details on using hashes here.

File details

Details for the file thanakan_mail-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: thanakan_mail-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for thanakan_mail-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18966a86be80c778106faafffd66f79e3b341d6628f1ce3ecf8d14062e75ec95
MD5 d6a4d11a0ca992276d735774be42b01e
BLAKE2b-256 46d87aff23b4009850aec503cddfef9976769e54c9e192baed2130ec9b529f86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page