全部字符经 crypto.randomInt 逐位采样,无 Math.random 与可预测种子。type 支持 numeric / alpha / alnum / hex / password,password 模式保证大写、小写、数字、符号各至少一位并整体洗牌。长度 1-128,批量上限 100 条。
http://rainapi.top/api/random在本站内直接写 /api/random 就能调用;从别处调用请复制上方完整地址。 浏览器网页代码可以直接跨域请求,无需额外配置。响应头包含Access-Control-Allow-Origin: *,浏览器可 fetch。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| length 例: 16 | number | 可选 | 长度 1-128,默认 16;password 模式低于 8 自动抬到 8 |
| type 例: password | string | 可选 | numeric | alpha | alnum(默认)| hex | password |
| count 例: 5 | number | 可选 | 生成条数 1-100,默认 1 |
| 字段 | 类型 | 说明 |
|---|---|---|
| result / results | string/array | count=1 时为单串,多条时为数组 |
| type / length / count | mixed | 参数回显 |
GET /api/random?length=12&type=password{
"code": 200,
"type": "password",
"length": 12,
"count": 1,
"result": "aT7$kQ2zLm9W"
}| HTTP | code | 含义 |
|---|---|---|
| 400 | 400 | length 越界或 type 不支持 |
| 429 | 429 | 超出频率限制 |
Retry-After: 30公开服务面向零散调用与轻量场景。批量任务请自行加入退避(收到 429 后等待 Retry-After 秒再重试), 或先本地缓存已查询过的结果。持续高频使用建议申请独立配额(未来提供)。
curl -s 'http://rainapi.top/api/random?length=12&type=password'