Skip to content

HTTP API

Sam MG Harish edited this page Sep 27, 2026 · 3 revisions

HTTP API

Base URL is the local server, e.g. http://127.0.0.1:8000. Interactive docs at /api/docs, OpenAPI document at /api/openapi.json.

CORS allows http://localhost and http://127.0.0.1 with and without ports 5173 and 8000, credentials disabled. The server binds loopback only.

System

GET /api/health

{"ok": true}

GET /api/version

{"name": "lu77U-MobileSec", "version": "0.1.4"}

Both values come from pyproject.toml; nothing carries a second copy.

GET /api/status

Readiness gate for scanning. Polled by the dashboard; its access-log lines are filtered out of the terminal.

{"jadx_configured": true, "ollama_configured": true,
 "blutter_configured": false, "hermes_decomp_configured": false,
 "rn_decompiler_configured": false,
 "ready_for_analysis": true}

ollama_configured refers to the active provider, whichever it is. The name is historical.

The three decompiler flags are informational; none factor into ready_for_analysis. A scan of the matching framework without its tool still runs; it degrades to a detection-only report. See Configuration.

Scans

POST /api/scans

multipart/form-data, exactly one of:

Field Type Notes
file file Filename must end in .apk
path string Absolute path to a local .apk inside the user's home directory
{"id": "9f2c1a7b4d0e"}
Status Cause
400 Prerequisites not configured. detail carries message and the full status object
400 Not an .apk, path outside the home directory, file not found, or neither field supplied

An uploaded filename is reduced to a safe basename: directory components stripped, characters outside A-Za-z0-9._ - replaced with _, .apk appended if missing. A supplied path is resolved with symlinks followed, then checked against the home directory on a separator boundary. The APK is copied into the scan folder; the original is never analyzed in place.

GET /api/scans

{"scans": [ScanMeta, ...]}

Newest first, read by globbing meta.json under the output base.

GET /api/scans/{scan_id}

{"meta": ScanMeta, "result": ScanResult | null}

404 if unknown. result is null until the scan completes, except for a stopped or paused scan, which stores a partial result (see Reports).

GET /api/scans/{scan_id}/logs

The scan's complete log, oldest first, read from scan.log. The WebSocket replays only a bounded backlog, so this is how the UI shows the whole history, including for a scan that finished before the page opened, or ran in a previous server process. The file is written in verbose runs only.

Query: limit (optional, most recent N).

{"scan_id": "9f2c1a7b4d0e", "count": 1842,
 "logs": [{"ts": "2026-08-13T10:15:02+00:00", "message": "..."}],
 "persisted": true}

persisted distinguishes "this scan produced no output" from "nothing was written down", which look identical from an empty list.

404 if the scan is unknown. Read on a worker thread.

GET /api/scans/{scan_id}/logs/download

The raw scan.log, as a text/plain attachment so a browser does not render a multi-megabyte file inline. 404 when the scan is unknown or no log was recorded.

POST /api/scans/{scan_id}/stop

Signals a queued or running scan to stop, without deleting it. Terminal.

{"stopping": "9f2c1a7b4d0e"}

404 unknown, 400 not active.

POST /api/scans/{scan_id}/pause

Stops the scan at its next checkpoint and keeps everything, so it can be resumed. meta.status becomes paused with pause_reason: "user".

{"pausing": "9f2c1a7b4d0e"}

404 unknown, 400 not running.

POST /api/scans/{scan_id}/resume

Re-queues a paused scan. It continues from checkpoint/, skipping completed stages and regions that already reported.

{"resuming": "9f2c1a7b4d0e"}
Status Cause
404 Unknown scan
400 Scan is not paused
400 Could not be resumed (typically the uploaded APK is no longer on disk)

DELETE /api/scans/{scan_id}

Cancels the scan if running, waits up to 10 seconds for the worker to unwind, then deletes the folder.

{"deleted": "9f2c1a7b4d0e"}

GET /api/scans/{scan_id}/report/{fmt}

