{
  "tags": [
    "网站监控"
  ],
  "description": "分页查询 MySQL `black_ip` 表的历史黑名单，包含已过期记录，按创建时间倒序返回。接口要求登录。普通用户仅能查询自身 uid；管理员可查询全量或用 uid 筛选指定用户。时间条件仅在 start 与 end 同时传入时生效。传 `action=export` 时返回全部匹配记录的去重 IP 纯文本。",
  "operationId": "user_get_v1_monitor_site_history_blackip",
  "security": [
    {
      "AccessToken": []
    },
    {
      "ApiKey": [],
      "ApiSecret": []
    }
  ],
  "responses": {
    "200": {
      "description": "普通查询返回 JSON；导出返回 text/plain 附件。",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "code",
              "count",
              "data"
            ],
            "properties": {
              "code": {
                "type": "integer",
                "enum": [
                  0
                ],
                "description": "历史黑名单列表查询成功时固定为 0。"
              },
              "count": {
                "type": "integer",
                "minimum": 0,
                "description": "未应用分页前的匹配历史记录总数。"
              },
              "data": {
                "type": "array",
                "description": "当前页历史黑名单。",
                "items": {
                  "type": "object",
                  "required": [
                    "site_id",
                    "ip",
                    "filter",
                    "uid",
                    "exp",
                    "create_at",
                    "position",
                    "auto_unlock",
                    "domain",
                    "fname"
                  ],
                  "properties": {
                    "site_id": {
                      "type": "integer",
                      "nullable": true,
                      "description": "网站 ID。"
                    },
                    "ip": {
                      "type": "string",
                      "nullable": true,
                      "description": "被封禁 IP。"
                    },
                    "filter": {
                      "type": "string",
                      "nullable": true,
                      "description": "关联 CC 过滤器 ID 原始值。"
                    },
                    "uid": {
                      "type": "integer",
                      "nullable": true,
                      "description": "黑名单所属用户 ID。"
                    },
                    "exp": {
                      "description": "过期时间，保持数据库原始类型。"
                    },
                    "create_at": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true,
                      "description": "创建时间。"
                    },
                    "position": {
                      "type": "string",
                      "nullable": true,
                      "description": "黑名单位置描述。"
                    },
                    "auto_unlock": {
                      "type": "integer",
                      "enum": [
                        0,
                        1
                      ],
                      "nullable": true,
                      "description": "自动解锁标记的数据库布尔值。"
                    },
                    "domain": {
                      "type": "string",
                      "nullable": true,
                      "description": "关联网站域名；网站不存在时为空。"
                    },
                    "fname": {
                      "type": "string",
                      "nullable": true,
                      "description": "关联 CC 过滤器名称；过滤器不存在时为空。"
                    }
                  },
                  "additionalProperties": false
                }
              }
            },
            "additionalProperties": false
          },
          "example": {
            "code": 0,
            "count": 1,
            "data": [
              {
                "site_id": 123,
                "ip": "192.0.2.10",
                "filter": "8",
                "uid": 12,
                "exp": 1767312000,
                "create_at": "2026-01-01T12:00:00",
                "position": "",
                "auto_unlock": 1,
                "domain": "www.example.invalid",
                "fname": "默认 CC 过滤器"
              }
            ]
          }
        },
        "text/plain": {
          "schema": {
            "type": "string",
            "description": "仅 action=export 返回：去重后的 IP 列表，每行一个。"
          },
          "example": "192.0.2.10\n198.51.100.20\n"
        }
      }
    }
  },
  "x-python-handler": "monitor.HistoryBlackIpAPI",
  "x-python-route-line": 768,
  "x-audience": "user",
  "x-auth": "user",
  "x-reviewed": true,
  "parameters": [
    {
      "name": "page",
      "in": "query",
      "required": false,
      "description": "页码，必须为数字，默认 1。",
      "schema": {
        "type": "integer",
        "minimum": 1,
        "default": 1
      }
    },
    {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "每页条数，必须为数字，默认 10。action=export 时服务端忽略该值并查询全部。",
      "schema": {
        "type": "integer",
        "minimum": 0,
        "default": 10
      }
    },
    {
      "name": "uid",
      "in": "query",
      "required": false,
      "description": "仅管理员有效：按黑名单所属用户 ID 精确筛选；普通用户传入时仍仅查询自身。",
      "schema": {
        "type": "integer",
        "example": 12
      }
    },
    {
      "name": "ip",
      "in": "query",
      "required": false,
      "description": "黑名单 IP 精确筛选。",
      "schema": {
        "type": "string",
        "example": "192.0.2.10"
      }
    },
    {
      "name": "site_id",
      "in": "query",
      "required": false,
      "description": "网站 ID 精确筛选。",
      "schema": {
        "type": "integer",
        "example": 123
      }
    },
    {
      "name": "start",
      "in": "query",
      "required": false,
      "description": "创建时间下界；只有同时传 end 才生效，直接交给数据库比较。",
      "schema": {
        "type": "string",
        "example": "2026-01-01 00:00:00"
      }
    },
    {
      "name": "end",
      "in": "query",
      "required": false,
      "description": "创建时间上界（不含）；只有同时传 start 才生效，直接交给数据库比较。",
      "schema": {
        "type": "string",
        "example": "2026-01-02 00:00:00"
      }
    },
    {
      "name": "action",
      "in": "query",
      "required": false,
      "description": "传 export 时下载所有匹配 IP 的去重文本；其他值按普通查询处理。",
      "schema": {
        "type": "string",
        "enum": [
          "export"
        ]
      }
    }
  ],
  "x-itecdn-source-reviewed": true,
  "extensions": [
    {
      "key": "x-python-handler",
      "value": "monitor.HistoryBlackIpAPI"
    },
    {
      "key": "x-python-route-line",
      "value": 768
    },
    {
      "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/monitor/site/history-blackip",
  "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": "查询历史黑名单记录",
    "description": {
      "content": "分页查询 MySQL `black_ip` 表的历史黑名单，包含已过期记录，按创建时间倒序返回。接口要求登录。普通用户仅能查询自身 uid；管理员可查询全量或用 uid 筛选指定用户。时间条件仅在 start 与 end 同时传入时生效。传 `action=export` 时返回全部匹配记录的去重 IP 纯文本。",
      "type": "text/plain"
    },
    "url": {
      "path": [
        "v1",
        "monitor",
        "site",
        "history-blackip"
      ],
      "host": [
        "{{baseUrl}}"
      ],
      "query": [
        {
          "disabled": false,
          "description": {
            "content": "页码，必须为数字，默认 1。",
            "type": "text/plain"
          },
          "key": "page",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "每页条数，必须为数字，默认 10。action=export 时服务端忽略该值并查询全部。",
            "type": "text/plain"
          },
          "key": "limit",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "仅管理员有效：按黑名单所属用户 ID 精确筛选；普通用户传入时仍仅查询自身。",
            "type": "text/plain"
          },
          "key": "uid",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "黑名单 IP 精确筛选。",
            "type": "text/plain"
          },
          "key": "ip",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "网站 ID 精确筛选。",
            "type": "text/plain"
          },
          "key": "site_id",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "创建时间下界；只有同时传 end 才生效，直接交给数据库比较。",
            "type": "text/plain"
          },
          "key": "start",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "创建时间上界（不含）；只有同时传 start 才生效，直接交给数据库比较。",
            "type": "text/plain"
          },
          "key": "end",
          "value": ""
        },
        {
          "disabled": false,
          "description": {
            "content": "传 export 时下载所有匹配 IP 的去重文本；其他值按普通查询处理。",
            "type": "text/plain"
          },
          "key": "action",
          "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"
        }
      ]
    }
  }
}