> For the complete documentation index, see [llms.txt](https://clash.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clash.gitbook.io/doc/restful-api/config.md).

# Config

## &#x20;获得当前的基础设置

<mark style="color:blue;">`GET`</mark> `/configs`

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "port": 7890,
    "socket-port": 7891,
    "redir-port": 0,
    "allow-lan": true,
    "mode": "Rule",
    "log-level": "info"
}
```

{% endtab %}
{% endtabs %}

## &#x20;增量修改配置

<mark style="color:purple;">`PATCH`</mark> `/configs`

\
传入需要修改的配置即可<br>

#### Request Body

| Name       | Type    | Description                                       |
| ---------- | ------- | ------------------------------------------------- |
| port       | integer | HTTP 代理端口                                         |
| socks-port | integer | Socks5 代理端口                                       |
| redir-port | string  | Redir 代理端口                                        |
| allow-lan  | boolean | 是否把代理监听地址放到 0.0.0.0                               |
| mode       | string  | 代理模式 ( Global \| Rule \| Direct )                 |
| log-level  | string  | 设置 TTY 日志等级 ( info \| warning \| error \| debug ) |

{% tabs %}
{% tab title="204
由于可能出现 RESTful API 流量经过代理的问题，而更换端口需要 Graceful Shutdown

所以统一返回 204 No Content
" %}

```


```

{% endtab %}
{% endtabs %}

## &#x20;重新加载配置文件

<mark style="color:orange;">`PUT`</mark> `/configs`

这个接口不会影响 external-controller 和 secret 的值

#### Query Parameters

| Name  | Type    | Description |
| ----- | ------- | ----------- |
| force | boolean | 改变端口等信息     |

#### Request Body

| Name | Type   | Description |
| ---- | ------ | ----------- |
| path | string | 配置文件完整路径    |

{% tabs %}
{% tab title="200 " %}

```
```

{% endtab %}
{% endtabs %}

## &#x20;获取所有已经解析的规则

<mark style="color:blue;">`GET`</mark> `/rules`

{% tabs %}
{% tab title="200 " %}

```javascript
{
    "rules": [
        { "type": "DomainSuffix", "payload": "google.com", "proxy": "Proxy" },
        { "type": "DomainKeyword", "payload": "google", "proxy": "Proxy" },
        { "type": "GEOIP", "payload": "CN", "proxy": "DIRECT" },
        { "type": "IPCIDR", "payload": "91.108.4.0/22", "proxy": "Proxy" },
        { "type": "FINAL", "payload": "", "proxy": "Proxy" }
    ]
}
```

{% endtab %}
{% endtabs %}
