HTTP APIHTTP API
内核在本机开了一组接口,脚本可以驱动它。The kernel exposes a loopback API your scripts can drive.
内核启动后监听 127.0.0.1:8199(可在设置里改)。除订阅导出外的接口都要求本机访问;/api/* 还需要请求头 X-API-Key。
把监听地址改成 0.0.0.0 会让同一局域网的设备也能访问这些接口,API Key 也随之暴露风险。默认的 127.0.0.1 是更安全的选择。
订阅导出
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /sub/all.yaml | 节点列表,App 导出「完整配置」时读的就是它 |
| GET | /all.yaml | 同上,兼容老地址 |
curl http://127.0.0.1:8199/all.yaml
返回体形如:
proxies:
- name: "HK-01 | NF-US"
type: ss
server: 203.0.113.10
port: 8388
cipher: aes-256-gcm
password: "******"
检测控制
| 方法 | 路径 | 说明 |
|---|---|---|
| POST | /api/trigger-check | 触发一轮检测,需要 API Key |
| GET | /api/status | 当前阶段与进度 |
| GET | /api/results | 本轮结果 |
| GET | /api/logs | 内核日志,返回 {"logs": [...]} |
curl -X POST -H "X-API-Key: <key>" \
http://127.0.0.1:8199/api/trigger-check
curl -H "X-API-Key: <key>" http://127.0.0.1:8199/api/status
API Key 在 App 的「设置 → API Key」里查看;若 config.yaml 的 api-key 为空,内核启动时会自动生成一个并写回。
状态字段
/api/status 反映三段流水线的进度,字段与概览页的三根进度条一一对应:
| 字段 | 含义 |
|---|---|
total | 本轮待测节点总数 |
aliveDone / alivePass | 测活已完成 / 通过 |
mediaDone | 媒体检测已完成(分母是 alivePass) |
filterPass | 通过过滤、即将进入测速的数量 |
speedDone / speedPass | 测速已完成 / 达标(分母是 filterPass) |
1.2.6 修正了概览页测速进度的分母:原来用节点总数,现在用 filterPass,与「已测速 / 可用节点」的直觉一致。
本 App 不提供的接口
上游在内核里开了 Sub-Store 时才会额外生成 /mihomo.yaml、/base64.txt 和 /export/:target 的各种格式。本 App 把 Sub-Store 关掉了,所以这些路径不可用 —— 需要完整 mihomo 配置或 Base64 订阅,请用 App 内的导出功能生成文件。
从电脑访问手机上的内核
临时调试可用 adb 端口转发,不必改监听地址:
adb reverse tcp:8199 tcp:8199
curl http://127.0.0.1:8199/all.yaml
抓取订阅到本地文件:
curl -s http://127.0.0.1:8199/all.yaml -o all.yaml
Once running, the kernel listens on 127.0.0.1:8199 (configurable in Settings). Everything except subscription export is loopback-only, and /api/* additionally requires the X-API-Key header.
Binding 0.0.0.0 exposes these endpoints to your whole LAN, and the API key with them. The default 127.0.0.1 is the safer choice.
Subscription export
| Method | Path | Notes |
|---|---|---|
| GET | /sub/all.yaml | Node list; this is what the app reads for a "full config" export |
| GET | /all.yaml | Same, legacy path |
curl http://127.0.0.1:8199/all.yaml
The response looks like:
proxies:
- name: "HK-01 | NF-US"
type: ss
server: 203.0.113.10
port: 8388
cipher: aes-256-gcm
password: "******"
Controlling a check
| Method | Path | Notes |
|---|---|---|
| POST | /api/trigger-check | Start a round; needs the API key |
| GET | /api/status | Current stage and progress |
| GET | /api/results | Results of the current round |
| GET | /api/logs | Kernel log as {"logs": [...]} |
curl -X POST -H "X-API-Key: <key>" \
http://127.0.0.1:8199/api/trigger-check
curl -H "X-API-Key: <key>" http://127.0.0.1:8199/api/status
Find the key in Settings → API key. When api-key is empty in config.yaml, the kernel generates one on startup and writes it back.
Status fields
/api/status mirrors the three pipeline stages shown as progress bars on the Overview screen:
| Field | Meaning |
|---|---|
total | Nodes queued for this round |
aliveDone / alivePass | Liveness finished / passed |
mediaDone | Media checks finished (denominator is alivePass) |
filterPass | Passed filtering, about to be speed-tested |
speedDone / speedPass | Speed tests finished / above threshold (denominator is filterPass) |
1.2.6 fixed the denominator of the speed progress: it used the total node count before, now it uses filterPass, matching "tested / available".
Endpoints this app does not expose
Upstream only generates /mihomo.yaml, /base64.txt and the various /export/:target formats when Sub-Store is enabled inside the kernel. This app disables Sub-Store, so none of those paths exist — use the in-app export for a full mihomo config or a Base64 subscription.
Reaching the phone from a computer
For quick debugging, forward the port instead of changing the listen address:
adb reverse tcp:8199 tcp:8199
curl http://127.0.0.1:8199/all.yaml
Saving the subscription locally:
curl -s http://127.0.0.1:8199/all.yaml -o all.yaml