API குறிப்பு

Auth & டோக்கன்கள்

அனைத்து GraphQL கோரிக்கைகளுக்கும் Authorization தலைப்பில் ஒரு Bearer டோக்கன் மற்றும் ஒரு c-id (கிளையன்ட் ID) தலைப்பு தேவை. இரண்டையும் PlainApp Settings → Sessions & API Tokens-இலிருந்து பெறுங்கள். ADB டோக்கன் தனித்தது மற்றும் Android ஆட்டோமேஷனில் HTTP சர்வரைத் தொடங்க அல்லது நிறுத்த மட்டுமே பயன்படுத்தப்படுகிறது — இதை Settings → Developer Options-இல் காணலாம்.

வகை வரையறைகள்

bash
# GraphQL requests must include both headers:
c-id: <client-id>
Authorization: Bearer <api-token>

# Endpoint : POST /graphql

செயல்பாடுகள்

http

API Token

PlainApp Settings → Sessions & API Tokens → API Tokens தாவலில் ஒரு API டோக்கனை உருவாக்கவும். ஒவ்வொரு டோக்கனுக்கும் ஒரு கிளையன்ட் ID மற்றும் ஒரு டோக்கன் மதிப்பு உள்ளது. இரண்டையும் கோரிக்கை தலைப்புகளாக அனுப்பவும்: கிளையன்ட் ID-க்கு c-id மற்றும் டோக்கனுக்கு Authorization: Bearer.

bash
# 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 } }"}'
app

ADB Token

ADB டோக்கன் ஆட்டோமேஷனுக்காக மட்டுமே பயன்படுத்தப்படுகிறது — adb broadcast மூலம் PlainApp HTTP சர்வரைத் தொடங்குதல் மற்றும் நிறுத்துதல். இதை PlainApp Settings → Developer Options-இல் காணலாம். இது GraphQL கோரிக்கைகளுக்கான Bearer டோக்கன் அல்ல.

bash
# 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>
app

plainapp-cli (AI Agent)

plainapp-cli என்பது ஒரு Rust கட்டளை-வரி கருவியாகும், இது ஒரு AI-அழைக்கக்கூடிய CLI-ஆக வடிவமைக்கப்பட்டுள்ளது. இதை எந்த AI முகவருக்கும் கொடுங்கள், அந்த முகவர் PlainApp GraphQL API வழியாக தொலைபேசி தரவு — தொடர்புகள், SMS, கோப்புகள், குறிப்புகள், அழைப்புகள் மற்றும் பல — ஆய்வு செய்து கட்டுப்படுத்தட்டும்.

bash
# 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"]}
}'