Skip to content

Commit 76a1683

Browse files
committed
update api
1 parent 4b16f9a commit 76a1683

4 files changed

Lines changed: 384 additions & 243 deletions

File tree

docs/api/index.en.md

Lines changed: 124 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -17,242 +17,286 @@ This request includes the header `'Authorization: Bearer ${secret}'`, where:
1717
- `?force=true` is a parameter that needs to be included in certain requests
1818
- `'{"path": "", "payload": ""}'` is the data for the resource to be updated
1919

20-
In most cases, the data passed is `'{"path": "", "payload": ""}'`, which can include a new configuration file path.
21-
2220
!!! note
23-
Note that if the path is not in the Clash 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).
21+
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).
2422

2523
## Logs
2624

2725
### `/logs`
2826

29-
Request method: `GET`
30-
31-
- Retrieve real-time logs.
32-
33-
### `/logs?level=log_level`
34-
35-
Request Method: `GET`
27+
!!! info ""
28+
Retrieve real-time logs
3629

37-
- Retrieve logs of a specified level. Possible values: info, debug, warning, error
30+
- Request method: `GET` / `WS`
31+
- Optional parameter: `?level=log_level`, where `log_level` can be `info`, `warning`, `error`, `debug`
3832

3933
## Traffic Information
4034

4135
### `/traffic`
4236

43-
Request method: `GET`
37+
!!! info ""
38+
Retrieve real-time traffic, measured in kbps
4439

45-
- Retrieve real-time traffic, measured in kbps.
40+
- Request method: `GET` / `WS`
4641

4742
## Memory Information
4843

4944
### `/memory`
5045

51-
Request method: `GET`
46+
!!! info ""
47+
Retrieve real-time memory usage, measured in kb
5248

53-
- Retrieve real-time memory usage, measured in kb.
49+
- Request method: `GET` / `WS`
5450

5551
## Version Information
5652

5753
### `/version`
5854

59-
Request method: `GET`
55+
!!! info ""
56+
Retrieve the Clash version
6057

61-
- Retrieve the Clash version.
58+
- Request method: `GET`
6259

6360
## Cache
6461

6562
### `/cache/fakeip/flush`
6663

67-
Request method: `POST`
64+
!!! info ""
65+
Clear the fake IP cache
6866

69-
- Clear the fake IP cache.
67+
- Request method: `POST`
68+
69+
### `/cache/dns/flush`
70+
71+
!!! info ""
72+
Clear the DNS cache
73+
74+
- Request method: `POST`
7075

7176
## Running Configuration
7277

7378
### `/configs`
7479

75-
Request method: `GET`
80+
!!! info ""
81+
Retrieve basic configuration
7682

77-
- Retrieve basic configuration.
83+
- Request method: `GET`
7884

79-
Request method: `PUT`
85+
!!! info ""
86+
Reload basic configuration
8087

81-
- Reload basic configuration; data must be sent, and the URL must include `?force=true` to enforce execution.
88+
- Request method: `PUT`
89+
- Parameter: `?force=true`
8290

83-
Request method: `PATCH`
91+
!!! info ""
92+
Update basic configuration
8493

85-
- Update basic configuration; data must be sent in the format `'{"mixed-port": 7890}'`, modified as needed for the configuration items to be updated.
94+
- Request method: `PATCH`
95+
- Data: `'{"mixed-port": 7890}'`
8696

8797
### `/configs/geo`
8898

89-
Request method: `POST`
99+
!!! info ""
100+
Update the GEO database
90101

91-
- Update the GEO database; data must be sent.
102+
- Request method: `POST`
103+
- Data: `'{"path": "", "payload": ""}'`
92104

93105
### `/restart`
94106

95-
Request method: `POST`
107+
!!! info ""
108+
Restart the kernel
96109

97-
- Restart the kernel; data must be sent.
110+
- Request method: `POST`
111+
- Data: `'{"path": "", "payload": ""}'`
98112

99113
## Updates
100114

101115
### `/upgrade`
102116

103-
Request method: `POST`
117+
!!! info ""
118+
Update the kernel
104119

105-
- Update the kernel; data must be sent.
120+
- Request method: `POST`
121+
- Data: `'{"path": "", "payload": ""}'`
106122

107123
### `/upgrade/ui`
108124

