创建交互会话
curl --request POST \
--url https://api.firecrawl.dev/v2/interact \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activityTtl": 1805,
"streamWebView": true,
"ttl": 300
}
'import requests
url = "https://api.firecrawl.dev/v2/interact"
payload = {
"activityTtl": 1805,
"streamWebView": True,
"ttl": 300
}
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({activityTtl: 1805, streamWebView: true, ttl: 300})
};
fetch('https://api.firecrawl.dev/v2/interact', 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",
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([
'activityTtl' => 1805,
'streamWebView' => true,
'ttl' => 300
]),
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"
payload := strings.NewReader("{\n \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/interact")
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 \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\n}"
response = http.request(request)
puts response.read_body{
"cdpUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"interactiveLiveViewUrl": "<string>",
"liveViewUrl": "<string>",
"success": true
}{
"error": "Payment required to access this resource."
}交互端点
创建交互会话
启动一个可通过代码控制的独立交互浏览器会话(无需预先抓取)。
POST
/
interact
创建交互会话
curl --request POST \
--url https://api.firecrawl.dev/v2/interact \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"activityTtl": 1805,
"streamWebView": true,
"ttl": 300
}
'import requests
url = "https://api.firecrawl.dev/v2/interact"
payload = {
"activityTtl": 1805,
"streamWebView": True,
"ttl": 300
}
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({activityTtl: 1805, streamWebView: true, ttl: 300})
};
fetch('https://api.firecrawl.dev/v2/interact', 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",
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([
'activityTtl' => 1805,
'streamWebView' => true,
'ttl' => 300
]),
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"
payload := strings.NewReader("{\n \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/interact")
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 \"activityTtl\": 1805,\n \"streamWebView\": true,\n \"ttl\": 300\n}"
response = http.request(request)
puts response.read_body{
"cdpUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z",
"id": "<string>",
"interactiveLiveViewUrl": "<string>",
"liveViewUrl": "<string>",
"success": true
}{
"error": "Payment required to access this resource."
}请求头
| Header | 值 |
|---|---|
Authorization | Bearer <API_KEY> |
Content-Type | application/json |
请求体
| 参数 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
ttl | number | 否 | 600 | 会话总有效期(秒)(30-3600) |
activityTtl | number | 否 | 300 | 会话在销毁前允许的不活动时长(秒)(10-3600) |
profile | object | 否 | — | 启用跨会话的持久化存储。参见下文。 |
profile.name | string | 是* | — | 配置文件名称(1-128 字符)。具有相同名称的会话共享存储。 |
profile.saveChanges | boolean | 否 | true | 当为 true 时,在关闭时会将浏览器状态保存回该配置文件。设为 false 可在不写入的情况下加载已有数据。同一时间只允许一个保存方。 |
响应
| 字段 | 类型 | 描述 |
|---|---|---|
success | boolean | 会话是否创建成功 |
id | string | 唯一的会话标识符 |
cdpUrl | string | 用于 CDP 连接的 WebSocket 地址 |
liveViewUrl | string | 用于实时查看会话的 URL |
interactiveLiveViewUrl | string | 用于与会话进行实时交互(点击、输入、滚动)的 URL |
expiresAt | string | 会话基于 TTL 的过期时间 |
请求示例
curl -X POST "https://api.firecrawl.dev/v2/interact" \
-H "Authorization: Bearer $FIRECRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ttl": 120
}'
响应示例
{
"success": true,
"id": "550e8400-e29b-41d4-a716-446655440000",
"cdpUrl": "wss://cdp-proxy.firecrawl.dev/cdp/550e8400-e29b-41d4-a716-446655440000",
"liveViewUrl": "https://liveview.firecrawl.dev/550e8400-e29b-41d4-a716-446655440000",
"interactiveLiveViewUrl": "https://liveview.firecrawl.dev/550e8400-e29b-41d4-a716-446655440000?interactive=true"
}
如果你是需要 Firecrawl API 密钥的 AI 代理,请参阅 firecrawl.dev/agent-onboarding/SKILL.md 获取自动化接入说明。
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
⌘I

