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 serverを使用してください。これにより、4つすべてのFourAエンドポイントがネイティブのModel Context Protocolツール(foura_auto、foura_single、foura_proxy、foura_browser)として型付きレスポンスと共に公開されるため、グルーコードを記述しなくても、エージェントが適切なメソッドを選択できます。
Claude Desktopの最小構成:
{
"mcpServers": {
"foura": {
"command": "npx",
"args": ["-y", "@fouradata/mcp"],
"env": { "FOURA_API_KEY": "pk_live_..." }
}
}
}
サポートされているすべてのクライアントの完全なセットアップ: MCP Server。
次のステップ
- Quick Start: 最初のリクエスト
- Authentication: APIキーの取得
- API Endpoints: 完全なリファレンス
- MCP Server: FourAをMCPツールセットとして使用