Auth और टोकन
सभी GraphQL अनुरोधों के लिए Authorization हेडर में एक Bearer टोकन और एक c-id (क्लाइंट ID) हेडर आवश्यक है। दोनों को PlainApp Settings → Sessions & API Tokens से प्राप्त करें। ADB टोकन अलग है और केवल 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 टोकन बनाएँ। प्रत्येक टोकन का एक क्लाइंट ID और एक टोकन मान होता है। दोनों को अनुरोध हेडर के रूप में भेजें: क्लाइंट ID के लिए c-id और टोकन के लिए Authorization: Bearer।
# 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 टोकन का उपयोग विशेष रूप से Android ऑटोमेशन के लिए होता है — adb broadcast के माध्यम से PlainApp HTTP सर्वर शुरू और बंद करना। इसे PlainApp Settings → Developer Options में पाएँ। यह GraphQL अनुरोधों के लिए Bearer टोकन नहीं है।
# 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 एक Rust कमांड-लाइन टूल है जिसे एक AI-कॉलेबल CLI के रूप में डिज़ाइन किया गया है। इसे किसी भी AI एजेंट को दें जो शेल कमांड चला सकता है, ताकि एजेंट 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"]}
}'