{
  "tags": [
    "API 密钥"
  ],
  "description": "获取当前登录用户的 API Key 配置；管理员可通过 `uid` 查询指定用户。接口直接返回数据库中保存的 API Key、API Secret 和来源 IP 白名单，不会对密钥做掩码；调用方不得把响应写入日志、前端持久化存储或转发给无关方。目标用户尚未开通 API Key 时请求仍成功，`data` 返回 null。",
  "operationId": "user_get_v1_api_key",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "业务结果通过 HTTP 200 返回。查询成功时 `data` 为完整 API Key 记录；目标用户尚未开通时 `data` 为 null；普通用户尝试指定 `uid` 或登录凭证无效时返回字符串业务错误码。",
      "content": {
        "application/json": {
          "schema": {
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "integer",
                    "enum": [
                      0
                    ],
                    "description": "查询完成时的成功状态码，固定为 0，包括用户尚未开通 API Key 的情况。"
                  },
                  "msg": {
                    "type": "string",
                    "enum": [
                      "获取成功"
                    ],
                    "description": "API Key 查询完成时返回的确认消息。"
                  },
                  "data": {
                    "description": "目标用户的完整 API Key 配置；尚未开通 API Key 时为 null。",
                    "oneOf": [
                      {
                        "type": "object",
                        "required": [
                          "id",
                          "uid",
                          "api_key",
                          "api_secret",
                          "api_ip"
                        ],
                        "properties": {
                          "id": {
                            "type": "integer",
                            "format": "int64",
                            "description": "API Key 配置记录的唯一 ID。"
                          },
                          "uid": {
                            "type": "integer",
                            "format": "int64",
                            "description": "该 API Key 所属用户的 ID。"
                          },
                          "api_key": {
                            "type": "string",
                            "minLength": 16,
                            "maxLength": 16,
                            "description": "调用 API 时通过 `api-key` 请求头提交的 16 位访问标识。"
                          },
                          "api_secret": {
                            "type": "string",
                            "minLength": 30,
                            "maxLength": 30,
                            "description": "与 API Key 配对、通过 `api-secret` 请求头提交的 30 位明文密钥。"
                          },
                          "api_ip": {
                            "type": "string",
                            "nullable": true,
                            "description": "允许使用该密钥的来源 IP 白名单，多个地址以竖线 `|` 分隔；null 或空字符串表示不限制来源 IP。"
                          }
                        },
                        "additionalProperties": false
                      },
                      {
                        "type": "string",
                        "nullable": true,
                        "enum": [
                          null
                        ]
                      }
                    ]
                  }
                },
                "additionalProperties": false
              },
              {
                "type": "object",
                "required": [
                  "code",
                  "msg",
                  "data"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "enum": [
                      "task-5",
                      "login_required"
                    ],
                    "description": "业务错误码：`task-5` 表示普通用户尝试查询指定用户的 API Key，`login_required` 表示登录态或 API Key 认证无效。"
                  },
                  "msg": {
                    "type": "string",
                    "description": "与业务错误码对应的中文权限或认证失败原因。"
                  },
                  "data": {
                    "type": "string",
                    "enum": [
                      ""
                    ],
                    "description": "业务错误时固定为空字符串。"
                  }
                },
                "additionalProperties": false
              }
            ]
          },
          "example": {
            "code": 0,
            "msg": "获取成功",
            "data": {
              "id": 1,
              "uid": 2,
              "api_key": "EXAMPLEAPIKEY001",
              "api_secret": "EXAMPLE_API_SECRET_00000000000",
              "api_ip": "192.0.2.10|198.51.100.20"
            }
          }
        }
      }
    }
  },
  "x-python-handler": "system.ApiKeyAPI",
  "x-python-route-line": 907,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "uid",
      "in": "query",
      "required": false,
      "description": "要查询 API Key 的用户 ID。省略时查询当前登录用户；仅管理员可指定其他用户，普通用户传入该参数会返回权限错误。",
      "schema": {
        "type": "integer",
        "format": "int64",
        "minimum": 1
      },
      "example": 2
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "system.ApiKeyAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 907
    },
    {
      "key": "x-audience",
      "value": "user"
    },
    {
      "key": "x-auth",
      "value": "user"
    },
    {
      "key": "x-reviewed",
      "value": true
    },
    {
      "key": "x-itecdn-source-reviewed",
      "value": true
    }
  ],
  "method": "get",
  "path": "/v1/api-key",
  "servers": [
    {
      "url": "https://master.example.invalid",
      "description": "不可调用的示例地址；复制示例后替换为自己的主控域名。"
    }
  ],
  "securitySchemes": {
    "AccessToken": {
      "type": "apiKey",
      "in": "header",
      "name": "access-token",
      "description": "通过登录接口获得的短期访问令牌。"
    },
    "ApiKey": {
      "type": "apiKey",
      "in": "header",
      "name": "api-key",
      "description": "API Key；必须和 api-secret 同时发送。"
    },
    "ApiSecret": {
      "type": "apiKey",
      "in": "header",
      "name": "api-secret",
      "description": "API Secret；必须和 api-key 同时发送。"
    }
  },
  "info": {
    "title": "itecdn v5 用户 API",
    "version": "5.x",
    "description": "itecdn v5.x Python 主控用户 API。本文档不适用于 v6 或其它实现。"
  },
  "postman": {
    "name": "获取 API Key 配置",
    "description": {
      "content": "获取当前登录用户的 API Key 配置；管理员可通过 `uid` 查询指定用户。接口直接返回数据库中保存的 API Key、API Secret 和来源 IP 白名单，不会对密钥做掩码；调用方不得把响应写入日志、前端持久化存储或转发给无关方。目标用户尚未开通 API Key 时请求仍成功，`data` 返回 null。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "api-key"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "要查询 API Key 的用户 ID。省略时查询当前登录用户；仅管理员可指定其他用户，普通用户传入该参数会返回权限错误。",
            "type": "text/plain"
          },
          "key": "uid",
          "value": ""
        }
      ],
      "variable": []
    },
    "header": [
      {
        "key": "Accept",
        "value": "application/json"
      }
    ],
    "method": "GET",
    "auth": {
      "type": "apikey",
      "apikey": [
        {
          "type": "any",
          "value": "access-token",
          "key": "key"
        },
        {
          "type": "any",
          "value": "{{apiKey}}",
          "key": "value"
        },
        {
          "type": "any",
          "value": "header",
          "key": "in"
        }
      ]
    }
  }
}