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.1.1.tar.gz (11.9 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.1.1-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: thanakan_mail-0.1.1.tar.gz
  • Upload date:
  • Size: 11.9 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.1.1.tar.gz
Algorithm Hash digest
SHA256 76273c86281d39db153b190ceb8c361fe1c4a454fc088e8313a2ae6ff7271d7a
MD5 a80e9e8c9aefaea7cf583ef0517a7b64
BLAKE2b-256 dbe6d3c0d0c4a3ec958797f5702d050bd1ce272f920a01e9eacc317f97e8a5f7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: thanakan_mail-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d2038a780ebec334a0806fedbc6f508d4f0a55dcbaa6ce0a06f8d4445eb9b005
MD5 d2e2e537b391cbfb1b39cc9110114ee8
BLAKE2b-256 adc20adce5dd169739d7110cee0cf739408dd435bc3133741ba0938ff095ca67

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