{
  "openapi": "3.0.1",
  "info": {
    "title": "Bright Data API",
    "description": "将 Bright Data API 集成到您的管道中，实现高端抓取精度",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.brightdata.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/request": {
      "get": {
        "description": "",
        "parameters": [
          {
            "in": "query",
            "name": "zone",
            "description": "将为您的请求提供服务的代理区域名称。",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "url",
            "description": "请求的目标 URL。",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "format",
            "description": "通过代理请求原始 HTML 的格式为 `raw`。\n\n请求 JSON 响应的格式为 `json`。",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["raw", "json"]
            }
          },
          {
            "in": "query",
            "name": "method",
            "description": "通过代理请求 HTML 的方法为 `GET`。",
            "required": false,
            "schema": {
              "type": "string",
              "default": "GET"
            }
          },
          {
            "in": "query",
            "name": "country",
            "description": "请求通过的代理所在的国家代码。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "city",
            "description": "请求通过的代理所在的城市名称，必须定义国家。\n\n在数据中心和 ISP 区域中支持预配置城市，在住宅和移动网络中默认支持。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "zip",
            "description": "请求通过的代理所在的邮政编码，必须定义国家。\n\n仅在住宅网络中支持。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ASN",
            "description": "请求通过的代理所在的 ASN 代码，必须定义国家。\n\n仅在住宅网络中支持。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "carrier",
            "description": "仅适用于移动网络：请求通过的运营商代码。\n\n仅在移动网络中支持。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "os",
            "description": "设置在代理上的客户端操作系统。\n\n仅在住宅和移动网络中支持。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "dns",
            "description": "使用 `local` 或 `remote` 设置域名映射是在客户端本地还是在远程代理节点上完成。",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["local", "remote"]
            }
          },
          {
            "in": "query",
            "name": "session",
            "description": "客户端传递的字符串以标记会话，所有具有相同 session 参数的请求将被传递到相同的代理节点。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "ip",
            "description": "在数据中心和 ISP 区域中：将请求转发到由 `ip` 标识的特定代理。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "gip",
            "description": "在 `住宅` 和 `移动` 区域中：将请求转发到由 `gip` 标识的特定代理组。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "c_tag",
            "description": "在请求中包含唯一的 `c_tag` 标志。响应中，业务端会在头部返回相同的标志。此无缝交换确保每个响应都绑定到其对应的请求，消除混淆并简化数据管理。",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "direct",
            "description": "将参数设置为 `true` 会指示通过 Bright Data 超级代理（数据中心代理，而非代理节点本身）处理请求。",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功"
          },
          "400": {
            "description": "缺少 zone 参数"
          }
        }
      },
      "post": {
        "description": "",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PostBody"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP200"
                }
              }
            }
          },
          "401": {
            "description": "未授权",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP401"
                }
              }
            }
          },
          "400": {
            "description": "错误请求",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP400"
                }
              }
            }
          }
        }
      }
    },
    "/response": {
      "get": {
        "description": "",
        "parameters": [
          {
            "in": "query",
            "name": "response_id",
            "description": "响应 ID",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "成功",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP200"
                }
              }
            }
          },
          "401": {
            "description": "未授权",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP401"
                }
              }
            }
          },
          "400": {
            "description": "错误请求",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTP400"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PostBody": {
        "required": ["zone", "url", "format"],
        "type": "object",
        "properties": {
          "zone": {
            "description": "将为您的请求提供服务的代理区域名称。",
            "type": "string"
          },
          "url": {
            "description": "请求的目标 URL。",
            "type": "string"
          },
          "format": {
            "description": "通过代理请求原始 HTML 的格式为 `raw`。\n\n请求 JSON 响应的格式为 `json`。",
            "type": "string",
            "enum": ["raw", "json"]
          },
          "method": {
            "description": "通过代理请求 HTML 的方法为 `GET`。",
            "type": "string",
            "default": "GET"
          },
          "country": {
            "description": "请求通过的代理所在的国家代码。",
            "type": "string"
          },
          "city": {
            "description": "请求通过的代理所在的城市名称，必须定义国家。\n\n在数据中心和 ISP 区域中支持预配置城市，在住宅和移动网络中默认支持。",
            "type": "string"
          },
          "zip": {
            "description": "请求通过的代理所在的邮政编码，必须定义国家。\n\n仅在住宅网络中支持。",
            "type": "string"
          },
          "ASN": {
            "description": "请求通过的代理所在的 ASN 代码，必须定义国家。\n\n仅在住宅网络中支持。",
            "type": "string"
          },
          "carrier": {
            "description": "仅适用于移动网络：请求通过的运营商代码。\n\n仅在移动网络中支持。",
            "type": "string"
          },
          "os": {
            "description": "设置在代理上的客户端操作系统。\n\n仅在移动网络中支持。",
            "type": "string"
          },
          "dns": {
            "description": "使用 `local` 或 `remote` 设置域名映射是在客户端本地还是在远程代理节点上完成。",
            "type": "string",
            "enum": ["local", "remote"]
          },
          "session": {
            "description": "客户端传递的字符串以标记会话，所有具有相同 session 参数的请求将被传递到相同的代理节点。",
            "type": "string"
          },
          "ip": {
            "description": "在数据中心和 ISP 区域中：将请求转发到由 `ip` 标识的特定代理。",
            "type": "string"
          },
          "gip": {
            "description": "在 `住宅` 和 `移动` 区域中：将请求转发到由 `gip` 标识的特定代理组。",
            "type": "string"
          },
          "c_tag": {
            "description": "在请求中包含唯一的 `c_tag` 标志。响应中，业务端会在头部返回相同的标志。此无缝交换确保每个响应都绑定到其对应的请求，消除混淆并简化数据管理。",
            "type": "string"
          },
          "direct": {
            "description": "将参数设置为 `true` 会指示通过 Bright Data 超级代理（数据中心代理，而非代理节点本身）处理请求。",
            "type": "boolean"
          }
        }
      },
      "HTTP200": {
        "type": "string",
        "example": "OK"
      },
      "HTTP401": {
        "type": "string",
        "example": "需要用户身份验证"
      },
      "HTTP400": {
        "type": "string",
        "example": "错误请求"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "在 Authorization 头中使用您的 Bright Data API Key 作为 Bearer token。\n\n**认证方法:**\n1. 从 Bright Data 账户设置获取您的 API Key: https://brightdata.com/cp/setting/users\n2. 在请求的 Authorization 头中包含 API Key\n3. 格式: `Authorization: Bearer YOUR_API_KEY`\n\n**示例:**\n```\nAuthorization: Bearer b5648e1096c6442f60a6c4bbbe73f8d2234d3d8324554bd6a7ec8f3f251f07df\n```\n\n了解如何获取 Bright Data API Key: https://docs.brightdata.com/cn/api-reference/authentication#如何生成新的-api-key？",
        "bearerFormat": "API Key"
      }
    }
  }
}
