SDK 与库
FourA 是一个 REST API:您可以将其与任何支持 HTTP 的语言配合使用。以下是最常用语言的快速入门示例。
Python
使用 requests 库:
import requests
response = requests.post(
"https://eu.api.foura.ai/api/single/",
headers={
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"method": "GET",
"url": "https://example.com"
}
)
data = response.json()
print(data["data"][:200]) # First 200 chars of response body
Node.js
使用内置的 fetch(Node 18+):
const response = await fetch('https://eu.api.foura.ai/api/single/', {
method: 'POST',
headers: {
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
method: 'GET',
url: 'https://example.com'
})
});
const result = await response.json();
console.log(result.data.slice(0, 200));
cURL
从命令行进行测试的最简单方法:
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"}'
Go
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
payload, _ := json.Marshal(map[string]string{
"method": "GET",
"url": "https://example.com",
})
req, _ := http.NewRequest("POST", "https://eu.api.foura.ai/api/single/", bytes.NewBuffer(payload))
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", "application/json")
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}
Ruby
require 'net/http'
require 'json'
require 'uri'
uri = URI('https://eu.api.foura.ai/api/single/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri)
request['X-API-Key'] = 'YOUR_API_KEY'
request['Content-Type'] = 'application/json'
request.body = { method: 'GET', url: 'https://example.com' }.to_json
response = http.request(request)
puts JSON.parse(response.body)['data'][0..200]
MCP Server(用于 LLM 代理)
如果您正在构建 LLM 代理(Claude Desktop、Claude Code、Cursor、Windsurf、VS Code),请跳过原始 HTTP 客户端并使用 @fouradata/mcp 服务器。它将所有四个 FourA endpoint 暴露为原生 Model Context Protocol 工具(foura_auto、foura_single、foura_proxy、foura_browser)并提供类型化 response,这样代理即可选择正确的方法,而无需您编写任何胶水代码。
Claude Desktop 的最低配置:
{
"mcpServers": {
"foura": {
"command": "npx",
"args": ["-y", "@fouradata/mcp"],
"env": { "FOURA_API_KEY": "pk_live_..." }
}
}
}
所有支持客户端的完整设置:MCP Server。
后续步骤
- 快速入门:您的第一个 request
- 身份验证:获取您的 API 密钥
- API endpoint:完整参考
- MCP Server:将 FourA 用作 MCP 工具集