API¶
Request Example¶
Curl example: curl -H 'Authorization: Bearer ${secret}' http://${controller-api}/configs?force=true -d '{"path": "", "payload": ""}' -X PUT
This request includes the header 'Authorization: Bearer ${secret}', where:
${secret}is the API key set in the configuration file api${controller-api}is the API listening address set in the configuration file api?force=trueis a parameter that needs to be included in certain requests'{"path": "", "payload": ""}'is the data for the resource to be updated
Note
If you need to pass a path, please note that if the path is not in the mihomo working directory, please manually set the SAFE_PATHS environment variable to add it to the safe path. The syntax of this environment variable is the same as the PATH environment variable parsing rules of this operating system (i.e., semicolon-separated in Windows and colon-separated in other systems).
Logs¶
/logs¶
Retrieve real-time logs
- Request method:
GET/WS - Optional parameter:
?level=log_level, wherelog_levelcan beinfo,warning,error,debug
Traffic Information¶
/traffic¶
Retrieve real-time traffic, measured in kbps
- Request method:
GET/WS
Memory Information¶
/memory¶
Retrieve real-time memory usage, measured in kb
- Request method:
GET/WS
Version Information¶
/version¶
Retrieve the Clash version
- Request method:
GET
Cache¶
/cache/fakeip/flush¶
Clear the fake IP cache
- Request method:
POST
/cache/dns/flush¶
Clear the DNS cache
- Request method:
POST
Running Configuration¶
/configs¶
Retrieve basic configuration
- Request method:
GET
Reload basic configuration
- Request method:
PUT - Parameter:
?force=true
Update basic configuration
- Request method:
PATCH - Data:
'{"mixed-port": 7890}'
/configs/geo¶
Update the GEO database
- Request method:
POST - Data:
'{"path": "", "payload": ""}'
/restart¶
Restart the kernel
- Request method:
POST - Data:
'{"path": "", "payload": ""}'
Updates¶
/upgrade¶
Update the kernel
- Request method:
POST - Data:
'{"path": "", "payload": ""}'
/upgrade/ui¶
Update the panel; external-ui must be set
- Request method:
POST
/upgrade/geo¶
Update the GEO database
- Request method:
POST - Data:
'{"path": "", "payload": ""}'
Policy Groups¶
/group¶
Retrieve policy group information
- Request method:
GET
/group/group_name¶
Retrieve specific policy group information
- Request method:
GET
Clear the fixed selection of the automatic policy group
- Request method:
DELETE
/group/group_name/delay¶
Test the nodes/strategy groups within the specified strategy group, return new latency information, and clear the fixed selection of the automatic strategy group
- Request method:
GET - Parameter:
?url=xxx&timeout=5000
Proxies¶
/proxies¶
Retrieve proxy information
- Request method:
GET
/proxies/proxies_name¶
Retrieve specific proxy information
- Request method:
GET
Select a specific proxy
- Request method:
PUT - Data:
'{"name":"Japan"}'
/proxies/proxies_name/delay¶
Test a specified proxy and return new delay information
- Request method:
GET - Parameter:
?url=xxx&timeout=5000
Proxy Sets¶
/providers/proxies¶
Retrieve all information for all proxy sets
- Request method:
GET
/providers/proxies/providers_name¶
Retrieve information for a specific proxy set
- Request method:
GET
Update the proxy set
- Request method:
PUT
/providers/proxies/providers_name/healthcheck¶
Trigger a health check for a specific proxy set
- Request method:
GET
/providers/proxies/providers_name/proxies_name/healthcheck¶
Test a specified proxy within the proxy set and return new delay information
- Request method:
GET - Parameter:
?url=xxx&timeout=5000
Rules¶
/rules¶
Retrieve rule information
- Request method:
GET
Rule Sets¶
/providers/rules¶
Retrieve all information for all rule sets
- Request method:
GET
/providers/rules/providers_name¶
Update the rule set
- Request method:
PUT
Connections¶
/connections¶
Retrieve connection information
- Request method:
GET/WS - Optional parameter:
?interval=milliseconds, wheremillisecondsis the refresh interval, default value is 1000 milliseconds
Close all connections
- Request method:
DELETE
/connections/:id¶
Close a specific connection
- Request method:
DELETE
Domain Query¶
/dns/query¶
Retrieve DNS query data for a specified name and type
- Request method:
GET - Parameter:
?name=example.com&type=A
DEBUG¶
/debug requires the kernel to be started with the log level set to debug.
/debug/gc¶
Perform active garbage collection
- Request method:
PUT
/debug/pprof¶
Open in a browser http://${controller-api}/debug/pprof to view raw DEBUG information, where:
allocsindicates memory allocation for each function call, including the size of memory allocated on the stack and heap, as well as the number of allocations. This report is primarily to help identify memory leaks and frequent memory requests in the code.- The
heapreport provides detailed information about memory usage on the heap, including the size, number, and address of allocated memory blocks, sorted by size. This report is mainly to locate areas of excessive memory usage; we can check object sizes in the heap report to find areas of high memory consumption.
Install Graphviz to view graphical debug information.¶
View Graphical Heap Report¶
View Graphical Allocs Report¶
Submit Output Report¶
Access http://${controller-api}/debug/pprof/heap?raw=true in a browser to download this file, and upload it to issues to report any problems you encounter.