Criar sessão de navegador
Inicia uma nova sessão de navegador na nuvem em um ambiente isolado (sandboxed).
curl --request POST \
--url https://api.firecrawl.dev/v2/browser \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ttl": 300,
"activityTtl": 1805,
"streamWebView": true
}
'import requests
url = "https://api.firecrawl.dev/v2/browser"
payload = {
"ttl": 300,
"activityTtl": 1805,
"streamWebView": True
}
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({ttl: 300, activityTtl: 1805, streamWebView: true})
};
fetch('https://api.firecrawl.dev/v2/browser', 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/browser",
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([
'ttl' => 300,
'activityTtl' => 1805,
'streamWebView' => true
]),
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/browser"
payload := strings.NewReader("{\n \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\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/browser")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/browser")
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 \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"id": "<string>",
"cdpUrl": "<string>",
"liveViewUrl": "<string>",
"interactiveLiveViewUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}{
"error": "Payment required to access this resource."
}Cabeçalhos
| Cabeçalho | Valor |
|---|---|
Authorization | Bearer <API_KEY> |
Content-Type | application/json |
Corpo da Requisição
| Parâmetro | Tipo | Obrigatório | Padrão | Descrição |
|---|---|---|---|---|
ttl | number | Não | 300 | Tempo de vida total da sessão, em segundos (30-3600) |
activityTtl | number | Não | 60 | Número de segundos de inatividade antes que a sessão seja destruída (10-3600) |
profile | object | Não | — | Habilita armazenamento persistente entre sessões. Veja abaixo. |
profile.name | string | Sim* | — | Nome do perfil (1-128 caracteres). Sessões com o mesmo nome compartilham o armazenamento. |
profile.saveChanges | boolean | Não | true | Quando true, o estado do navegador é salvo de volta no perfil ao fechar. Defina como false para carregar dados existentes sem gravar. Apenas um salvamento é permitido por vez. |
Resposta
| Campo | Tipo | Descrição |
|---|---|---|
success | boolean | Indica se a sessão foi criada |
id | string | Identificador único da sessão |
cdpUrl | string | URL WebSocket para conexões CDP |
liveViewUrl | string | URL para assistir à sessão em tempo real |
interactiveLiveViewUrl | string | URL para interagir com a sessão em tempo real (clicar, digitar, rolar) |
expiresAt | string | Quando a sessão expira com base no TTL |
Exemplo de requisição
curl -X POST "https://api.firecrawl.dev/v2/browser" \
-H "Authorization: Bearer $FIRECRAWL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"ttl": 120
}'
Resposta de exemplo
{
"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"
}
Autorizações
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Corpo
Tempo de vida máximo, em segundos, da sessão de navegador
30 <= x <= 3600Tempo, em segundos, antes de a sessão ser encerrada por inatividade
10 <= x <= 3600Indica se uma visualização ao vivo do navegador deve ser transmitida
Ativar o armazenamento persistente entre sessões do navegador. Dados salvos em uma sessão podem ser carregados em outra sessão posteriormente usando o mesmo nome.
Show child attributes
Show child attributes
Resposta
Sessão de navegador criada com sucesso
Identificador exclusivo da sessão
URL de WebSocket para acesso ao Chrome DevTools Protocol
URL para visualizar a sessão do navegador em tempo real
URL para interagir em tempo real com a sessão do navegador (clicar, digitar, rolar)
Momento em que a sessão irá expirar, com base no TTL
curl --request POST \
--url https://api.firecrawl.dev/v2/browser \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"ttl": 300,
"activityTtl": 1805,
"streamWebView": true
}
'import requests
url = "https://api.firecrawl.dev/v2/browser"
payload = {
"ttl": 300,
"activityTtl": 1805,
"streamWebView": True
}
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({ttl: 300, activityTtl: 1805, streamWebView: true})
};
fetch('https://api.firecrawl.dev/v2/browser', 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/browser",
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([
'ttl' => 300,
'activityTtl' => 1805,
'streamWebView' => true
]),
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/browser"
payload := strings.NewReader("{\n \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\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/browser")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.firecrawl.dev/v2/browser")
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 \"ttl\": 300,\n \"activityTtl\": 1805,\n \"streamWebView\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"id": "<string>",
"cdpUrl": "<string>",
"liveViewUrl": "<string>",
"interactiveLiveViewUrl": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}{
"error": "Payment required to access this resource."
}