# Scrapfly Documentation

## Table of Contents

### Dashboard

- [Intro](https://scrapfly.io/docs)
- [Project](https://scrapfly.io/docs/project)
- [Account](https://scrapfly.io/docs/account)
- [Workspace & Team](https://scrapfly.io/docs/workspace-and-team)
- [Billing](https://scrapfly.io/docs/billing)

### Products

#### MCP Server

- [Getting Started](https://scrapfly.io/docs/mcp/getting-started)
- [Tools & API Spec](https://scrapfly.io/docs/mcp/tools)
- [Authentication](https://scrapfly.io/docs/mcp/authentication)
- [Examples & Use Cases](https://scrapfly.io/docs/mcp/examples)
- [FAQ](https://scrapfly.io/docs/mcp/faq)
##### Integrations

- [Overview](https://scrapfly.io/docs/mcp/integrations)
- [Claude Desktop](https://scrapfly.io/docs/mcp/integrations/claude-desktop)
- [Claude Code](https://scrapfly.io/docs/mcp/integrations/claude-code)
- [ChatGPT](https://scrapfly.io/docs/mcp/integrations/chatgpt)
- [Cursor](https://scrapfly.io/docs/mcp/integrations/cursor)
- [Cline](https://scrapfly.io/docs/mcp/integrations/cline)
- [Windsurf](https://scrapfly.io/docs/mcp/integrations/windsurf)
- [Zed](https://scrapfly.io/docs/mcp/integrations/zed)
- [Roo Code](https://scrapfly.io/docs/mcp/integrations/roo-code)
- [VS Code](https://scrapfly.io/docs/mcp/integrations/vscode)
- [LangChain](https://scrapfly.io/docs/mcp/integrations/langchain)
- [LlamaIndex](https://scrapfly.io/docs/mcp/integrations/llamaindex)
- [CrewAI](https://scrapfly.io/docs/mcp/integrations/crewai)
- [OpenAI](https://scrapfly.io/docs/mcp/integrations/openai)
- [n8n](https://scrapfly.io/docs/mcp/integrations/n8n)
- [Make](https://scrapfly.io/docs/mcp/integrations/make)
- [Zapier](https://scrapfly.io/docs/mcp/integrations/zapier)
- [Vapi AI](https://scrapfly.io/docs/mcp/integrations/vapi)
- [Agent Builder](https://scrapfly.io/docs/mcp/integrations/agent-builder)
- [Custom Client](https://scrapfly.io/docs/mcp/integrations/custom-client)


#### Web Scraping API

- [Getting Started](https://scrapfly.io/docs/scrape-api/getting-started)
- [API Specification]()
- [Monitoring](https://scrapfly.io/docs/monitoring)
- [Customize Request](https://scrapfly.io/docs/scrape-api/custom)
- [Debug](https://scrapfly.io/docs/scrape-api/debug)
- [Unblocker (formerly ASP)](https://scrapfly.io/docs/scrape-api/unblocker)
- [Proxy](https://scrapfly.io/docs/scrape-api/proxy)
- [Proxy Mode](https://scrapfly.io/docs/scrape-api/proxy-mode)
- [Proxy Mode - Screaming Frog](https://scrapfly.io/docs/scrape-api/proxy-mode/screaming-frog)
- [Proxy Mode - Apify](https://scrapfly.io/docs/scrape-api/proxy-mode/apify)
- [(Auto) Data Extraction](https://scrapfly.io/docs/scrape-api/extraction)
- [Javascript Rendering](https://scrapfly.io/docs/scrape-api/javascript-rendering)
- [Javascript Scenario](https://scrapfly.io/docs/scrape-api/javascript-scenario)
- [SSL](https://scrapfly.io/docs/scrape-api/ssl)
- [DNS](https://scrapfly.io/docs/scrape-api/dns)
- [Cache](https://scrapfly.io/docs/scrape-api/cache)
- [Batch (Multi-URL Scraping)](https://scrapfly.io/docs/scrape-api/batch)
- [Session](https://scrapfly.io/docs/scrape-api/session)
- [Webhook](https://scrapfly.io/docs/scrape-api/webhook)
- [Schedule](https://scrapfly.io/docs/scrape-api/schedule)
- [Screenshot](https://scrapfly.io/docs/scrape-api/screenshot)
- [Errors](https://scrapfly.io/docs/scrape-api/errors)
- [Timeout](https://scrapfly.io/docs/scrape-api/understand-timeout)
- [Throttling](https://scrapfly.io/docs/throttling)
- [Troubleshoot](https://scrapfly.io/docs/scrape-api/troubleshoot)
- [Billing](https://scrapfly.io/docs/scrape-api/billing)
- [FAQ](https://scrapfly.io/docs/scrape-api/faq)

#### Crawler API

- [Getting Started](https://scrapfly.io/docs/crawler-api/getting-started)
- [API Specification]()
- [Retrieving Results](https://scrapfly.io/docs/crawler-api/results)
- [WARC Format](https://scrapfly.io/docs/crawler-api/warc-format)
- [Data Extraction](https://scrapfly.io/docs/crawler-api/extraction-rules)
- [Search](https://scrapfly.io/docs/crawler-api/search)
- [Prompt & Extract](https://scrapfly.io/docs/crawler-api/prompt)
- [Auto Refresh](https://scrapfly.io/docs/crawler-api/refresh)
- [Webhook](https://scrapfly.io/docs/crawler-api/webhook)
- [Schedule](https://scrapfly.io/docs/crawler-api/schedule)
- [Billing](https://scrapfly.io/docs/crawler-api/billing)
- [Errors](https://scrapfly.io/docs/crawler-api/errors)
- [Troubleshoot](https://scrapfly.io/docs/crawler-api/troubleshoot)
- [FAQ](https://scrapfly.io/docs/crawler-api/faq)

#### Screenshot API

- [Getting Started](https://scrapfly.io/docs/screenshot-api/getting-started)
- [API Specification]()
- [Accessibility Testing](https://scrapfly.io/docs/screenshot-api/accessibility)
- [Webhook](https://scrapfly.io/docs/screenshot-api/webhook)
- [Schedule](https://scrapfly.io/docs/screenshot-api/schedule)
- [Billing](https://scrapfly.io/docs/screenshot-api/billing)
- [Errors](https://scrapfly.io/docs/screenshot-api/errors)

#### Extraction API

- [Getting Started](https://scrapfly.io/docs/extraction-api/getting-started)
- [API Specification]()
- [Rules Template](https://scrapfly.io/docs/extraction-api/rules-and-template)
- [LLM Extraction](https://scrapfly.io/docs/extraction-api/llm-prompt)
- [AI Auto Extraction](https://scrapfly.io/docs/extraction-api/automatic-ai)
- [Webhook](https://scrapfly.io/docs/extraction-api/webhook)
- [Billing](https://scrapfly.io/docs/extraction-api/billing)
- [Errors](https://scrapfly.io/docs/extraction-api/errors)
- [FAQ](https://scrapfly.io/docs/extraction-api/faq)

#### Data API


#### Proxy Saver

- [Getting Started](https://scrapfly.io/docs/proxy-saver/getting-started)
- [Fingerprints](https://scrapfly.io/docs/proxy-saver/fingerprints)
- [Optimizations](https://scrapfly.io/docs/proxy-saver/optimizations)
- [SSL Certificates](https://scrapfly.io/docs/proxy-saver/certificates)
- [Protocols](https://scrapfly.io/docs/proxy-saver/protocols)
- [Pacfile](https://scrapfly.io/docs/proxy-saver/pacfile)
- [Secure Credentials](https://scrapfly.io/docs/proxy-saver/security)
- [Billing](https://scrapfly.io/docs/proxy-saver/billing)

#### Cloud Browser API

- [Getting Started](https://scrapfly.io/docs/cloud-browser-api/getting-started)
- [Proxy & Geo-Targeting](https://scrapfly.io/docs/cloud-browser-api/proxy)
- [Unblock API](https://scrapfly.io/docs/cloud-browser-api/unblock)
- [Captcha Solver](https://scrapfly.io/docs/cloud-browser-api/captcha-solver)
- [File Downloads](https://scrapfly.io/docs/cloud-browser-api/file-downloads)
- [Session Resume](https://scrapfly.io/docs/cloud-browser-api/session-resume)
- [Human-in-the-Loop](https://scrapfly.io/docs/cloud-browser-api/human-in-the-loop)
- [Debug Mode](https://scrapfly.io/docs/cloud-browser-api/debug-mode)
- [Browser Extensions](https://scrapfly.io/docs/cloud-browser-api/extensions)
- [Credential Vault](https://scrapfly.io/docs/cloud-browser-api/credential-vault)
- [Native Browser MCP](https://scrapfly.io/docs/cloud-browser-api/mcp)
- [DevTools Protocol](https://scrapfly.io/docs/cloud-browser-api/cdp-reference)
##### Integrations

- [Puppeteer](https://scrapfly.io/docs/cloud-browser-api/puppeteer)
- [Playwright](https://scrapfly.io/docs/cloud-browser-api/playwright)
- [Selenium](https://scrapfly.io/docs/cloud-browser-api/selenium)
- [Vercel Agent Browser](https://scrapfly.io/docs/cloud-browser-api/agent-browser)
- [Browser Use](https://scrapfly.io/docs/cloud-browser-api/browser-use)
- [Stagehand](https://scrapfly.io/docs/cloud-browser-api/stagehand)
- [1Password](https://scrapfly.io/docs/cloud-browser-api/1password)

- [Billing](https://scrapfly.io/docs/cloud-browser-api/billing)
- [Errors](https://scrapfly.io/docs/cloud-browser-api/errors)


### Tools

- [Antibot Detector](https://scrapfly.io/docs/tools/antibot-detector)

### SDK

- [Golang](https://scrapfly.io/docs/sdk/golang)
- [PHP](https://scrapfly.io/docs/sdk/php)
- [Python](https://scrapfly.io/docs/sdk/python)
- [Rust](https://scrapfly.io/docs/sdk/rust)
- [TypeScript](https://scrapfly.io/docs/sdk/typescript)
- [Scrapy](https://scrapfly.io/docs/sdk/scrapy)

### Integrations

- [Getting Started](https://scrapfly.io/docs/integration/getting-started)
- [LangChain](https://scrapfly.io/docs/integration/langchain)
- [LlamaIndex](https://scrapfly.io/docs/integration/llamaindex)
- [CrewAI](https://scrapfly.io/docs/integration/crewai)
- [Zapier](https://scrapfly.io/docs/integration/zapier)
- [Make](https://scrapfly.io/docs/integration/make)
- [n8n](https://scrapfly.io/docs/integration/n8n)

### Academy

- [Overview](https://scrapfly.io/academy)
- [Web Scraping Overview](https://scrapfly.io/academy/scraping-overview)
- [Tools](https://scrapfly.io/academy/tools-overview)
- [Reverse Engineering](https://scrapfly.io/academy/reverse-engineering)
- [Static Scraping](https://scrapfly.io/academy/static-scraping)
- [HTML Parsing](https://scrapfly.io/academy/html-parsing)
- [Dynamic Scraping](https://scrapfly.io/academy/dynamic-scraping)
- [Hidden API Scraping](https://scrapfly.io/academy/hidden-api-scraping)
- [Headless Browsers](https://scrapfly.io/academy/headless-browsers)
- [Hidden Web Data](https://scrapfly.io/academy/hidden-web-data)
- [JSON Parsing](https://scrapfly.io/academy/json-parsing)
- [Data Processing](https://scrapfly.io/academy/data-processing)
- [Scaling](https://scrapfly.io/academy/scaling)
- [Walkthrough Summary](https://scrapfly.io/academy/walkthrough-summary)
- [Scraper Blocking](https://scrapfly.io/academy/scraper-blocking)
- [Proxies](https://scrapfly.io/academy/proxies)

---

#  PHP SDK

 The PHP SDK is a client for the Scrapfly [Web Scraping API](https://scrapfly.io/docs/scrape-api/getting-started), [Screenshot API](https://scrapfly.io/docs/screenshot-api/getting-started), [Extraction API](https://scrapfly.io/docs/extraction-api/getting-started) and [Crawler API](https://scrapfly.io/docs/crawler-api/getting-started), built on Guzzle. It follows the official Python, TypeScript, Go and Rust SDKs, so a request reads the same in every language.

- One config class per API (`ScrapeConfig`, `ScreenshotConfig`, `ExtractionConfig`, `CrawlerConfig`), every option a named argument
- Enums for the fixed values: `ProxyPool`, `Format`, `ScreenshotFormat`, `CrawlerContentFormat`, ...
- Typed exceptions carrying the API error code, the HTTP status and whether a retry may succeed
- A `Crawl` helper that drives a crawl from its start to its content, search and extraction included
- `concurrentScrape()` on a Guzzle pool

It requires PHP 8.3 or newer.

> Source code and examples live on [GitHub](https://github.com/scrapfly/php-scrapfly). The package is [scrapfly/scrapfly-sdk](https://packagist.org/packages/scrapfly/scrapfly-sdk) on Packagist.

## Installation

```
composer require scrapfly/scrapfly-sdk
```

## Quick Use

```
<?php

require 'vendor/autoload.php';

use Scrapfly\ScrapflyClient;
use Scrapfly\ScrapeConfig;

$client = new ScrapflyClient(key: 'YOUR_API_KEY');

$response = $client->scrape(new ScrapeConfig(url: 'https://web-scraping.dev/product/1'));

echo $response->statusCode(), "\n";
echo $response->content();
```

## Configuring Scrape

 Every option of the [Web Scraping API](https://scrapfly.io/docs/scrape-api/getting-started#spec) is a named argument of `ScrapeConfig`, in camel case: `render_js` is `renderJs`, `wait_for_selector` is `waitForSelector`.

> For websites protected against web scraping, enable the Unblocker: `unblocker: true`.

```
use Scrapfly\Format;
use Scrapfly\ScrapeConfig;

$config = new ScrapeConfig(
    url: 'https://web-scraping.dev/product/1',
    // request details
    method: 'GET',
    headers: ['X-Csrf-Token' => '1234'],

    // proxies and the Unblocker
    unblocker: true,
    country: 'us,ca,fr',

    // cache (recommended when developing)
    cache: true,
    cacheTtl: 3600,
    debug: true,

    // javascript rendering
    renderJs: true,
    waitForSelector: '.review',
    renderingWait: 5000,
    js: 'return document.title',
    autoScroll: true,

    format: Format::Markdown,
    tags: ['products'],
);

$response = $client->scrape($config);
```

### Proxy Pools

 `proxyPool` picks the proxy pool of the Web Scraping API and the Crawler API; the Screenshot API picks its pool itself and ignores it. The Unblocker is its own flag: `unblocker: true`.

| Case | Sent as | What it runs |
|---|---|---|
| `ProxyPool::PublicDatacenterPool` | `public_datacenter_pool` | datacenter proxies, the default |
| `ProxyPool::PublicResidentialPool` | `public_residential_pool` | residential proxies |
| `ProxyPool::PublicTorPool` | `public_tor_pool` | the Tor network, the only pool that reaches `.onion` sites |

 A pool of your own is passed by name, as a string. The `Basic`, `Unblocker`, `UnblockerUltra` and `Auto` cases of `ProxyPool` are not accepted by the API yet. See [the proxy pools](https://scrapfly.io/docs/scrape-api/proxy#proxy-pools) for the pools of your account.

## Handling Result

```
$response = $client->scrape($config);

// the page and the target's status code
$html = $response->content();
$status = $response->statusCode();

// the target's response headers, and the final URL after redirects
$headers = $response->responseHeaders();
$url = $response->url();

// this scrape in your Scrapfly dashboard, and what it cost
$logUrl = $response->logUrl();
$credits = $response->cost();

// the result block, and the whole API answer with its config and context
$result = $response->result();
$answer = $response->data;
```

## Concurrent Scraping

 `concurrentScrape()` runs a list of configs at most `$concurrency` at a time, your account's limit when left out. The results come back in the order of the configs, a failed scrape as its exception:

```
use Scrapfly\Exception\ScrapflyException;

$results = $client->concurrentScrape([
    new ScrapeConfig(url: 'https://web-scraping.dev/product/1'),
    new ScrapeConfig(url: 'https://web-scraping.dev/product/2'),
    new ScrapeConfig(url: 'https://web-scraping.dev/product/3'),
], concurrency: 3);

foreach ($results as $result) {
    if ($result instanceof ScrapflyException) {
        echo 'failed: ', $result->getErrorCode(), "\n";
        continue;
    }
    echo $result->url(), ': ', strlen($result->content()), " bytes\n";
}
```

## Batch Scraping

 `scrapeBatch()` sends up to 100 scrapes in one request and yields each result as soon as its scrape finishes, keyed by the correlation id of its config. Every config needs one of its own. A failed scrape is yielded as its exception, never thrown, and a config with `proxifiedResponse: true` yields the target's own response. Batch scraping is not on the FREE plan.

```
use Scrapfly\Exception\ScrapflyException;

foreach ($client->scrapeBatch([
    new ScrapeConfig(url: 'https://web-scraping.dev/product/1', correlationId: 'product-1'),
    new ScrapeConfig(url: 'https://web-scraping.dev/product/2', correlationId: 'product-2'),
]) as $correlationId => $result) {
    if ($result instanceof ScrapflyException) {
        echo $correlationId, ' failed: ', $result->getErrorCode(), "\n";
        continue;
    }
    echo $correlationId, ': ', $result->statusCode(), "\n";
}
```

 `scrapeBatchAsync()` runs the same batch on Guzzle's promises: each result goes to a callback as soon as its part arrives, and the batch shares Guzzle's event loop with your other async requests.

```
$promise = $client->scrapeBatchAsync($configs, function (string $correlationId, $result): void {
    // called as each scrape finishes
});

$promise->wait();
```

## Getting Account Details

```
$account = $client->account();
print_r($account['subscription']['usage']['scrape']);
```

## Examples

### POST Form

`data` is encoded from the `content-type` header, a form by default:

```
$response = $client->scrape(new ScrapeConfig(
    url: 'https://httpbin.dev/post',
    method: 'POST',
    data: ['product' => 'Box of Chocolate Candy', 'quantity' => 2],
));
```

### POST JSON

```
$response = $client->scrape(new ScrapeConfig(
    url: 'https://httpbin.dev/post',
    method: 'POST',
    headers: ['Content-Type' => 'application/json'],
    data: ['product' => 'Box of Chocolate Candy', 'quantity' => 2],
));
```

### JavaScript Scenario

```
$response = $client->scrape(new ScrapeConfig(
    url: 'https://web-scraping.dev/product/1',
    renderJs: true,
    jsScenario: [
        ['click' => ['selector' => '#load-more-reviews']],
        ['wait' => 2000],
    ],
));
```

### Scraping Binary Data

A binary document comes back in `content()` as its bytes, with the `binary` format:

```
$response = $client->scrape(new ScrapeConfig(url: 'https://web-scraping.dev/assets/products/orange-chocolate-box-small-1.webp'));
file_put_contents('product.webp', $response->content());
```

## Screenshot API

```
use Scrapfly\ScreenshotConfig;
use Scrapfly\ScreenshotFormat;
use Scrapfly\ScreenshotOption;

$screenshot = $client->screenshot(new ScreenshotConfig(
    url: 'https://web-scraping.dev/product/1',
    format: ScreenshotFormat::Png,
    capture: 'fullpage',
    options: [ScreenshotOption::BlockBanners],
));

$screenshot->save('product'); // product.png
```

## Extraction API

Extract structured data from a document you already have, with a model, a prompt or a template:

```
use Scrapfly\ExtractionConfig;

$html = $client->scrape(new ScrapeConfig(url: 'https://web-scraping.dev/product/1'))->content();

$result = $client->extract(new ExtractionConfig(
    body: $html,
    contentType: 'text/html',
    url: 'https://web-scraping.dev/product/1',
    extractionModel: 'product',
));

print_r($result->data);
```

## Crawler API

`Crawl` starts a crawl, waits for it and reads what it collected:

```
use Scrapfly\Crawler\Crawl;
use Scrapfly\CrawlerConfig;
use Scrapfly\CrawlerContentFormat;

$crawl = (new Crawl($client, new CrawlerConfig(
    url: 'https://web-scraping.dev/products',
    pageLimit: 20,
    contentFormats: [CrawlerContentFormat::Markdown],
)))->start()->wait();

echo $crawl->status()->state()['urls_visited'], " pages\n";

foreach ($crawl->contents(CrawlerContentFormat::Markdown)->contents as $url => $formats) {
    echo $url, ': ', strlen($formats['markdown']), " chars\n";
}
```

### List Crawled URLs

```
foreach ($crawl->urls('failed')->urls as $url) {
    echo $url->url, ': ', $url->reason, "\n";
}
```

### Read a Single Page's Content

```
$markdown = $crawl->content('https://web-scraping.dev/product/1', CrawlerContentFormat::Markdown);
```

### Download WARC and HAR Artifacts

```
$crawl->artifact('warc')->save('crawl.warc.gz');
$crawl->artifact('har')->save('crawl.har');

// the HTTP responses the WARC holds
foreach ($crawl->artifact('warc')->pages() as $page) {
    echo $page['status_code'], ' ', $page['url'], "\n";
}
```

### Search, Prompt and Extract

 A crawl started with `search: true` builds a search index of its pages. Wait for it with `wait(searchable: true)`, then search it, ask it a question, or extract an object shaped by a JSON Schema.

```
$crawl = (new Crawl($client, new CrawlerConfig(url: 'https://web-scraping.dev/products', pageLimit: 20, search: true)))
    ->start()
    ->wait(searchable: true);

// ranked chunks of the crawled pages
$hits = $crawl->search('chocolate', limit: 5);

// the answer as it is generated
foreach ($crawl->prompt('Which product is the cheapest?') as $event) {
    if ($event->isToken()) {
        echo $event->data;
    }
}

// the whole answer at once
echo $crawl->promptAnswer('Which product is the cheapest?')->answer;

// an object shaped by a JSON Schema
$result = $crawl->extract('Every product with its price in USD', [
    'type' => 'object',
    'properties' => ['products' => ['type' => 'array', 'items' => [
        'type' => 'object',
        'properties' => ['name' => ['type' => 'string'], 'price' => ['type' => 'number']],
        'required' => ['name', 'price'],
    ]]],
    'required' => ['products'],
]);
print_r($result->data['products']);
```

 A prompt or an extraction is sent once and never retried. The schema constrains the model as it generates and is not checked again afterwards: validate anything you act on. `$client->crawlSearch()`, `crawlPrompt()`, `crawlPromptAnswer()` and `crawlExtract()` take a list of crawl uuids, to answer from several crawls at once.

### Cancel a Running Crawl

```
$crawl->cancel();
```

## Cloud Browser API

 `cloudBrowserUrl()` builds the CDP WebSocket URL of a session for any CDP client. `cloudBrowserUnblock()` opens a page past its anti-bot first and returns the browser with its cookies and clearance:

```
use Scrapfly\BrowserConfig;
use Scrapfly\UnblockConfig;

$wsUrl = $client->cloudBrowserUrl(new BrowserConfig(proxyPool: 'residential', country: 'us'));

$session = $client->cloudBrowserUnblock(new UnblockConfig(url: 'https://web-scraping.dev/products'));
echo $session['ws_url'], "\n";
$client->cloudBrowserSessionStop($session['session_id']);
```

 The client also manages your extensions (`cloudBrowserExtension*`), credential vaults and their items (`cloudBrowserVault*`), and reads the recording of a `debug` session (`cloudBrowserPlayback()`, `cloudBrowserVideo()`). A vault key travels in the `X-Vault-Key` header, never in a URL.

## Schedules

A schedule runs a scrape, a screenshot or a crawl on a recurrence and delivers each run to a webhook:

```
use Scrapfly\ScheduleRecurrence;
use Scrapfly\ScheduleRequest;

$schedule = $client->createScrapeSchedule(
    ['url' => 'https://web-scraping.dev/products', 'render_js' => true],
    new ScheduleRequest(webhookName: 'my-webhook', recurrence: new ScheduleRecurrence(cron: '0 */6 * * *')),
);

$client->pauseSchedule($schedule['id']);
$client->resumeSchedule($schedule['id']);
$client->cancelSchedule($schedule['id']);
```

## Error Handling

 Every exception extends `Scrapfly\Exception\ScrapflyException`, which carries the API error code (`getErrorCode()`), the HTTP status, whether a retry may succeed (`isRetryable()`, `getRetryAfter()`) and the documentation of the error:

- `UpstreamHttpClientException` / `UpstreamHttpServerException`: the target answered 4xx / 5xx. Pass `raiseOnUpstreamError: false` to get the response instead
- `UnblockerException`, `ProxyException`, `ScrapeException`, `CrawlerException`, ...: the `ERR::ASP::*`, `ERR::PROXY::*`, `ERR::SCRAPE::*`, `ERR::CRAWLER::*` errors
- `BadApiKeyException` and `TooManyRequestsException`
- `TransportException`: no answer at all (`isTimeout()`). Its message names the request URL with `key=REDACTED`, never the API key

```
use Scrapfly\Exception\TooManyRequestsException;
use Scrapfly\Exception\UnblockerException;
use Scrapfly\Exception\UpstreamHttpClientException;

try {
    $response = $client->scrape(new ScrapeConfig(url: 'https://httpbin.dev/status/403'));
} catch (UpstreamHttpClientException $e) {
    echo 'the target answered ', $e->getHttpStatusCode(), "\n";
} catch (UnblockerException $e) {
    echo 'blocked: ', $e->getErrorCode(), "\n";
} catch (TooManyRequestsException $e) {
    sleep($e->getRetryAfter() ?? 5);
}
```

## Webhooks

 Verify a delivery against your webhook's signing secret before trusting it. The signature covers the body before any `Content-Encoding`: decompress a compressed delivery first.

```
use Scrapfly\Webhook;

$body = file_get_contents('php://input');
if (!Webhook::verifySignature($body, $_SERVER['HTTP_X_SCRAPFLY_WEBHOOK_SIGNATURE'] ?? null, $secret)) {
    http_response_code(401);
    exit;
}
$payload = json_decode($body, true);
```

## Resources

- [Packagist, scrapfly/scrapfly-sdk](https://packagist.org/packages/scrapfly/scrapfly-sdk)
- [GitHub, source &amp; examples](https://github.com/scrapfly/php-scrapfly)
- [Web Scraping API reference](https://scrapfly.io/docs/scrape-api/getting-started)
- [Screenshot API reference](https://scrapfly.io/docs/screenshot-api/getting-started)
- [Extraction API reference](https://scrapfly.io/docs/extraction-api/getting-started)
- [Crawler API reference](https://scrapfly.io/docs/crawler-api/getting-started)
