快速入门
在两分钟内从零开始完成你的第一次数据采集。
前提条件
步骤 1:获取你的 API Key
登录 Dashboard 并创建 API key。格式如下:pk_live_a1b2c3d4e5f6...
复制该密钥。发出的每个 request 都需要用到它。
步骤 2:发起你的第一个 Request
打开终端并运行以下命令(将 YOUR_API_KEY 替换为你实际的 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。
步骤 3:读取 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 | 速度 | 适用场景 |
|---|---|---|
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}'
尝试 proxy 请求(自动 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
}
}'
后续内容
- 身份验证:API 密钥管理与安全
- API 端点:所有四个端点的完整参数参考
- Smart Fetch (Auto):auto 端点如何做出决策
- SDK 与库:Python、Node.js、Go、Ruby 示例
- 选择合适的端点:何时选择 auto、single、browser 或 proxy