支持 3d6、d20、1d20+5、2d6+1d8-1。每组 1–100 颗、2–1000 面,总共最多 100 颗、10 组。点数来自 crypto.getRandomValues 的拒绝采样。 访问类别:匿名 API,可携带 Token 使用独立额度
请求参数
dicequery必填- string · 最短:2 字符 · 最长:64 字符
_formatquery- 响应格式为 json 或 text;_format=svg 返回 JSON。plain 是 text 的别名。未识别的值继续按 Accept 协商。
- string · 可选:json、text
_colorquery- 控制 text 响应的 ANSI 颜色。0、false、off、no 关闭;省略或其他值保留。
- string · 可选:0、false、off、no
路径兼容入口
GET /roll/{dice}
将 dice 的值进行 URL 编码后填入路径。
响应
application/json
{
"type": "object",
"properties": {
"expression": {
"type": "string"
},
"groups": {
"type": "array",
"items": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"sides": {
"type": "integer"
},
"sign": {
"anyOf": [
{
"type": "number",
"enum": [
1
]
},
{
"type": "number",
"enum": [
-1
]
}
]
},
"rolls": {
"type": "array",
"items": {
"type": "integer"
}
},
"subtotal": {
"type": "integer"
}
},
"required": [
"count",
"sides",
"sign",
"rolls",
"subtotal"
]
}
},
"modifier": {
"type": "integer"
},
"total": {
"type": "integer"
}
},
"required": [
"expression",
"groups",
"modifier",
"total"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}application/json
{
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
},
"issues": {
"type": "array",
"items": {
"type": "object",
"properties": {
"location": {
"type": "string",
"enum": [
"body",
"query",
"path",
"header"
]
},
"field": {
"type": "string"
},
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"location",
"field",
"code",
"message"
]
}
}
},
"required": [
"code",
"message"
]
}
},
"required": [
"error"
]
}响应示例
成功响应
curl -sS 'https://oit.sh/roll/3d6?_format=json'HTTP 200
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"expression": "3d6",
"groups": [
{
"count": 3,
"sides": 6,
"sign": 1,
"rolls": [
5,
5,
4
],
"subtotal": 14
}
],
"modifier": 0,
"total": 14
}错误示例
curl -sS 'https://oit.sh/roll?dice=invalid+value&_format=json'HTTP 400
content-type: application/json
content-encoding: gzip
cache-control: no-store
{
"error": {
"code": "INVALID_INPUT",
"message": "骰子表达式只支持 NdS、可选修饰和加减组合,例如 3d6 或 1d20+5",
"issues": [
{
"location": "query",
"field": "dice",
"code": "invalid_value",
"message": "骰子表达式只支持 NdS、可选修饰和加减组合,例如 3d6 或 1d20+5"
}
]
}
}curl 访问示例
curl、wget、HTTPie 默认得到 text/plain。示例展示纯文本输出。
命令与输出
curl -sS 'https://oit.sh/roll/3d6?_color=0'HTTP 200 content-type: text/plain; charset=utf-8 content-encoding: gzip cache-control: no-store 3d6 3d6: 4 6 4 modifier 0 total 14
在线调试
curl -X GET 'https://oit.sh/roll?dice=3d6'
响应
等待发送请求