Interactセッションでコードを実行
curl --request POST \
--url https://api.firecrawl.dev/v2/interact/{sessionId}/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"language": "node",
"timeout": 150
}
'import requests
url = "https://api.firecrawl.dev/v2/interact/{sessionId}/execute"
payload = {
"code": "<string>",
"language": "node",
"timeout": 150
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', language: 'node', timeout: 150})
};
fetch('https://api.firecrawl.dev/v2/interact/{sessionId}/execute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firecrawl.dev/v2/interact/{sessionId}/execute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'language' => 'node',
'timeout' => 150
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firecrawl.dev/v2/interact/{sessionId}/execute"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firecrawl.dev/v2/interact/{sessionId}/execute")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/interact/{sessionId}/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"exitCode": 123,
"killed": true,
"result": "<string>",
"stderr": "<string>",
"stdout": "<string>",
"success": true
}{
"error": "Payment required to access this resource."
}Interact エンドポイント
セッションでのコード実行
スタンドアロンのInteractセッションで、Playwrightまたはagent-browserのコードを実行します。
POST
/
interact
/
{sessionId}
/
execute
Interactセッションでコードを実行
curl --request POST \
--url https://api.firecrawl.dev/v2/interact/{sessionId}/execute \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"code": "<string>",
"language": "node",
"timeout": 150
}
'import requests
url = "https://api.firecrawl.dev/v2/interact/{sessionId}/execute"
payload = {
"code": "<string>",
"language": "node",
"timeout": 150
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({code: '<string>', language: 'node', timeout: 150})
};
fetch('https://api.firecrawl.dev/v2/interact/{sessionId}/execute', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.firecrawl.dev/v2/interact/{sessionId}/execute",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'code' => '<string>',
'language' => 'node',
'timeout' => 150
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.firecrawl.dev/v2/interact/{sessionId}/execute"
payload := strings.NewReader("{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.firecrawl.dev/v2/interact/{sessionId}/execute")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/interact/{sessionId}/execute")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"code\": \"<string>\",\n \"language\": \"node\",\n \"timeout\": 150\n}"
response = http.request(request)
puts response.read_body{
"error": "<string>",
"exitCode": 123,
"killed": true,
"result": "<string>",
"stderr": "<string>",
"stdout": "<string>",
"success": true
}{
"error": "Payment required to access this resource."
}ヘッダー
| ヘッダー | 値 |
|---|---|
Authorization | Bearer <API_KEY> |
Content-Type | application/json |
リクエストボディ
| パラメータ | 型 | 必須 | デフォルト | 説明 |
|---|---|---|---|---|
code | string | はい | - | 実行するコード(1〜100,000 文字) |
language | string | いいえ | "node" | コードの言語:"python"、"node"、または "bash"(agent-browser CLI コマンド用) |
timeout | number | いいえ | - | 実行タイムアウト時間(秒、1〜300) |
レスポンス
| Field | Type | Description |
|---|---|---|
success | boolean | コードが正常に実行されたかどうか |
stdout | string | コード実行時の標準出力 |
result | string | コード実行時の標準出力 |
stderr | string | コード実行時の標準エラー出力 |
exitCode | number | 実行されたプロセスの終了コード |
killed | boolean | プロセスがタイムアウトにより強制終了されたかどうか |
error | string | 実行が失敗した場合のエラーメッセージ(失敗時のみ含まれる) |
リクエスト例
curl -X POST "https://api.firecrawl.dev/v2/interact/550e8400-e29b-41d4-a716-446655440000/execute" \
-H "Authorization: Bearer $FIRECRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"code": "await page.goto(\"https://example.com\")\ntitle = await page.title()\nprint(title)",
"language": "python"
}'
成功時のレスポンス例
{
"success": true,
"result": "Example Domain"
}
エラー時のレスポンス例
{
"success": true,
"error": "TimeoutError: page.goto: Timeout 30000ms exceeded."
}
Firecrawl API key が必要な AI agent ですか?自動オンボーディングの手順については、firecrawl.dev/agent-onboarding/SKILL.mdを参照してください。
承認
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
パスパラメータ
InteractセッションID
ボディ
application/json
⌘I

