API
Request Example
Section titled “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
- Request method:
GET/WS - Optional parameter:
?level=log_level, wherelog_levelcan beinfo,warning,error,debug - Optional parameter:
?format=structured, when present outputs structured logs (withtime,level,message,fieldsfields) - Response fields (standard mode, one JSON per line):
type: log level —info/warning/error/debugpayload: log message content
- Response fields (structured mode
?format=structured):time: time string inHH:MM:SSformatlevel: log levelmessage: log message contentfields: array of additional fields
Traffic Information
Section titled “Traffic Information”/traffic
Section titled “/traffic”- Request method:
GET/WS - Response fields (pushed once per second):
up: current upload rate (bytes/s)down: current download rate (bytes/s)upTotal: cumulative uploaded bytesdownTotal: cumulative downloaded bytes
Memory Information
Section titled “Memory Information”/memory
Section titled “/memory”- Request method:
GET/WS - Response fields (pushed once per second):
inuse: current memory in use (bytes)oslimit: OS memory limit (bytes, always0)
Version Information
Section titled “Version Information”/version
Section titled “/version”- Request method:
GET - Response fields:
meta: whether this is a Meta build (true/false)version: version string
/cache/fakeip/flush
Section titled “/cache/fakeip/flush”- Request method:
POST - Response: none (HTTP 204)
/cache/dns/flush
Section titled “/cache/dns/flush”- Request method:
POST - Response: none (HTTP 204)
/cache/smart/flush 👻
Section titled “/cache/smart/flush 👻”- Request method:
POST - Response: none (HTTP 204)
/cache/smart/flush/:config 👻
Section titled “/cache/smart/flush/:config 👻”- Request method:
POST - Response: none (HTTP 204)
Running Configuration
Section titled “Running Configuration”/configs
Section titled “/configs”- Request method:
GET - Response fields: JSON object of the current running configuration, including
port,socks-port,mixed-port,mode,log-level,allow-lan,ipv6,tun, and other fields
- Request method:
PUT - Parameter:
?force=true - Response: none (HTTP 204)
- Request method:
PATCH - Data:
'{"mixed-port": 7890}' - Response: none (HTTP 204)
/configs/geo
Section titled “/configs/geo”- Request method:
POST - Data:
'{"path": "", "payload": ""}' - Response: none (HTTP 204)
/restart
Section titled “/restart”- Request method:
POST - Data:
'{"path": "", "payload": ""}' - Response: none (HTTP 204)
Updates
Section titled “Updates”/upgrade
Section titled “/upgrade”- Request method:
POST - Optional parameters:
?channel=xxxspecifies the update channel,?force=trueforces the update - Data:
'{"path": "", "payload": ""}' - Response fields:
status: fixed value"ok"
/upgrade/ui
Section titled “/upgrade/ui”- Request method:
POST - Response fields:
status: fixed value"ok"
/upgrade/geo
Section titled “/upgrade/geo”- Request method:
POST - Data:
'{"path": "", "payload": ""}' - Response: none (HTTP 204)
/upgrade/lgbm 👻
Section titled “/upgrade/lgbm 👻”- Request method:
POST
Policy Groups
Section titled “Policy Groups”/group
Section titled “/group”- Request method:
GET - Response fields:
proxies: array of policy group objects, each in the same format as/proxies/proxies_name
/group/group_name
Section titled “/group/group_name”- Request method:
GET - Response fields: policy group object, same format as
/proxies/proxies_name
/group/group_name/delay
Section titled “/group/group_name/delay”- Request method:
GET - Parameter:
?url=xxx&timeout=5000 - Optional parameter:
?expected=xxx, the expected HTTP response status code, supports ranges (e.g.200/204,200-299) - Response fields: JSON object mapping node names to their latency in milliseconds (
uint16), e.g.{"Node A": 120, "Node B": 350}
/group/weights 👻
Section titled “/group/weights 👻”- Request method:
GET
/group/group_name/weights 👻
Section titled “/group/group_name/weights 👻”- Request method:
GET - Response:
{"weights": [...]}
Proxies
Section titled “Proxies”/proxies
Section titled “/proxies”- Request method:
GET - Response fields:
proxies: object keyed by proxy/group name; every entry shares these common fields:name: proxy or group nametype: type (e.g.Shadowsocks,VMess,DIRECT,Selector,URLTest,Fallback,LoadBalance, etc.)udp: whether UDP is supporteduot: whether UDP over TCP is supportedxudp: whether XUDP is supportedtfo: whether TCP Fast Open is enabledmptcp: whether MPTCP is enabledsmux: whether stream multiplexing is enabledalive: whether the proxy is currently alivehistory: array of delay history entries, each withtimeanddelay(ms)extra: extra delay histories grouped by test URLinterface: bound network interface namerouting-mark: routing mark valueprovider-name: name of the proxy provider this proxy belongs todialer-proxy: underlying dialer proxy name
- Policy groups (
Selector,URLTest,Fallback,LoadBalance) additionally include:now: currently selected node name (absent forLoadBalance)all: array of all node/group names in the grouptestUrl: health check URLhidden: whether the group is hidden in the dashboardicon: icon URLemptyFallback: fallback node name used when all members are unavailableexpectedStatus: expected HTTP response status code for health checks (absent forSelector)fixed: currently pinned node name (onlyURLTestandFallback)
/proxies/proxies_name
Section titled “/proxies/proxies_name”- Request method:
GET - Response fields: proxy or group object, same fields as a single entry under
/proxies(regular proxies have only the common fields; policy groups additionally includenow,all, etc.)
- Request method:
PUT - Data:
'{"name":"Japan"}' - Response: none (HTTP 204)
- Request method:
DELETE - Response: none (HTTP 204)
/proxies/proxies_name/delay
Section titled “/proxies/proxies_name/delay”- Request method:
GET - Parameter:
?url=xxx&timeout=5000 - Optional parameter:
?expected=xxx, the expected HTTP response status code, supports ranges (e.g.200/204,200-299) - Response fields:
delay: measured latency in milliseconds (uint16)
Proxy Sets
Section titled “Proxy Sets”/providers/proxies
Section titled “/providers/proxies”- Request method:
GET - Response fields:
providers: object keyed by provider name, each containing provider metadata and its proxy list
/providers/proxies/providers_name
Section titled “/providers/proxies/providers_name”- Request method:
GET - Response fields: proxy provider object including configuration metadata and a
proxieslist
- Request method:
PUT - Response: none (HTTP 204)
/providers/proxies/providers_name/healthcheck
Section titled “/providers/proxies/providers_name/healthcheck”- Request method:
GET - Response: none (HTTP 204)
/providers/proxies/providers_name/proxies_name
Section titled “/providers/proxies/providers_name/proxies_name”- Request method:
GET - Response fields: proxy object, same fields as
/proxies/proxies_name
/providers/proxies/providers_name/proxies_name/healthcheck
Section titled “/providers/proxies/providers_name/proxies_name/healthcheck”- Request method:
GET - Parameter:
?url=xxx&timeout=5000 - Response fields:
delay: measured latency in milliseconds (uint16)
/rules
Section titled “/rules”- Request method:
GET - Response fields:
rules: array of rule objects, each containing:index: rule index (0-based)type: rule type (e.g.DOMAIN,IP-CIDR,GEOIP, etc.)payload: rule match contentproxy: target proxy or policy group namesize: number of entries in the rule set (only valid forGEOIP/GEOSITE,-1otherwise)extra(optional, when present includes):disabled: whether the rule is disabledhitCount: number of times the rule was matchedhitAt: timestamp of the last matchmissCount: number of times the rule was not matchedmissAt: timestamp of the last miss
/rules/disable
Section titled “/rules/disable”- Request method:
PATCH - Data:
'{"0": false,"1": true}' - Response: none (HTTP 204)
Rule Sets
Section titled “Rule Sets”/providers/rules
Section titled “/providers/rules”- Request method:
GET - Response fields:
providers: object keyed by rule provider name
/providers/rules/providers_name
Section titled “/providers/rules/providers_name”- Request method:
PUT - Response: none (HTTP 204)
Connections
Section titled “Connections”/connections
Section titled “/connections”- Request method:
GET/WS - Optional parameter:
?interval=milliseconds, wheremillisecondsis the refresh interval, default value is 1000 milliseconds - Response fields:
downloadTotal: cumulative downloaded bytesuploadTotal: cumulative uploaded bytesmemory: current memory usage (bytes)connections: array of active connection objects, each containing:id: unique connection IDmetadata: connection metadata (source/destination address, protocol, process name, etc.)upload: bytes uploaded on this connectiondownload: bytes downloaded on this connectionstart: connection start timechains: proxy chain arrayproviderChains: provider proxy chain arrayrule: matched rule typerulePayload: matched rule content
- Request method:
DELETE - Response: none (HTTP 204)
/connections/:id
Section titled “/connections/:id”- Request method:
DELETE - Response: none (HTTP 204)
/connections/smart/:id 👻
Section titled “/connections/smart/:id 👻”- Request method:
DELETE - Response: none (HTTP 204)
Domain Query
Section titled “Domain Query”/dns/query
Section titled “/dns/query”- Request method:
GET - Parameter:
?name=example.com&type=A - Response fields:
Status: DNS response code (Rcode)Question: array of query questionsTC: whether the response is truncatedRD: recursion desired flagRA: recursion available flagAD: authenticated data flagCD: checking disabled flagAnswer(optional): array of answer records, each withname,type,TTL,dataAuthority(optional): array of authority records, same format asAnswerAdditional(optional): array of additional records, same format asAnswer
Storage
Section titled “Storage”/storage/key
Section titled “/storage/key”- Request method:
GET - Response fields: any valid JSON value that was stored, or
nullif the key does not exist
- Request method:
PUT - Data:
'{"foo": "bar"}' - Response: none (HTTP 204)
- Request method:
DELETE - Response: none (HTTP 204)
/debug requires the kernel to be started with the log level set to debug.
/debug/gc
Section titled “/debug/gc”- Request method:
PUT - Response: none (HTTP 204)
/debug/pprof
Section titled “/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.
Section titled “Install Graphviz to view graphical debug information.”View Graphical Heap Report
Section titled “View Graphical Heap Report”go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/heapView Graphical Allocs Report
Section titled “View Graphical Allocs Report”go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/allocsSubmit Output Report
Section titled “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.