Skip to content

API

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=true is 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, where log_level can be info, warning, error, debug
  • Optional parameter: ?format=structured, when present outputs structured logs (with time, level, message, fields fields)
  • Response fields (standard mode, one JSON per line):
    • type: log level — info / warning / error / debug
    • payload: log message content
  • Response fields (structured mode ?format=structured):
    • time: time string in HH:MM:SS format
    • level: log level
    • message: log message content
    • fields: array of additional fields
  • 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 bytes
    • downTotal: cumulative downloaded bytes
  • Request method: GET / WS
  • Response fields (pushed once per second):
    • inuse: current memory in use (bytes)
    • oslimit: OS memory limit (bytes, always 0)
  • Request method: GET
  • Response fields:
    • meta: whether this is a Meta build (true / false)
    • version: version string
  • Request method: POST
  • Response: none (HTTP 204)
  • Request method: POST
  • Response: none (HTTP 204)
  • Request method: POST
  • Response: none (HTTP 204)
  • Request method: POST
  • Response: none (HTTP 204)
  • 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)
  • Request method: POST
  • Data: '{"path": "", "payload": ""}'
  • Response: none (HTTP 204)
  • Request method: POST
  • Data: '{"path": "", "payload": ""}'
  • Response: none (HTTP 204)
  • Request method: POST
  • Optional parameters: ?channel=xxx specifies the update channel, ?force=true forces the update
  • Data: '{"path": "", "payload": ""}'
  • Response fields:
    • status: fixed value "ok"
  • Request method: POST
  • Response fields:
    • status: fixed value "ok"
  • Request method: POST
  • Data: '{"path": "", "payload": ""}'
  • Response: none (HTTP 204)
  • Request method: POST
  • Request method: GET
  • Response fields:
    • proxies: array of policy group objects, each in the same format as /proxies/proxies_name
  • Request method: GET
  • Response fields: policy group object, same format as /proxies/proxies_name
  • 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}
  • Request method: GET
  • Request method: GET
  • Response: {"weights": [...]}
  • Request method: GET
  • Response fields:
    • proxies: object keyed by proxy/group name; every entry shares these common fields:
      • name: proxy or group name
      • type: type (e.g. Shadowsocks, VMess, DIRECT, Selector, URLTest, Fallback, LoadBalance, etc.)
      • udp: whether UDP is supported
      • uot: whether UDP over TCP is supported
      • xudp: whether XUDP is supported
      • tfo: whether TCP Fast Open is enabled
      • mptcp: whether MPTCP is enabled
      • smux: whether stream multiplexing is enabled
      • alive: whether the proxy is currently alive
      • history: array of delay history entries, each with time and delay (ms)
      • extra: extra delay histories grouped by test URL
      • interface: bound network interface name
      • routing-mark: routing mark value
      • provider-name: name of the proxy provider this proxy belongs to
      • dialer-proxy: underlying dialer proxy name
    • Policy groups (Selector, URLTest, Fallback, LoadBalance) additionally include:
      • now: currently selected node name (absent for LoadBalance)
      • all: array of all node/group names in the group
      • testUrl: health check URL
      • hidden: whether the group is hidden in the dashboard
      • icon: icon URL
      • emptyFallback: fallback node name used when all members are unavailable
      • expectedStatus: expected HTTP response status code for health checks (absent for Selector)
      • fixed: currently pinned node name (only URLTest and Fallback)
  • 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 include now, all, etc.)
  • Request method: PUT
  • Data: '{"name":"Japan"}'
  • Response: none (HTTP 204)
  • Request method: DELETE
  • Response: none (HTTP 204)
  • 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)
  • Request method: GET
  • Response fields:
    • providers: object keyed by provider name, each containing provider metadata and its proxy list
  • Request method: GET
  • Response fields: proxy provider object including configuration metadata and a proxies list
  • 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)
  • 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 content
      • proxy: target proxy or policy group name
      • size: number of entries in the rule set (only valid for GEOIP / GEOSITE, -1 otherwise)
      • extra (optional, when present includes):
        • disabled: whether the rule is disabled
        • hitCount: number of times the rule was matched
        • hitAt: timestamp of the last match
        • missCount: number of times the rule was not matched
        • missAt: timestamp of the last miss
  • Request method: PATCH
  • Data: '{"0": false,"1": true}'
  • Response: none (HTTP 204)
  • Request method: GET
  • Response fields:
    • providers: object keyed by rule provider name
  • Request method: PUT
  • Response: none (HTTP 204)
  • Request method: GET / WS
  • Optional parameter: ?interval=milliseconds, where milliseconds is the refresh interval, default value is 1000 milliseconds
  • Response fields:
    • downloadTotal: cumulative downloaded bytes
    • uploadTotal: cumulative uploaded bytes
    • memory: current memory usage (bytes)
    • connections: array of active connection objects, each containing:
      • id: unique connection ID
      • metadata: connection metadata (source/destination address, protocol, process name, etc.)
      • upload: bytes uploaded on this connection
      • download: bytes downloaded on this connection
      • start: connection start time
      • chains: proxy chain array
      • providerChains: provider proxy chain array
      • rule: matched rule type
      • rulePayload: matched rule content
  • Request method: DELETE
  • Response: none (HTTP 204)
  • Request method: DELETE
  • Response: none (HTTP 204)
  • Request method: DELETE
  • Response: none (HTTP 204)
  • Request method: GET
  • Parameter: ?name=example.com&type=A
  • Response fields:
    • Status: DNS response code (Rcode)
    • Question: array of query questions
    • TC: whether the response is truncated
    • RD: recursion desired flag
    • RA: recursion available flag
    • AD: authenticated data flag
    • CD: checking disabled flag
    • Answer (optional): array of answer records, each with name, type, TTL, data
    • Authority (optional): array of authority records, same format as Answer
    • Additional (optional): array of additional records, same format as Answer
  • Request method: GET
  • Response fields: any valid JSON value that was stored, or null if 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.

  • Request method: PUT
  • Response: none (HTTP 204)

Open in a browser http://${controller-api}/debug/pprof to view raw DEBUG information, where:

  • allocs indicates 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 heap report 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.
Terminal window
go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/heap

Full image

Terminal window
go tool pprof -http=:8080 http://127.0.0.1:xxxx/debug/pprof/allocs

Sample output

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.