代码审查 - Python中文 API接口文档,AI代码审查API,自动检测代码质量、安全漏洞、性能问题,并提供优化建议。支持Python、JavaScript、Java、Go等主流语言。CI/CD流水线自动集成方案。支持参数说明、调用示例、在线测试。免费试用。

请求格式

POST /api/v1/code-review

请求头信息:

Authorization: Bearer YOUR_API_KEY
Content-Type: application/json
Accept: application/json

请求参数

参数名 类型 必填 说明
languagestring是代码语言(python)
codetext是待审查的源代码
strictnessstring否严格程度(low/medium/high)
focusstring否审查重点(security/performance/style/all)

调用示例 - cURL

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 调用示例

# 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": 7,
    "issues": [
      {
        "severity": "high",
        "line": 15,
        "message": "检测到SQL注入风险",
        "suggestion": "使用参数化查询替代字符串拼接"
      },
      {
        "severity": "medium",
        "line": 42,
        "message": "函数复杂度偏高",
        "suggestion": "建议拆分为多个小函数"
      }
    ],
    "overall_score": 74
  },
  "request_id": "req_code-review_python_zh_5"
}
🚀 在线测试

点击返回主页,获取API密钥并在线测试