認証とトークン
すべての GraphQL リクエストは、Authorization ヘッダーに Bearer token を、c-id (クライアント ID) ヘッダーにクライアント ID を含める必要があります。両方とも PlainApp Settings → Sessions & API Tokens から取得できます。ADB token は個別のもので、Android オートメーションで HTTP サーバーを開始または停止するためだけに使用されます——Settings → Developer Options で確認できます。
型定義
# GraphQL requests must include both headers:
c-id: <client-id>
Authorization: Bearer <api-token>
# Endpoint : POST /graphql操作
API Token
PlainApp Settings → Sessions & API Tokens → API Tokens タブで API token を作成します。各 token にはクライアント ID と token 値が含まれます。両方をリクエストヘッダーとして送信します:c-id にはクライアント ID を、Authorization: Bearer には token を指定します。
# On your Android device:
# 1. Open PlainApp
# 2. Go to Settings → Sessions & API Tokens
# 3. Open the "API Tokens" tab
# 4. Tap + to create a new token
# 5. Copy the c-id and token values shown
curl --request POST \
--url http://192.168.1.100:8080/graphql \
--header 'c-id: <your-client-id>' \
--header 'Authorization: Bearer <your-api-token>' \
--header 'Content-Type: application/json' \
--data '{"query":"{ chatItems { content } }"}'ADB Token
ADB token は Android オートメーション専用です——adb broadcast を介して PlainApp HTTP サーバーを開始および停止します。PlainApp Settings → Developer Options で確認できます。GraphQL リクエスト用の Bearer token ではありません。
# Start the HTTP server
adb shell am broadcast -a com.ismartcoding.plain.action.START_HTTP_SERVER -p com.ismartcoding.plain --es token <your-adb-token>
# Stop the HTTP server
adb shell am broadcast -a com.ismartcoding.plain.action.STOP_HTTP_SERVER -p com.ismartcoding.plain --es token <your-adb-token>plainapp-cli (AI Agent)
plainapp-cli は、AI から呼び出し可能な CLI として設計された Rust 製コマンドラインツールです。シェルコマンドを実行できる任意の AI agent に渡すことで、その agent が PlainApp GraphQL API を介して連絡先、SMS、ファイル、メモ、通話などの携帯電話のデータを検査・制御できるようになります。
# Install (macOS & Linux one-liner)
bash <(curl -fsSL https://raw.githubusercontent.com/plainhub/plainapp-cli/main/install.sh)
# Or build from source (requires Rust ≥ 1.75)
cargo install --path .
# --- Setup ---
# 1. Open PlainApp → Settings → Sessions & API Tokens → API Tokens tab
# 2. Tap + to create a token, note the Client ID and Token
# 3. Run to generate config:
plainapp-cli --init
# Edit ~/.config/plainapp-cli/config.toml:
# api_url = "https://192.168.1.100:8443"
# client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# token = "BASE64_ENCODED_32_BYTE_TOKEN"
# --- Usage ---
# Fetch the full GraphQL schema (for AI introspection)
plainapp-cli --schema
# Execute any GraphQL query or mutation
plainapp-cli --exec '<json>'
# Examples:
# List SMS conversations
plainapp-cli -e '{"query":"{ smses(limit:20,offset:0) { id address body date } }","variables":null}'
# List notes
plainapp-cli -e '{"query":"{ app { battery sdcardPath } }","variables":null}'
# Delete a file
plainapp-cli -e '{
"query": "mutation DeleteFiles($paths:[String!]!) { deleteFiles(paths:$paths) }",
"variables": {"paths":["/sdcard/tmp/test.txt"]}
}'