统一响应包装
所有响应使用 { ok, data | error } 包装,错误带 code 与 message。
所有路径都以本站根域为前缀。下方 cURL 示例 会自动替换为你正在访问的域名。
https://roar.dearlicy.com所有响应使用 { ok, data | error } 包装,错误带 code 与 message。
公开接口对所有人开放;含密钥算法可在请求体里附带自带 key(最长 256)。
受全局 IP 黑白名单与每分钟限流约束;策略可在管理后台「安全策略」中调整。
响应携带 CORS 头,允许浏览器直接跨域调用,便于前端 / 小程序 / 插件集成。
按编号顺序阅读即可完整覆盖加 / 解 / 查能力。
/api/public/encrypt用指定字符集 + 算法把明文编码成兽音密文。
curl -X POST https://roar.dearlicy.com/api/public/encrypt \
-H "Content-Type: application/json" \
-d '{
"text": "你好,秘密",
"charsetId": "<charsetId>",
"algorithmId": "<algorithmId>"
}'const res = await fetch('/api/public/encrypt', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: '你好,秘密',
charsetId: '<charsetId>',
algorithmId: '<algorithmId>',
}),
});
const json = await res.json();
console.log(json.data.cipher);{
"ok": true,
"data": {
"cipher": "嗷呜嗷嗷呜呜嗷嗷……",
"algoType": "RAW",
"algoName": "经典原始",
"charsetName": "经典嗷呜",
"durationMs": 3
}
}/api/public/decrypt只需粘贴密文,自动识别字符集与算法;含密钥算法在缺密钥时返回 needKey 提示。
curl -X POST https://roar.dearlicy.com/api/public/decrypt \
-H "Content-Type: application/json" \
-d '{ "cipher": "嗷呜嗷……", "key": "可选密钥" }'const res = await fetch('/api/public/decrypt', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ cipher: '嗷呜嗷……' }),
});
const json = await res.json();
if (json.data.needKey) {
// 提示用户输入密钥后再次调用
} else {
console.log(json.data.text);
}{
"ok": true,
"data": {
"text": "你好,秘密",
"algoType": "RAW",
"charsetName": "经典嗷呜",
"durationMs": 4
}
}
// 当算法需要密钥而未提供时:
{
"ok": true,
"data": {
"needKey": true,
"algoType": "KEYPERM",
"algoHint": "KEYPERM"
}
}/api/public/options查询启用状态下的字符集与算法预设列表,用于驱动前端选择。
curl https://roar.dearlicy.com/api/public/optionsconst res = await fetch('/api/public/options');
const { data } = await res.json();
console.log(data.charsets, data.algorithms);{
"ok": true,
"data": {
"charsets": [
{ "id": "...", "name": "经典嗷呜", "c0": "嗷", "c1": "呜", "c2": "啊", "c3": "~", "isDefault": true }
],
"algorithms": [
{ "id": "...", "name": "经典原始", "type": "RAW", "isDefault": true, "needKey": false }
]
}
}所有错误统一通过 error.code 返回,可据此做差异化处理(例如限流时退避,IP 拒绝时引导联系管理员)。
RATE_LIMITED触发限流;data.resetAt 为下次可请求时间戳。
IP_BLACKLISTED当前 IP 已被加入全局黑名单。
IP_NOT_WHITELISTED当前 IP 不在白名单中(白名单模式启用时)。
BAD_REQUEST参数缺失或字段不合法(详见 message)。
DECODE_FAIL密文无法被识别——字符集未启用或密文损坏。