fmt is json, html or pdf. Generated on request from the stored result and streamed as an attachment; nothing is cached server-side.

The download filename comes from the app name, the package name, or the stored filename stem, with unsafe characters replaced.

Status Cause
404 Unknown format, or no stored result
400 pdf requested while pdf_generation is disabled
500 PDF conversion failed (missing WeasyPrint or Edge)

PDF conversion runs on a worker thread; the temporary file is deleted after the response is sent.

WS /api/ws/scans/{scan_id}

Streams scan events. On connect the server sends the current meta, then replays the event backlog (up to 3000 events), then live events.

type Payload
meta {"meta": ScanMeta}
log {"message": "..."}
progress {"phase": "...", "percent": 0-100, "message": "..."}
status {"status": "running" | "paused" | "completed" | "failed" | "cancelled", "error"?: "..."}

Every event also carries scan_id and an ISO-8601 UTC ts.

The socket is accepted even for an unknown scan id; it simply produces no events.

Devices

GET /api/devices

{"devices": [{"serial": "emulator-5554", "model": "sdk_gphone64_arm64",
              "android_version": "13", "is_emulator": true}]}

GET /api/devices/{serial}/apps

{"packages": ["com.example.app", "..."]}

GET /api/devices/{serial}/checks

Runs the real readiness checks. Root is checked first, then the Frida check and the HTTPS check run concurrently on separate threads. The whole call runs on a worker thread and takes several seconds.

{
  "root": {"ok": true, "message": "Root access available"},
  "frida": {"ok": true, "message": "Frida 16.7.19 running; 143 processes visible."},
  "mitmproxy": {"ok": false, "message": "No HTTPS traffic captured — ..."}
}

These perform the same operations a scan performs, including pushing and starting frida-server and installing the mitmproxy CA, so a green result means what it means inside a completed scan. frida-server is stopped again afterwards.

Settings

GET /api/settings

Full snapshot. Secrets are never included; each provider carries masked previews and a count.

{
  "active_provider": "ollama",
  "provider_order": ["ollama", "claude", "openai", "gemini", "custom",
                     "claude_cli", "copilot_cli", "kimi_cli", "codex_cli", "antigravity_cli"],
  "providers": {
    "ollama": {"name": "ollama", "display_name": "Ollama (local or cloud)",
               "model": "glm-4.6:cloud", "mode": "cloud", "base_url": null,
               "cloud_host": "https://api.ollama.com", "local_host": "http://localhost:11434",
               "max_concurrent_requests": 2,
               "has_api_key": true, "api_key_count": 2,
               "api_keys": [{"index": 0, "masked": "sk-…abcd"},
                            {"index": 1, "masked": "sk-…wxyz"}],
               "default_model": "glm-4.6:cloud", "needs_api_key": true}
  },
  "jadx_path": "/opt/homebrew/bin/jadx",
  "blutter_path": "",
  "hermes_decomp_path": "",
  "rn_decompiler_path": "",
  "output_dir": "",
  "output_dir_default": "/Users/you/Documents/lu77U-MobileSec",
  "dynamic_verification": true,
  "agent_memory": true,
  "pdf_generation": true,
  "auto_resume": true,
  "agent_budget": {"max_steps_per_region": 40, "max_minutes": 45},
  "agent_budget_limits": {"max_steps_per_region": [0, 500], "max_minutes": [0, 480]},
  "max_concurrent_requests_range": [1, 20],
  "status": {"jadx_configured": true, "ollama_configured": true,
             "blutter_configured": false, "hermes_decomp_configured": false,
             "rn_decompiler_configured": false, "ready_for_analysis": true}
}

PUT /api/settings

Partial update. Only the keys present are applied.

