{"id":15141554,"url":"https://github.com/obgnail/clash-api","last_synced_at":"2025-10-23T18:30:40.256Z","repository":{"id":168562910,"uuid":"644262377","full_name":"obgnail/clash-api","owner":"obgnail","description":"clash restful API","archived":false,"fork":false,"pushed_at":"2024-04-03T13:19:39.000Z","size":108,"stargazers_count":23,"open_issues_count":0,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T20:29:37.156Z","etag":null,"topics":["clash","clashapi","golang","restful-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/obgnail.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-05-23T06:51:15.000Z","updated_at":"2025-01-12T23:06:51.000Z","dependencies_parsed_at":"2023-12-30T09:31:39.093Z","dependency_job_id":"c39eac76-49e2-41d2-bc72-8427f1b416a1","html_url":"https://github.com/obgnail/clash-api","commit_stats":null,"previous_names":["obgnail/clash-api"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obgnail%2Fclash-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obgnail%2Fclash-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obgnail%2Fclash-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/obgnail%2Fclash-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/obgnail","download_url":"https://codeload.github.com/obgnail/clash-api/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237869253,"owners_count":19379290,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clash","clashapi","golang","restful-api"],"created_at":"2024-09-26T09:01:08.358Z","updated_at":"2025-10-23T18:30:39.826Z","avatar_url":"https://github.com/obgnail.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clash api\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"assets/nijika.png\" width=\"450\" height=\"450\"\u003e\n\u003c/p\u003e\n\n\n本项目是 [Clash RESTful API](https://clash.gitbook.io/doc) 的 golang 实现。我丢，搬砖活。\n\n\n\n\n## Introduction\n\n\u003e Clash RESTful API 是一套控制 Clash 的一个途径，能获取 Clash 中的一些信息，同时也能控制 Clash 内部的配置。基于 API，可以打造自己的可视化操作部分，也是实现 Clash GUI 的重要组成部分。—— Clash doc\n\n因为 new bing 需要用到香港节点，我平常也不用此节点，于是整了个自动切换脚本。开源 RESTful API 部分。\n\n\n\n## API\n\n```go\n// 默认url为http://127.0.0.1:9090，如需修改，请调用此函数\nfunc SetURL(URL string) {}\n\n// 设置密钥(调用业务接口前必须调用此接口)\nfunc SetSecret(sec string) {}\nfunc SetSecretFromEnv(name string) error {}\nfunc SetSecretFromFile(file string) error {}\n\n// 监控请求日志\nfunc GetLogs(level LogLevel) (chan *Log, error) {}\n\n// 每秒推送一次，上下载流量\nfunc GetTraffic(handler func(traffic *Traffic) (stop bool)) error {}\n\n// 节点列表\nfunc GetProxies() (map[string]*Proxies, error) {}\n\n// 具体节点的信息\nfunc GetProxyMessage(name string) (*Proxy, error) {}\n\n// 测试具体节点的延时\nfunc GetProxyDelay(name string, url string, timeout int) (*ProxyDelay, error) {}\n\n// 切换节点\nfunc SwitchProxy(selector, name string) error {}\n\n// 获取配置\nfunc GetConfig() (*Config, error) {}\n\n// 设置配置\nfunc SetConfig(port, socksPort int, redirPort string, allowLan bool, mode, logLevel string) error {}\n\n// 应用配置(不会影响 external-controller 和 secret 的值)\nfunc EnableConfig(path string) error {}\n\n// PAC rules\nfunc GetRules() ([]*Rule, error) {}\n```\n\n \n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/obgnail/clash-api/clash\"\n)\n\nfunc main() {\n\tif err := clash.SetSecretFromFile(\"./secret.txt\"); err != nil {\n\t\tpanic(err)\n\t}\n\n\tproxies, err := clash.GetProxies()\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfmt.Println(proxies)\n}\n```\n\n## Processing\n\n- [x] 支持 Meta (mihomo) 内核 API\n  \u003e 以最新 Meta Alpha 内核及 Metacubexd 的代码实现为准，Meta Wiki 为辅\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobgnail%2Fclash-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobgnail%2Fclash-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobgnail%2Fclash-api/lists"}