快速入门
在两分钟内从零开始完成您的首次数据收集。
前提条件
第 1 步:获取您的 API 密钥
登录 Dashboard 并创建一个 API 密钥。它看起来像这样: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。
第 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 主体(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"]}}
}'
尝试 browser 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 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
}
}'
下一步
- 身份验证:API 密钥管理和安全性
- API Endpoint:所有四个 endpoint 的完整参数参考
- 智能获取 (Auto):auto endpoint 如何决定执行的操作
- SDK 与库:Python、Node.js、Go、Ruby 示例
- 选择合适的 Endpoint:何时选择 auto、single、browser 或 proxy