Controller API Docs
The Clash / Mihomo core exposes a local RESTful API (the external controller) that dashboards and scripts use to fetch data and issue commands. Below are the request methods and response fields for around 30 endpoints, grouped by function.
Example Request
Every request a dashboard or script sends to the core must include an authentication header, formatted as follows:
curl -H 'Authorization: Bearer ${secret}' http://${controller-api}/configs?force=true \ -d '{"path": "", "payload": ""}' -X PUT
${secret}is thesecretkey set in your config file${controller-api}is theexternal-controllerlisten address set in your config file?force=trueis a query parameter required by some endpoints'{"path": "", "payload": ""}'is the resource data to update
If a request needs to pass a file path that isn't inside the mihomo working directory, you'll need to manually set the SAFE_PATHS environment variable to add it to the allowed paths. The syntax matches your OS's PATH variable (semicolon-separated on Windows, colon-separated elsewhere).
Logs
/logsGet real-time logs.
- Optional parameter
?level=log_level, wherelog_levelcan beinfo/warning/error/debug - Optional parameter
?format=structured; when included, outputs structured logs (withtime/level/message/fields) - Standard mode pushes one JSON object per line:
typeis the log level,payloadis the log message - Structured mode:
time(HH:MM:SS),level,message,fields(array of extra fields)
Traffic Info
/trafficGet real-time traffic. up/down are in bytes/second, upTotal/downTotal are in bytes, pushed once per second.
upcurrent upload ratedowncurrent download rateupTotalcumulative bytes uploadeddownTotalcumulative bytes downloaded
Memory Info
/memoryGet real-time memory usage (in bytes), pushed once per second.
inusecurrent memory in useoslimitsystem memory limit (always0)
Version Info
/versionGet core version info.
metawhether this is a Meta buildversionversion string
Cache
/cache/fakeip/flushClear the fake-ip cache. Returns HTTP 204.
/cache/dns/flushClear the DNS cache. Returns HTTP 204.
Runtime Config
/configsGet the current running config as a JSON object, including fields like port, socks-port, mixed-port, mode, log-level, allow-lan, ipv6, tun, and more.
/configsReload the base config, with the parameter ?force=true. Returns HTTP 204.
/configsPartially update the base config, e.g. '{"mixed-port": 7890}'. Returns HTTP 204.
/configs/geoUpdate the GEO database, with '{"path": "", "payload": ""}'. Returns HTTP 204.
/restartRestart the core, with '{"path": "", "payload": ""}'. Returns HTTP 204.
Updates
/upgradeUpdate the core. Optional ?channel=xxx to specify an update channel, or ?force=true to force the update. Returns {"status": "ok"}.
/upgrade/uiUpdate the dashboard (requires external-ui to be set in the config first). Returns {"status": "ok"}.
/upgrade/geoUpdate the GEO database. Returns HTTP 204.
Proxy Groups
/groupGet info for all proxy groups. Returns a proxies array, each item formatted the same as /proxies/{name}.
/group/{group_name}Get info for a specific proxy group, formatted the same as /proxies/{name}.
/group/{group_name}/delayTest the latency of every node in the proxy group. Returns fresh latency data and clears any current fixed selection on the auto-select group.
- Include the parameters
?url=xxx&timeout=5000 - Optional
?expected=xxx: the expected HTTP status code, supports range syntax like200/204or200-299 - Returns an object mapping node names to latency in milliseconds, e.g.
{"NodeA": 120, "NodeB": 350}
Proxies
/proxiesGet info for all proxies/proxy groups. Returns a proxies object keyed by name; common fields for every entry include:
name/type(e.g. Shadowsocks, VMess, DIRECT, Selector, URLTest, etc.)udp/uot/xudp/tfo/mptcp/smuxcapability flagsalivewhether it's currently reachable,historylatency history (time+delay),extraadditional history grouped by test URLinterface/routing-mark/provider-name/dialer-proxy- Proxy groups also include:
nowthe currently selected node (not present on LoadBalance),allthe member list,testUrl,hidden,icon,emptyFallback,expectedStatus(not present on Selector),fixed(URLTest/Fallback only)
/proxies/{name}Get info for a specific proxy/proxy group, with the same fields as above (a plain proxy only has the common fields).
/proxies/{name}Switch the currently selected node in this proxy group. Include '{"name":"Japan"}'. Returns HTTP 204.
/proxies/{name}Clear the fixed selection for this proxy/proxy group (not applicable to the Selector type). Returns HTTP 204.
/proxies/{name}/delayTest the latency of a specific proxy. Include ?url=xxx&timeout=5000 (optionally ?expected=xxx). Returns {"delay": 120}.
Proxy Providers
/providers/proxiesGet info for all proxy providers. Returns a providers object keyed by provider name, each containing metadata and a list of proxies.
/providers/proxies/{name}Get info for a specific proxy provider, including its config info and a proxies list.
/providers/proxies/{name}Update this proxy provider. Returns HTTP 204.
/providers/proxies/{name}/healthcheckTrigger a health check for this proxy provider. Returns HTTP 204.
/providers/proxies/{name}/{proxy_name}Get info for a specific proxy within a provider, with the same fields as /proxies/{name}.
/providers/proxies/{name}/{proxy_name}/healthcheckTest the latency of a specific proxy within a provider. Include ?url=xxx&timeout=5000. Returns {"delay": 120}.
Rules
/rulesGet all rules. Returns a rules array, each item containing:
indexindex (0-based)typerule typepayloadmatch contentproxytarget proxy/proxy groupsizenumber of entries in the rule (only meaningful for GEOIP/GEOSITE, otherwise-1)- Optional
extra:disabled/hitCount/hitAt/missCount/missAt
/rules/disableTemporarily enable/disable rules by index (resets on restart). Include '{"0": false,"1": true}'. Returns HTTP 204.
Rule Providers
/providers/rulesGet info for all rule providers. Returns a providers object keyed by name.
/providers/rules/{name}Update a specific rule provider. Returns HTTP 204.
Connections
/connectionsGet active connection info. Optional parameter ?interval=milliseconds (refresh interval, defaults to 1000ms).
downloadTotal/uploadTotalcumulative trafficmemorycurrent memory usageconnectionsarray of active connections:id,metadata(source/destination address, protocol, process name, etc.),upload/download,start,chains/providerChainsthe proxy chain,rule/rulePayloadthe matched rule
/connectionsClose all connections. Returns HTTP 204.
/connections/{id}Close a specific connection. Returns HTTP 204.
DNS Query
/dns/queryGet a DNS query result for a given name and type. Include ?name=example.com&type=A.
StatusDNS response codeQuestionarray of query questionsTC/RD/RA/AD/CDvarious DNS flag bits- Optional
Answer/Authority/Additional: arrays of records, each withname/type/TTL/data
Storage
/storage/{key}Get the stored value for a given key. Returns null if it doesn't exist.
/storage/{key}Write a value for a given key (must be valid JSON, max 1MB). Include '{"foo": "bar"}'. Returns HTTP 204.
/storage/{key}Delete the stored value for a given key. Returns HTTP 204.
DEBUG
The /debug endpoints require the core's startup log level to be set to debug.
/debug/gcTrigger a manual garbage collection. Returns HTTP 204.
/debug/pprofOpen http://${controller-api}/debug/pprof in your browser to view raw debug info:
- allocs: memory allocations per function call (stack/heap size and count), useful for tracking down memory leaks or frequent allocations
- heap: detailed heap memory usage, including the size, count, and address of allocated blocks sorted by size, useful for locating high memory usage
Install Graphviz to view a graphical report:
go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/heap go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/allocs
Visit http://${controller-api}/debug/pprof/heap?raw=true in your browser to download the report file — attach it to an issue if you need help troubleshooting.