109-
Request method: `POST`
125+
!!! info ""
126+
Update the panel; [external-ui](../config/general.md#external-user-interface) must be set
110127

111-
- Update the panel; [external-ui](../config/general.md#external-user-interface) must be set.
128+
- Request method: `POST`
112129

113130
### `/upgrade/geo`
114131

115-
Request method: `POST`
132+
!!! info ""
133+
Update the GEO database
116134

117-
- Update the GEO database; data must be sent.
135+
- Request method: `POST`
136+
- Data: `'{"path": "", "payload": ""}'`
118137

119138
## Policy Groups
120139

121140
### `/group`
122141

123-
Request method: `GET`
142+
!!! info ""
143+
Retrieve policy group information
124144

125-
- Retrieve policy group information.
145+
- Request method: `GET`
126146

127147
### `/group/group_name`
128148

129-
Request method: `GET`
149+
!!! info ""
150+
Retrieve specific policy group information
130151

131-
- Retrieve specific policy group information.
152+
- Request method: `GET`
132153

133-
Request method: `DELETE`
154+
!!! info ""
155+
Clear the fixed selection of the automatic policy group
134156

135-
- Clear the fixed selection of the automatic policy group.
157+
- Request method: `DELETE`
136158

137159
### `/group/group_name/delay`
138160

139-
Request method: `GET`
161+
!!! info ""
162+
Test the nodes/strategy groups within the specified strategy group, return new latency information, and clear the fixed selection of the automatic strategy group
140163

141-
- Test the nodes/strategy groups within the specified strategy group, return new latency information, and clear the fixed selection of the automatic strategy group
142-
- the URL must include `?url=xxx&timeout=5000`, modified as needed.
164+
- Request method: `GET`
165+
- Parameter: `?url=xxx&timeout=5000`
143166

144167
## Proxies
145168

146169
### `/proxies`
147170

148-
Request method: `GET`
171+
!!! info ""
172+
Retrieve proxy information
149173

150-
- Retrieve proxy information.
174+
- Request method: `GET`
151175

152176
### `/proxies/proxies_name`
153177

154-
Request method: `GET`
178+
!!! info ""
179+
Retrieve specific proxy information
155180

156-
- Retrieve specific proxy information.
181+
- Request method: `GET`
157182

158-
Request method: `PUT`
183+
!!! info ""
184+
Select a specific proxy
159185

160-
- Select a specific proxy; data must be included in the format `'{"name":"Japan"}'`.
186+
- Request method: `PUT`
187+
- Data: `'{"name":"Japan"}'`
161188

162189
### `/proxies/proxies_name/delay`
163190

164-
Request method: `GET`
191+
!!! info ""
192+
Test a specified proxy and return new delay information
165193

166-
- Test a specified proxy and return new delay information
167-
- the URL must include `?url=xxx&timeout=5000`, modified as needed.
194+
- Request method: `GET`
195+
- Parameter: `?url=xxx&timeout=5000`
168196

169197
## Proxy Sets
170198

171199
### `/providers/proxies`
172200

173-
Request method: `GET`
201+
!!! info ""
202+
Retrieve all information for all proxy sets
174203

175-
- Retrieve all information for all proxy sets.
204+
- Request method: `GET`
176205

177206
### `/providers/proxies/providers_name`
178207

179-
Request method: `GET`
208+
!!! info ""
209+
Retrieve information for a specific proxy set
180210

181-
- Retrieve information for a specific proxy set.
211+
- Request method: `GET`
182212

183-
Request method: `PUT`
213+
!!! info ""
214+
Update the proxy set
184215

185-
- Update the proxy set.
216+
- Request method: `PUT`
186217

187218
### `/providers/proxies/providers_name/healthcheck`
188219

189-
Request method: `GET`
220+
!!! info ""
221+
Trigger a health check for a specific proxy set
190222

191-
- Trigger a health check for a specific proxy set.
223+
- Request method: `GET`
192224

193225
### `/providers/proxies/providers_name/proxies_name/healthcheck`
194226

195-
- Test a specified proxy within the proxy set and return new delay information
196-
- the URL must include `?url=xxx&timeout=5000`, modified as needed.
227+
!!! info ""
228+
Test a specified proxy within the proxy set and return new delay information
229+
230+
- Request method: `GET`
231+
- Parameter: `?url=xxx&timeout=5000`
197232

198233
## Rules
199234

200235
### `/rules`
201236

202-
Request method: `GET`
237+
!!! info ""
238+
Retrieve rule information
203239

204-
- Retrieve rule information.
240+
- Request method: `GET`
205241

206242
## Rule Sets
207243

208244
### `/providers/rules`
209245

210-
Request method: `GET`
246+
!!! info ""
247+
Retrieve all information for all rule sets
211248

212-
- Retrieve all information for all rule sets.
249+
- Request method: `GET`
213250

214251
### `/providers/rules/providers_name`
215252

216-
Request method: `PUT`
253+
!!! info ""
254+
Update the rule set
217255

218-
- Update the rule set.
256+
- Request method: `PUT`
219257

220258
## Connections
221259

222260
### `/connections`
223261

224-
Request method: `GET`
262+
!!! info ""
263+
Retrieve connection information
225264

226-
- Retrieve connection information.
265+
- Request method: `GET` / `WS`
266+
- Optional parameter: `?interval=milliseconds`, where `milliseconds` is the refresh interval, default value is 1000 milliseconds
227267

228-
Request method: `DELETE`
268+
!!! info ""
269+
Close all connections
229270

230-
- Close all connections.
271+
- Request method: `DELETE`
231272

232273
### `/connections/:id`
233274

234-
Request method: `DELETE`
275+
!!! info ""
276+
Close a specific connection
235277

236-
- Close a specific connection.
278+
- Request method: `DELETE`
237279

238280
## Domain Query
239281

240282
### `/dns/query`
241283

242-
Request method: `GET`
284+
!!! info ""
285+
Retrieve DNS query data for a specified name and type
243286

244-
- Retrieve DNS query data for a specified name and type
245-
- the URL must include `?name=example.com&type=A`, modified as needed.
287+
- Request method: `GET`
288+
- Parameter: `?name=example.com&type=A`
246289

247290
## DEBUG
248291

249292
`/debug` requires the kernel to be started with the [log level](../config/general.md#log-level) set to `debug`.
250293

251294
### `/debug/gc`
252295

253-
Request method: `PUT`
296+
!!! info ""
297+
Perform active garbage collection
254298

255-
- Perform active garbage collection.
299+
- Request method: `PUT`
256300

257301
### `/debug/pprof`
258302

0 commit comments

Comments
 (0)