快速入门

在两分钟内从零开始完成您的首次数据采集。

前提条件

第 1 步:获取您的 API Key

登录 控制台 并创建 API key。格式如下:pk_live_a1b2c3d4e5f6...

请复制该密钥。发出的每个 request 都需要用到它。

第 2 步:发送您的第一个 Request

打开终端并运行以下命令(将 YOUR_API_KEY 替换为您实际的密钥):

curl -X POST https://eu.api.foura.ai/api/single/ \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"method": "GET", "url": "https://example.com"}'

此操作会向 example.com 发送一个 HTTP request 并返回页面 HTML。

Step 3: Read the Response

{
  "status": 200,
  "headers": [
    {
      "result": { "version": "HTTP/2", "code": 200, "reason": "" },
      "content-type": "text/html; charset=UTF-8",
      "content-length": "1256"
    }
  ],
  "data": "<!doctype html><html>...</html>",
  "total_time": 0.45
}

headers 字段是一个对象数组,每个重定向跃点对应一个对象。每个条目都包含一个 result 字段,其中包含状态行以及目标针对该跃点返回的所有 response header。

关键字段:

  • status: 目标网站返回的 HTTP 状态码
  • data: response body (HTML、JSON 或原始文本)
  • total_time: request 耗时 (秒)

步骤 4: 尝试不同的 Endpoint

FourA 针对不同场景提供了四个 endpoint:

Endpoint Speed Use when
POST /api/auto/ 不固定 (在热主机上较快) 您不确定目标站点需要哪种引擎。传入 URL 并让 FourA 自动选择最经济有效的可用路径。
POST /api/single/ 最快 (200ms-2s) 静态页面、API、服务端渲染站点
POST /api/browser/ 中等 (2s-10s) 依赖大量 JavaScript 的页面、SPA、动态内容
POST /api/proxy/ 快 (1s-5s) 会检查访问者身份的站点、按国家/地区展示不同内容的站点

尝试 auto request (智能默认选项):

curl -X POST https://eu.api.foura.ai/api/auto/ \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/product/42",
    "validate": {"data": {"accept": ["Add to cart"]}}
  }'

尝试浏览器 request:

curl -X POST https://eu.api.foura.ai/api/browser/ \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com", "timeout_ms": 15000}'

尝试发送代理 request(自动轮换 proxy):

curl -X POST https://eu.api.foura.ai/api/proxy/ \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "maxTries": 3,
    "request": {
      "method": "GET",
      "url": "https://example.com",
      "unblocker": true
    }
  }'

后续步骤

更新于: 2026年9月27日