Python SDK for the Gmail REST API
Project description
gmail-sdk
Python SDK for the Gmail REST API. Uses httpx directly — no google-api-python-client.
Install
pip install ldraney-gmail-sdk
Quick Start
from gmail_sdk import GmailClient
# Load token from ~/secrets/google-oauth/gmail-draneylucas.json
client = GmailClient(account="draneylucas")
print(client.get_profile())
# List unread messages
messages = client.list_messages(query="is:unread", max_results=5)
# Send an email
client.send_message(to="someone@example.com", subject="Hello", body="Hi there!")
# Reply to a message
client.reply(message_id="abc123", body="Thanks!")
# Send an HTML email
client.send_message(
to="someone@example.com",
subject="Hello",
body="Plain text fallback",
html_body="<h1>Hello!</h1><p>This is <b>HTML</b>.</p>",
)
# Reply-all, mark as read/unread
client.reply_all(message_id="abc123", body="Thanks everyone!")
client.mark_as_read(message_id="abc123")
client.mark_as_unread(message_id="abc123")
# List mailbox changes since a history ID (for incremental sync)
profile = client.get_profile()
changes = client.list_history(start_history_id=profile["historyId"])
First-Time Setup
Run the OAuth flow to authorize an account:
from gmail_sdk import GmailClient
client = GmailClient.authorize(account="draneylucas")
print(client.get_profile())
This opens a browser for Google sign-in and saves the token for future use.
Multi-Account
personal = GmailClient(account="draneylucas")
work = GmailClient(account="lucastoddraney")
dev = GmailClient(account="devopsphilosopher")
Configuration
- Secrets directory:
~/secrets/google-oauth/(override withsecrets_dir=orGMAIL_SECRETS_DIRenv var) - Credentials file:
{secrets_dir}/credentials.json - Token files:
{secrets_dir}/gmail-{account}.json
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_sdk_ldraney-0.1.3.tar.gz.
File metadata
- Download URL: gmail_sdk_ldraney-0.1.3.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1378d36c0a3421575794feeaaf0eeb864e919e053497d3fa9c2092c0bf5b303
|
|
| MD5 |
c9ada68d3329fd6cee46b8a43eb13f8e
|
|
| BLAKE2b-256 |
829b81cdf50aa0b0078fbebdcdcafc434cd40b786b318bebaa1dd50f2f0cab62
|
Provenance
The following attestation bundles were made for gmail_sdk_ldraney-0.1.3.tar.gz:
Publisher:
publish.yml on ldraney/gmail-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmail_sdk_ldraney-0.1.3.tar.gz -
Subject digest:
a1378d36c0a3421575794feeaaf0eeb864e919e053497d3fa9c2092c0bf5b303 - Sigstore transparency entry: 955111773
- Sigstore integration time:
-
Permalink:
ldraney/gmail-sdk@d3cbd915cc4f6dd6410a0aee32d021cc840d56dc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ldraney
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d3cbd915cc4f6dd6410a0aee32d021cc840d56dc -
Trigger Event:
push
-
Statement type:
File details
Details for the file gmail_sdk_ldraney-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gmail_sdk_ldraney-0.1.3-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28f05437930a21c34ef9808d1edc26b04282a463246713375646ae4569a7ffd3
|
|
| MD5 |
fbc360a8305c4aae777d9dc93ef0b199
|
|
| BLAKE2b-256 |
7b0c7fb424dd7b36b270bc3be5fc5f026d2467d865ec5b7997855eb8c96119ca
|
Provenance
The following attestation bundles were made for gmail_sdk_ldraney-0.1.3-py3-none-any.whl:
Publisher:
publish.yml on ldraney/gmail-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmail_sdk_ldraney-0.1.3-py3-none-any.whl -
Subject digest:
28f05437930a21c34ef9808d1edc26b04282a463246713375646ae4569a7ffd3 - Sigstore transparency entry: 955111776
- Sigstore integration time:
-
Permalink:
ldraney/gmail-sdk@d3cbd915cc4f6dd6410a0aee32d021cc840d56dc -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ldraney
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d3cbd915cc4f6dd6410a0aee32d021cc840d56dc -
Trigger Event:
push
-
Statement type: