统一检索服务 — search.msw.mba
Base URL: https://search.msw.mba
所有 /api/* 端点(除 /api/health)需携带认证信息,支持两种方式:
方式一:Casdoor JWT(推荐) — 通过 OAuth2 client_credentials 获取 token:
TOKEN=$(curl -s -X POST https://sso.msw.mba/api/login/oauth/access_token \ -d "grant_type=client_credentials&client_id=YOUR_CLIENT_ID&client_secret=YOUR_SECRET&scope=openid" \ | jq -r .access_token) curl -H "Authorization: Bearer $TOKEN" "https://search.msw.mba/api/search?q=test"
方式二:静态 API Key — 直接使用预分配的 key:
curl -H "Authorization: Bearer sk-search-xxxxx" "https://search.msw.mba/api/search?q=test"
多后端聚合搜索,自动去重,结果按时间降序排列。支持 compact 模式,适合 LLM / Agent 调用。
根据查询语言动态分配国内/国际结果配额(中文查询偏重国内,英文查询偏重国际)。
| 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
q | string | — | 搜索关键词(必填) |
region | string | auto | auto | cn | global |
max_results | int | 30 | 返回结果数量上限 (1-50) |
time_range | string | "" | 时间范围: day | week | month | year | 空=不限 |
compact | bool | false | 精简模式,截断 content 节省 token |
max_content_len | int | 200 | 每条结果 content 最大字符数 |
示例(Agent / LLM 推荐):
curl "https://search.msw.mba/api/search?q=kubernetes&compact=true&max_results=10&time_range=week"
响应:
{
"query": "kubernetes",
"region": "auto",
"number_of_results": 10,
"quotas": {"cn": 3, "global": 7},
"results": [
{"url": "...", "title": "...", "content": "...", "publishedDate": "2026-04-04T...", "source": "global"}
],
"backends": [
{"name": "global", "count": 21, "elapsed_ms": 2100, "error": null}
]
}
返回各后端的原始结果(不合并),用于调试。参数与 /api/search 相同(无 compact)。
抓取指定 URL 的文本内容,自动去 HTML 标签,适合 LLM 阅读。
curl -X POST "https://search.msw.mba/api/fetch" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com","max_length":4000,"strip_html":true}'
| Body 参数 | 类型 | 默认 | 说明 |
|---|---|---|---|
url | string | — | 目标 URL(必填) |
max_length | int | 8000 | 返回文本最大字符数 |
strip_html | bool | true | 是否去除 HTML 标签 |
timeout | int | 10 | 超时秒数(上限 30) |
检测各搜索后端(cn / global)的可用性和延迟。
返回 {"status": "ok"}。
交互式文档: /api/docs
设置实时生效,无需重启服务。配置持久化存储在服务端,重启后保留。