Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(php-sdk): add ScreenshotFormat, missing params, and browser improvements

Devin AI087f8b561480
diff --git a/apps/php-sdk/src/Client/FirecrawlClient.php b/apps/php-sdk/src/Client/FirecrawlClient.php
index e6cef00f6..e237b51c1 100644
--- a/apps/php-sdk/src/Client/FirecrawlClient.php
+++ b/apps/php-sdk/src/Client/FirecrawlClient.php
@@ -123,6 +123,7 @@ final class FirecrawlClient
string $language = 'node',
?int $timeout = null,
?string $origin = null,
+ ?string $prompt = null,
): BrowserExecuteResponse {
$body = [
'code' => $code,
@@ -134,6 +135,9 @@ final class FirecrawlClient
if ($origin !== null) {
$body['origin'] = $origin;
}
+ if ($prompt !== null) {
+ $body['prompt'] = $prompt;
+ }
return BrowserExecuteResponse::fromArray(
$this->http->post("/v2/scrape/{$jobId}/interact", $body),
@@ -399,11 +403,14 @@ final class FirecrawlClient
/**
* Create a new browser session.
+ *
+ * @param array<string, string>|null $profile
*/
public function browser(
?int $ttl = null,
?int $activityTtl = null,
?bool $streamWebView = null,
+ ?array $profile = null,
): BrowserCreateResponse {
$body = [];
if ($ttl !== null) {
@@ -415,6 +422,9 @@ final class FirecrawlClient
if ($streamWebView !== null) {
$body['streamWebView'] = $streamWebView;
}
+ if ($profile !== null) {
+ $body['profile'] = $profile;
+ }
return BrowserCreateResponse::fromArray($this->http->post('/v2/browser', $body));
}
diff --git a/apps/php-sdk/src/Models/BrowserCreateResponse.php b/apps/php-sdk/src/Models/BrowserCreateResponse.php
index 4a69d4ff7..05ad54133 100644
--- a/apps/php-sdk/src/Models/BrowserCreateResponse.php
+++ b/apps/php-sdk/src/Models/BrowserCreateResponse.php
@@ -11,6 +11,7 @@ final class BrowserCreateResponse
private readonly ?string $id = null,
private readonly ?string $cdpUrl = null,
private readonly ?string $liveViewUrl = null,
+ private readonly ?string $interactiveLiveViewUrl = null,
private readonly ?string $expiresAt = null,
private readonly ?string $error = null,
) {}
@@ -23,6 +24,7 @@ final class BrowserCreateResponse
id: $data['id'] ?? null,
cdpUrl: $data['cdpUrl'] ?? null,
liveViewUrl: $data['liveViewUrl'] ?? null,
+ interactiveLiveViewUrl: $data['interactiveLiveViewUrl'] ?? null,
expiresAt: $data['expiresAt'] ?? null,
error: $data['error'] ?? null,
);
@@ -57,4 +59,9 @@ final class BrowserCreateResponse
{
return $this->error;
}
+
+ public function getInteractiveLiveViewUrl(): ?string
+ {
+ return $this->interactiveLiveViewUrl;
+ }
}
diff --git a/apps/php-sdk/src/Models/ScrapeOptions.php b/apps/php-sdk/src/Models/ScrapeOptions.php
index 28153bf57..15be371b3 100644
--- a/apps/php-sdk/src/Models/ScrapeOptions.php
+++ b/apps/php-sdk/src/Models/ScrapeOptions.php
@@ -7,7 +7,7 @@ namespace Firecrawl\Models;
final class ScrapeOptions
{
/**
- * @param list<string|JsonFormat>|null $formats
+ * @param list<string|JsonFormat|ScreenshotFormat>|null $formats
* @param array<string, string>|null $headers
* @param list<string>|null $includeTags
* @param list<string>|null $excludeTags
@@ -31,18 +31,23 @@ final class ScrapeOptions
private readonly ?bool $blockAds = null,
private readonly ?string $proxy = null,
private readonly ?int $maxAge = null,
+ private readonly ?int $minAge = null,
private readonly ?bool $storeInCache = null,
private readonly ?bool $lockdown = null,
private readonly ?string $integration = null,
+ /** @var array<string, string>|null */
+ private readonly ?array $profile = null,
+ private readonly ?bool $changeTracking = null,
) {}
/**
- * @param list<string|JsonFormat>|null $formats
- * @param array<string, string>|null $headers
- * @param list<string>|null $includeTags
- * @param list<string>|null $excludeTags
- * @param list<mixed>|null $parsers
- * @param list<array<string, mixed>>|null $actions
+ * @param list<string|JsonFormat|ScreenshotFormat>|null $formats
+ * @param array<string, string>|null $headers
+ * @param list<string>|null $includeTags
+ * @param list<string>|null $excludeTags
+ * @param list<mixed>|null $parsers
+ * @param list<array<string, mixed>>|null $actions
+ * @param array<string, string>|null $profile
*/
public static function with(
?array $formats = null,
@@ -64,12 +69,16 @@ final class ScrapeOptions
?bool $storeInCache = null,
?string $integration = null,
?bool $lockdown = null,
+ ?int $minAge = null,
+ ?array $profile = null,
+ ?bool $changeTracking = null,
): self {
return new self(
$formats, $headers, $includeTags, $excludeTags, $onlyMainContent,
$timeout, $waitFor, $mobile, $parsers, $actions, $location,
$skipTlsVerification, $removeBase64Images, $blockAds, $proxy,
- $maxAge, $storeInCache, $lockdown, $integration,
+ $maxAge, $minAge, $storeInCache, $lockdown, $integration, $profile,
+ $changeTracking,
);
}
@@ -80,7 +89,8 @@ final class ScrapeOptions
if ($this->formats !== null) {
$data['formats'] = array_map(
- fn (string|JsonFormat $f): string|array => $f instanceof JsonFormat ? $f->toArray() : $f,
+ fn (string|JsonFormat|ScreenshotFormat $f): string|array =>
+ $f instanceof JsonFormat || $f instanceof ScreenshotFormat ? $f->toArray() : $f,
$this->formats,
);
}
@@ -101,9 +111,12 @@ final class ScrapeOptions
'blockAds' => $this->blockAds,
'proxy' => $this->proxy,
'maxAge' => $this->maxAge,
+ 'minAge' => $this->minAge,
'storeInCache' => $this->storeInCache,
'lockdown' => $this->lockdown,
'integration' => $this->integration,
+ 'profile' => $this->profile,
+ 'changeTracking' => $this->changeTracking,
];
foreach ($fields as $key => $value) {
@@ -115,7 +128,7 @@ final class ScrapeOptions
return $data;
}
- /** @return list<string|JsonFormat>|null */
+ /** @return list<string|JsonFormat|ScreenshotFormat>|null */
public function getFormats(): ?array
{
return $this->formats;
@@ -215,4 +228,20 @@ final class ScrapeOptions
{
return $this->integration;
}
+
+ public function getMinAge(): ?int
+ {
+ return $this->minAge;
+ }
+
+ /** @return array<string, string>|null */
+ public function getProfile(): ?array
+ {
+ return $this->profile;
+ }
+
+ public function getChangeTracking(): ?bool
+ {
+ return $this->changeTracking;
+ }
}
diff --git a/apps/php-sdk/src/Models/ScreenshotFormat.php b/apps/php-sdk/src/Models/ScreenshotFormat.php
new file mode 100644
index 000000000..6ffd2e760
--- /dev/null
+++ b/apps/php-sdk/src/Models/ScreenshotFormat.php
@@ -0,0 +1,40 @@
+<?php
+
+declare(strict_types=1);
+
+namespace Firecrawl\Models;
+
+final class ScreenshotFormat
+{
+ private function __construct(
+ private readonly ?bool $fullPage = null,
+ private readonly ?int $quality = null,
+ ) {}
+
+ public static function with(
+ ?bool $fullPage = null,
+ ?int $quality = null,
+ ): self {
+ return new self($fullPage, $quality);
+ }
+
+ /** @return array<string, mixed> */
+ public function toArray(): array
+ {
+ return array_filter([
+ 'type' => 'screenshot',
+ 'fullPage' => $this->fullPage,
+ 'quality' => $this->quality,
+ ], fn (mixed $v): bool => $v !== null);
+ }
+
+ public function getFullPage(): ?bool
+ {
+ return $this->fullPage;
+ }
+
+ public function getQuality(): ?int
+ {
+ return $this->quality;
+ }
+}