SDK và Thư viện
FourA là một REST API: bạn có thể sử dụng nó với bất kỳ ngôn ngữ nào hỗ trợ HTTP. Dưới đây là các ví dụ bắt đầu nhanh bằng các ngôn ngữ phổ biến nhất.
Python
Sử dụng thư viện 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
Sử dụng fetch tích hợp sẵn (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
Cách đơn giản nhất để kiểm tra từ dòng lệnh:
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]
Máy chủ MCP (dành cho các agent LLM)
Nếu bạn đang xây dựng một agent LLM (Claude Desktop, Claude Code, Cursor, Windsurf, VS Code), hãy bỏ qua HTTP client thô và sử dụng máy chủ @fouradata/mcp. Nó hiển thị cả bốn endpoint FourA dưới dạng các công cụ Model Context Protocol gốc (foura_auto, foura_single, foura_proxy, foura_browser) với các response được định kiểu, vì vậy agent có thể chọn đúng phương thức mà bạn không cần viết bất kỳ mã kết nối nào.
Cấu hình tối thiểu cho Claude Desktop:
{
"mcpServers": {
"foura": {
"command": "npx",
"args": ["-y", "@fouradata/mcp"],
"env": { "FOURA_API_KEY": "pk_live_..." }
}
}
}
Thiết lập đầy đủ cho mọi client được hỗ trợ: Máy chủ MCP.
Các bước tiếp theo
- Bắt đầu nhanh: Request đầu tiên của bạn
- Xác thực: Nhận API key của bạn
- API Endpoint: Tài liệu tham khảo đầy đủ
- Máy chủ MCP: Sử dụng FourA làm bộ công cụ MCP