请求头信息:
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: application/json
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
language | string | 是 | 代码语言(python) |
code | text | 是 | 待审查的源代码 |
strictness | string | 否 | 严格程度(low/medium/high) |
focus | string | 否 | 审查重点(security/performance/style/all) |
curl -X POST "https://cross.cybermagi.space/api/v1/code-review" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"language": "python", "code": "def foo():\n return 1 + 1", "strictness": "high"}'
# Python 예제 코드
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://cross.cybermagi.space"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"target": "python"
}
response = requests.post(
f"{BASE_URL}/api/v1/code-review",
json=data,
headers=headers
)
result = response.json()
print(result)
{
"success": true,
"data": {
"language": "python",
"issues_found": 5,
"issues": [
{
"severity": "high",
"line": 15,
"message": "检测到SQL注入风险",
"suggestion": "使用参数化查询替代字符串拼接"
},
{
"severity": "medium",
"line": 42,
"message": "函数复杂度偏高",
"suggestion": "建议拆分为多个小函数"
}
],
"overall_score": 71
},
"request_id": "req_code-review_python_ko_8"
}
点击返回主页,获取API密钥并在线测试