跳转到主要内容
Jmail Jmail Python 客户端是一个单文件实现,无需安装任何依赖。它使用 PEP 723 内联依赖,因此一切都由 uv run 自动处理。

环境配置

无需安装。只需使用 uv 来运行:
uv run clients/python/jmail.py emails --head 5
或在你自己的脚本中将其作为库使用:
from jmail import JmailClient

client = JmailClient()
df = client.emails()

库的使用

基本用法

from jmail import JmailClient

client = JmailClient()

# All emails with full body text
df = client.emails()

# Network-only (no body text, much smaller download)
df = client.emails(slim=True)

# 包含完整提取文本的文档(下载分片文件)
docs = client.documents(include_text=True)

# Photos, people, and facial recognition data
photos = client.photos()
people = client.people()
faces = client.photo_faces()

# iMessage conversations and messages
convos = client.imessage_conversations()
messages = client.imessage_messages()

# Crowd-sourced star counts
stars = client.star_counts()

# Release batch metadata
batches = client.release_batches()

获取原始 URL

可与 DuckDB、Polars 或其他工具一起使用:
url = client.url("emails-slim")
# → "https://data.jmail.world/v1/emails-slim.parquet"

url = client.url("emails-slim", fmt="ndjson.gz")
# → "https://data.jmail.world/v1/emails-slim.ndjson.gz"

禁用缓存

# 始终下载最新版本(不使用本地缓存)
client = JmailClient(cache=False)

命令行界面参考

Usage: uv run jmail.py <command> [options]

Commands:
  manifest          Print manifest JSON
  emails            Download emails (--slim for network-only, --head N)
  documents         Download documents (--include-text for full text, --head N)
  photos            Download photos metadata (--head N)
  people            Download people (--head N)
  photo_faces       Download photo face data (--head N)
  imessage_conversations  Download iMessage conversations (--head N)
  imessage_messages       Download iMessage messages (--head N)
  star_counts       Download star counts (--head N)
  release_batches   Download release batches (--head N)
  urls              Print all dataset URLs
  duckdb-examples   Print example DuckDB SQL queries

Options:
  --head N          Show first N rows
  --slim            (emails) Omit body text columns
  --include-text    (documents) Include full extracted text
  --no-cache        Skip local caching, always download fresh

示例

# First 10 emails, network-only view
uv run jmail.py emails --slim --head 10

# All documents with full text
uv run jmail.py documents --include-text

# 打印数据集 URL 供其他地方使用
uv run jmail.py urls

# Get manifest with dataset checksums
uv run jmail.py manifest

# Fresh download (skip cache)
uv run jmail.py emails --no-cache --head 5

依赖项

该客户端有三个依赖项,由 uv 自动管理:
  • pandas — DataFrame 处理
  • pyarrow — Parquet 文件读取
  • requests — HTTP 下载
这些依赖项通过 PEP 723 以内联方式声明:
# /// script
# requires-python = ">=3.9"
# dependencies = ["pandas", "pyarrow", "requests"]
# ///