Clash
  • Clash
  • RESTful API
    • Common
    • Proxies
    • Config
Powered by GitBook
On this page
  • 获取所有代理
  • 获取单个代理信息
  • 获取单个代理的延迟
  • 切换 Selector 中选中的代理
  1. RESTful API

Proxies

代理相关的 API

获取所有代理

GET /proxies

获取 Clash 中所有的代理

{
    "proxies": {
        "DIRECT": {
            "type": "Direct"
        },
        "GLOBAL": {
            "all": [
                "Proxy",
                "auto",
                "🇭🇰"
            ],
            "now": "Proxy",
            "type": "Selector"
        },
        "Proxy": {
            "all": [
                "auto",
                "🇭🇰"
            ],
            "now": "auto",
            "type": "Selector"
        },
        "REJECT": {
            "type": "Reject"
        },
        "auto": {
            "now": "🇭🇰",
            "type": "URLTest"
        },
        "🇭🇰": {
            "type": "Shadowsocks"
        }
    }
}

获取单个代理信息

GET /proxies/:name

获取 Clash 中单个代理的信息

Path Parameters

Name
Type
Description

name

string

代理名 (大小写敏感)

{
    "all": [
        "auto",
        "🇭🇰"
    ],
    "now": "auto",
    "type": "Selector"
}
{
    "error": "Proxy not found"
}

获取单个代理的延迟

GET /proxies/:name/delay

获取 Clash 中单个代理的延迟

Path Parameters

Name
Type
Description

name

string

代理名 (大小写敏感)

Query Parameters

Name
Type
Description

timeout

number

超时时间 (ms)

url

string

测试代理的目标网址

{
    "delay": 200
}
{
    "error": "Format error"
}
{
    "error": "Proxy not found"
}
{
    "error": "Proxy delay test timeout"
}

切换 Selector 中选中的代理

PUT /proxies/:name

当前接口只支持切换 Selector 中的代理

Path Parameters

Name
Type
Description

name

string

代理名称 (大小写敏感)

Request Body

Name
Type
Description

name

string

要切换的代理名字

请求格式错误
{
    "error": "Format error"
}
请求代理类型错误
{
    "error": "Proxy can't update"
}
{
    "error": "Proxy not found"
}
PreviousCommonNextConfig

Last updated 6 years ago