接口文档
基础路径 /v1/random,全部为 GET 请求,返回 {code, message, data}。
GET /v1/random/int 随机整数
| 参数 | 默认 | 说明 |
| min | 1 | 最小值(含) |
| max | 100 | 最大值(含) |
| count | 1 | 生成个数,1–1000 |
请求:/v1/random/int?min=1&max=100&count=3
返回:{"code":0,"message":"ok","data":{"min":1,"max":100,"count":3,"numbers":[8,66,78]}}
GET /v1/random/string 随机字符串
| 参数 | 默认 | 说明 |
| length | 16 | 长度,1–1024 |
| type | alnum | 预设字符集:digits 纯数字 / lower 小写 / upper 大写 / alnum 数字+大小写 / symbols alnum+符号 |
| charset | — | 自定义字符集:传入后优先于 type,从你给的字符里随机抽取(支持中文等 Unicode 字符,自动去重,最多 256 个,不含空白与控制字符) |
请求:/v1/random/string?length=16&type=alnum
返回:{"code":0,"message":"ok","data":{"length":16,"type":"alnum","string":"RYNbBOJV5xSmGy4Z"}}
请求:/v1/random/string?length=8&charset=春夏秋冬
返回:{"code":0,"message":"ok","data":{"length":8,"type":"custom","charset_size":4,"string":"冬春夏秋冬夏春冬"}}
GET /v1/random/uuid UUID v4
请求:/v1/random/uuid
返回:{"code":0,"message":"ok","data":{"count":1,"uuids":["afee4e2c-16f8-4b71-a8d0-31187758fb2d"]}}
GET /v1/random/float 随机浮点数
| 参数 | 默认 | 说明 |
| min | 0 | 最小值(含) |
| max | 1 | 最大值(不含) |
| precision | 6 | 小数位数,0–15 |
请求:/v1/random/float?min=0&max=1&precision=6
返回:{"code":0,"message":"ok","data":{"min":0,"max":1,"value":0.045965}}
GET /v1/random/shuffle 不重复抽取
从区间内洗牌后抽取,保证不重复,适合摇号、抽奖。
| 参数 | 默认 | 说明 |
| min | 1 | 最小值(含) |
| max | 49 | 最大值(含) |
| count | 5 | 抽取个数,不得超过区间大小 |
请求:/v1/random/shuffle?min=1&max=49&count=5
返回:{"code":0,"message":"ok","data":{"min":1,"max":49,"count":5,"numbers":[23,31,20,29,19]}}