跳转至

AngryBed 开放平台 API 文档

AngryBed 开放平台提供评测服务 API,支持代码提交、结果查询等功能。

获取 API Key

请打开 https://ifdian.net/item/dfba71ca5b6711f1be745254001e7c00https://ifdian.net/a/haofafa 购买。

若无法使用,请联系 haofafa(uid=2)或在 客服小二 转人工申请 API Key。

认证方式

所有 API 请求需在 Header 中携带:

Authorization: Bearer <你的API Key>

套餐与计费

套餐列表

套餐 价格 计费点 约可提交次数* 单次成本 适合人群
轻量版 ¥4.9 5,000 约 500-5,000 次 0.098 分 个人学习
标准版 ¥9.9 12,000 约 1,200-12,000 次 0.0825 分 日常使用
专业版 ¥19.9 30,000 约 3,000-30,000 次 0.066 分 重度用户
团队版 ¥49.9 100,000 约 10,000-100,000 次 0.0499 分 小型团队
企业版 ¥99.9 250,000 约 25,000-250,000 次 0.0399 分 大型项目

* 实际提交次数取决于代码耗时,耗时 ≤10 秒扣 1 点,耗时越长扣点越多,单次最高 10 点。 💡 计费点可累加,用完再充。请联系 haofafa 或客服充值。

计费规则

计费规则 说明
基础扣点 每次评测扣 1 点
超时加扣 运行时间超过 10 秒,每超 10 秒加扣 1 点(即 1 + ceil(time/10)
上限 单次评测最多扣 10 点
不计费 只有 Waiting/Compiling(0)System Error(8) 不计费
其他都计费 包括 Accepted、Compile Error、Time Limit Exceeded、Runtime Error 等 都正常扣点

API 接口

1. 提交代码

POST https://angrybed.cn/openapi/submit

请求参数

参数 类型 必填 说明
pid string 题目编号(如 B2001
lang string 语言类型(见下方支持列表)
code string 代码内容

支持的语言列表

语言 lang 参数
C++11 cc.cc11o2
C++14 cc.cc14o2
C++17 cc.cc17o2
C++20 cc.cc20o2
C c.c99
Python 2 py.py2
Python 3 py.py3
Java 8 java.java8
Java 11 java.java11
Java 17 java.java17
JavaScript (Node.js) js.nodejs
Go go.go
Rust rs.rs
Ruby rb.rb
PHP php.php
Pascal pas.fpc
C# (Mono) cs.mcs

响应示例

{
  "rid": "6a11297364a51111c11c15fe",
  "pid": "B2001",
  "status": "queued"
}

响应字段说明

响应字段 类型 说明
rid string 本次提交的唯一 ID,用于后续查询
pid string 题目编号
status string 提交状态,queued 表示已进入队列

错误响应

HTTP 状态码 说明
401 API Key 无效或缺失
429 计费点额度已用完

2. 查询评测结果

GET https://angrybed.cn/openapi/status?rid={rid}

请求参数

参数 类型 必填 说明
rid string 提交代码时返回的 rid

响应示例

{
  "rid": "6a11297364a51111c11c15fe",
  "status": 1,
  "score": 100,
  "time": 0.067,
  "memory": 4084,
  "points": 1,
  "compilerTexts": [],
  "judgeTexts": []
}

响应字段说明

响应字段 类型 说明
rid string 提交 ID
status int 评测状态码(见下方说明)
score int 得分(0-100)
time float 运行耗时(秒)
memory int 内存占用(KB)
points int 本次评测扣除的计费点
compilerTexts array 编译信息(如有)
judgeTexts array 评测详细信息(如有)

状态码说明

status 含义 是否计费
0 Waiting / Compiling 不计费
1 Accepted 计费
2 Wrong Answer 计费
3 Time Limit Exceeded 计费
4 Memory Limit Exceeded 计费
5 Runtime Error 计费
6 Output Limit Exceeded 计费
7 Compile Error 计费
8 System Error 不计费

3. 查询题目

GET https://angrybed.cn/openapi/problem?pid={pid}

请求参数

参数 类型 必填 说明
pid string 题目编号

响应示例

{
  "pid": "B2001",
  "title": "A+B Problem",
  "difficulty": 2,
  "tags": ["入门", "数学"],
  "nSubmit": 12345,
  "nAccept": 6789
}

4. 查询用户

GET https://angrybed.cn/openapi/user?uid={uid}

请求参数

参数 类型 必填 说明
uid string 用户 ID

响应示例

{
  "uid": 134,
  "uname": "user123",
  "rp": 1500,
  "rank": 42,
  "nAccept": 120,
  "nSubmit": 350
}

5. 查询比赛

GET https://angrybed.cn/openapi/contest

获取最近的比赛列表。

响应示例

[
  {
    "pid": "C001",
    "title": "周赛第1期",
    "beginAt": "2026-01-01T10:00:00.000Z",
    "endAt": "2026-01-01T12:00:00.000Z",
    "rule": "ioi",
    "rated": true
  }
]

6. 查询用量

GET https://angrybed.cn/openapi/usage

查询当前 API Key 的计费点余额及使用情况。

响应示例

{
  "quota": 12000,
  "used": 5,
  "records": [
    {
      "pid": "B2001",
      "points": 1,
      "status": 1,
      "createdAt": "2026-01-01T10:00:00.000Z"
    }
  ]
}

响应字段说明

响应字段 类型 说明
quota int 剩余计费点
used int 已使用次数(计费次数)
records array 最近 100 条使用记录

示例代码

Python

import requests
import time

API_KEY = "aboj_xxx"
HEADERS = {"Authorization": f"Bearer {API_KEY}"}
BASE_URL = "https://angrybed.cn/openapi"

# 1. 提交代码
submit_resp = requests.post(f"{BASE_URL}/submit", json={
    "pid": "B2001",
    "lang": "py.py3",
    "code": "print(sum(map(int, input().split())))"
}, headers=HEADERS)
print("提交结果:", submit_resp.json())

# 2. 等待评测完成
rid = submit_resp.json()["rid"]
time.sleep(3)

# 3. 查询结果
result = requests.get(f"{BASE_URL}/status", params={"rid": rid}, headers=HEADERS)
print("评测结果:", result.json())

# 4. 查询用量
usage = requests.get(f"{BASE_URL}/usage", headers=HEADERS)
print("剩余额度:", usage.json())

cURL

# 提交代码
curl -X POST https://angrybed.cn/openapi/submit \
  -H "Authorization: Bearer aboj_xxx" \
  -H "Content-Type: application/json" \
  -d '{"pid":"B2001","lang":"py.py3","code":"print(1+1)"}'

# 查询结果
curl "https://angrybed.cn/openapi/status?rid=xxx" \
  -H "Authorization: Bearer aboj_xxx"

# 查询用量
curl https://angrybed.cn/openapi/usage \
  -H "Authorization: Bearer aboj_xxx"

技术支持

  • 在线客服:https://angrybed.cn/kefu
  • API 测试工具:https://angrybed.cn/openapi/test
  • 联系管理员:@haofafa

如有问题请通过客服系统或联系管理员反馈。