Key Type
active_provider string, one of the ten provider names (5 API-key: ollama, claude, openai, gemini, custom; 5 CLI: claude_cli, copilot_cli, kimi_cli, codex_cli, antigravity_cli)
jadx_path string
blutter_path, hermes_decomp_path, rn_decompiler_path string. Optional; see Configuration
output_dir string, empty resets to the default
dynamic_verification, agent_memory, pdf_generation, auto_resume boolean
agent_budget {max_steps_per_region?, max_minutes?}, clamped to agent_budget_limits
providers {provider: {model?, mode?, base_url?, max_concurrent_requests?, binary_path?}}

Returns the fresh snapshot. 400 with a message for an unknown provider, a rejected base_url, or an out-of-range numeric field.

POST /api/settings/credentials

Appends one key to the provider's pool.

{"provider": "openai", "api_key": "sk-..."}

A null or blank api_key clears the whole pool. Responds {"ok": true, "provider": "openai"}.

DELETE /api/settings/credentials/{provider}/{index}

Removes one key from the pool by index.

{"ok": true, "provider": "openai"}

POST /api/settings/credentials/{provider}/reveal

Returns one stored key in full.

{"index": 0}
{"provider": "openai", "index": 0, "key": "sk-..."}

POST rather than GET so the key travels in the request body. A URL is the one place a secret ends up in browser history and access logs even on loopback-only, single-user use.

GET /api/settings/models/{provider}

{"provider": "openai", "models": ["gpt-4o", "..."]}

Live listing where it is cheap, curated list otherwise. Any failure falls back to the curated list rather than erroring — except custom, which has no curated list at all and falls back to the single model configured for it (or [] if none is set).

GET /api/settings/cli-status/{provider}

For one of the five CLI-backed providers: whether its binary resolves on this machine, and the sign-in hint to show if not.

{"cli_binary": "claude", "cli_resolved_path": "/usr/local/bin/claude",
 "cli_found": true, "signed_in": true, "detail": null,
 "signin_hint": "Run `claude` once in a terminal and complete the browser sign-in."}

signed_in comes from actually invoking the provider's own validate_credentials(), not just checking the binary exists — a probe failure or a not-signed-in CLI reports signed_in: false with detail explaining why, even when cli_found is true. Resolution follows the same rule the provider itself uses when it actually runs — an explicit binary_path when configured, a PATH lookup otherwise — so this cannot report a provider ready that then fails to start. 400 for a provider that is not CLI-backed.

POST /api/settings/test

{"provider": "openai"}

provider may be null to test the active one. Constructs the provider and calls validate_credentials().

{"ok": false, "provider": "openai", "model": "gpt-4o",
 "error": "Validation failed — check key/base URL/model/network."}

Error text is deliberately generic. Provider exception messages can carry request URLs, file paths and credentials, so the detail goes to the server-side verbose log.

Prompts

Endpoint Behaviour
GET /api/settings/prompts Every editable prompt with id, label, help, default, current, is_custom
PUT /api/settings/prompts/{prompt_id} Body {"text": "..."}. Saves an override. 400 for an unknown id or blank text
DELETE /api/settings/prompts/{prompt_id} Reverts to the built-in default

Prompt ids: static_agent_system, flutter_agent_system, react_native_agent_system, cordova_agent_system, xamarin_agent_system, java_kotlin_legacy, dynamic_verification_system.

Skills

Endpoint Behaviour
GET /api/settings/skills {"skills": [{"name", "filename", "size", "source"}]}, source is user or builtin
POST /api/settings/skills Multipart file upload of a .md file

Upload rules: extension .md, stem matching ^[A-Za-z0-9_-]+$, valid UTF-8, under 200 KB.

Uploads are written to <config dir>/skills/, not into the installed package, so they survive upgrades. The response reports overwritten when it replaced an earlier upload and shadows_builtin when a bundled skill of the same name now sits behind it.

SPA

GET /{full_path:path} serves the built single-page app. /assets is mounted separately from web/static/assets. Any other path is resolved against web/static by matching each segment against a directory listing, so .., absolute paths and symlinked escapes cannot match; unmatched paths fall back to index.html with Cache-Control: no-store so client-side routes work on reload.

If no build is present, the route returns a small placeholder page explaining how to build the frontend.

Clone this wiki locally