介面文件
基礎路徑 /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]}}