📖 API 文档

开发者API使用说明 · 版本 v1.0

💡 所有API请求均需在Header中携带 X-API-KeyX-API-Secret 进行身份认证。

🔐 认证方式

每个工具分类对应一个独立的API密钥对(App ID + App Secret)。
请求时通过HTTP Header传递:

X-API-Key: api_json_xxxxx
X-API-Secret: xxxxxxxxxxxxxxxx

或通过URL参数传递(仅限GET请求):

GET /api/v1/timestamp/now?api_key=api_json_xxxxx

📮 请求格式

项目说明
Base URLhttps://www.cnwebai.cn
请求头Content-Type: application/json
认证头X-API-Key + X-API-Secret

🔧 可用API端点

📋 调用示例

JSON格式化

# 请求
POST /api/v1/json/format
X-API-Key: api_json_xxxxx
X-API-Secret: xxxxxxxxxxxx
Content-Type: application/json

{"json": "{\"name\":\"test\",\"age\":25}"}

# 响应
{
  "code": 200,
  "msg": "操作成功",
  "data": {
    "formatted": "{\n  \"name\": \"test\",\n  \"age\": 25\n}",
    "valid": true
  }
}

时间戳转换

# 请求
POST /api/v1/timestamp/convert
Content-Type: application/json

{"timestamp": 1715800000, "to": "date"}

# 响应
{
  "code": 200,
  "data": {
    "timestamp": 1715800000,
    "date": "2024-05-16 00:26:40",
    "iso": "2024-05-15T16:26:40.000Z"
  }
}

Base64编码

# 请求
POST /api/v1/base64/encode
Content-Type: application/json

{"text": "Hello World"}

# 响应
{
  "code": 200,
  "data": {
    "encoded": "SGVsbG8gV29ybGQ="
  }
}

📊 状态码说明

状态码说明
200请求成功
400请求参数错误
401缺少API Key或格式错误
403API Key无效或已停用
429调用频率超限或已达每日配额
500服务器内部错误

💡 最佳实践