样本池覆盖 Windows/macOS/Linux/Android/iOS 与 Chrome/Edge/Firefox/Safari 的 2025-2026 常见组合,均为真实存在过的 UA 字符串,适用于测试脚本构造请求头。可与 UA 解析接口串联使用。
http://rainapi.top/api/ua/random在本站内直接写 /api/ua/random 就能调用;从别处调用请复制上方完整地址。 浏览器网页代码可以直接跨域请求,无需额外配置。响应头包含Access-Control-Allow-Origin: *,浏览器可 fetch。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| platform 例: android | string | 可选 | windows | macos | linux | android | ios | all(默认) |
| browser 例: firefox | string | 可选 | chrome | edge | firefox | safari | all(默认) |
| count 例: 3 | number | 可选 | 1-10 条,默认 1 |
| 字段 | 类型 | 说明 |
|---|---|---|
| user_agent / user_agents | string/array | UA 串(多条时含 platform/browser 标注) |
| pool_size | number | 当前筛选条件下的样本数 |
GET /api/ua/random?platform=macos&browser=safari{
"code": 200,
"count": 1,
"pool_size": 3,
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.1 Safari/605.1.15",
"platform": "macos",
"browser": "safari"
}| HTTP | code | 含义 |
|---|---|---|
| 400 | 400 | platform/browser 不在枚举内 |
| 404 | 404 | 筛选组合无样本 |
| 429 | 429 | 超出频率限制 |
Retry-After: 30公开服务面向零散调用与轻量场景。批量任务请自行加入退避(收到 429 后等待 Retry-After 秒再重试), 或先本地缓存已查询过的结果。持续高频使用建议申请独立配额(未来提供)。
curl -s 'http://rainapi.top/api/ua/random?platform=windows&count=2' | jq -r '.user_agents[].ua' # 与 UA 解析接口串联 curl -s 'http://rainapi.top/api/ua' -H "User-Agent: $(curl -s 'http://rainapi.top/api/ua/random' | jq -r .user_agent)"