Capture full-page screenshots of any URL from PHP with a single HTTP request. No Puppeteer, no headless browser setup — just call the API and receive an image. Works with Laravel, Symfony, WordPress, and plain PHP.
Start Free — 200 captures/month
PHP's built-in file_get_contents and stream_context_create functions are all you need
to call SnapAPI. No SDK installation required — the API speaks plain HTTP with JSON.
<?php
$apiKey = 'YOUR_API_KEY';
$payload = json_encode([
'url' => 'https://example.com',
'full_page' => true,
'format' => 'png',
'width' => 1280,
'height' => 800,
]);
$context = stream_context_create([
'http' => [
'method' => 'POST',
'header' => "Content-Type: application/json
X-Api-Key: $apiKey
",
'content' => $payload,
'timeout' => 30,
]
]);
$response = file_get_contents('https://api.snapapi.pics/v1/screenshot', false, $context);
$data = json_decode($response, true);
// $data['screenshot_url'] contains the hosted image URL
echo $data['screenshot_url'];
The response includes a screenshot_url field pointing to a hosted PNG or JPEG you can embed directly in HTML,
store to your own S3 bucket, or serve to users. The hosted URL remains accessible for 72 hours by default.
For production use, store your API key in an environment variable and retrieve it with
getenv('SNAPAPI_KEY') rather than hardcoding it in source files.
Laravel users can add it to .env and access it via env('SNAPAPI_KEY').
Laravel ships with Guzzle via the HTTP facade, making API calls concise and testable. The following pattern integrates SnapAPI into a Laravel service class with proper error handling.
use Illuminate\Support\Facades\Http;
class ScreenshotService
{
public function capture(string $url): string
{
$response = Http::withHeaders([
'X-Api-Key' => config('services.snapapi.key'),
])->post('https://api.snapapi.pics/v1/screenshot', [
'url' => $url,
'full_page' => true,
'format' => 'png',
'width' => 1280,
]);
$response->throw(); // throws on 4xx/5xx
return $response->json('screenshot_url');
}
}
Add SNAPAPI_KEY=sk_live_xxx to your .env file and reference it in
config/services.php under snapapi.key.
The ->throw() method converts HTTP errors into Laravel exceptions that your
existing exception handler will log and report automatically.
For retry logic, chain ->retry(3, 2000) before the ->post() call.
Laravel's HTTP client will automatically retry on connection errors and 429 Too Many Requests responses,
with a 2-second delay between attempts.
SnapAPI supports over 30 parameters for fine-grained control over how each screenshot is taken. The most commonly used options from PHP integrations include viewport sizing, delay, ad blocking, cookie consent dismissal, and custom CSS injection.
Set block_ads: true to strip advertising elements before capture.
Set hide_cookie_banners: true to automatically dismiss GDPR consent dialogs —
essential for clean screenshots of European websites.
The delay parameter (in milliseconds) waits for JavaScript animations to settle before capturing,
which prevents blank loading states in screenshots of React or Vue applications.
The device parameter accepts over 30 device presets including iPhone 15, Galaxy S23,
and iPad Pro. Combine with full_page: true to capture the complete scrollable page
at any mobile viewport.
Symfony developers can use the symfony/http-client component for type-safe HTTP calls with built-in retry support. Create a SnapApiClient service, inject the HttpClientInterface, and configure the base URI and API key in services.yaml. Symfony's autowiring will inject the configured client wherever you use the type hint.
WordPress plugins can call SnapAPI using the built-in wp_remote_post function, which wraps PHP's HTTP transport layer. Pass your API key in the headers array of the $args parameter and set a timeout of at least 30 seconds since rendering complex pages can take several seconds under heavy load.
For applications that generate screenshots on demand in response to user actions — creating a new page, publishing a post, updating a product — blocking the web request on the API call adds latency. Queue the screenshot job using Laravel Queues, Symfony Messenger, or a plain Redis list, and process it in a background worker. The worker calls SnapAPI, receives the screenshot URL, and updates the database record asynchronously. The user interface polls or uses a WebSocket to display the image when it's ready.
Alternatively, pass a webhook_url parameter to SnapAPI and let the API push the result to your endpoint rather than waiting for a response. This is the most efficient pattern for serverless PHP environments like AWS Lambda where function execution time is billed and long-polling is expensive.
The same HTTP client used for screenshots works with every SnapAPI endpoint. Switching to PDF generation requires only changing the endpoint path to /v1/pdf and adjusting parameters like page_format (A4, Letter), margin, and print_background. The response returns a PDF binary as base64 or a hosted URL you can stream directly to the browser with a Content-Disposition: attachment header.
Batch screenshot generation in PHP is best handled with curl_multi_exec, which sends multiple HTTP requests in parallel without blocking the main thread for each one. Initialize one cURL handle per URL, add them to a multi handle, execute, and collect responses. This approach saturates your outbound bandwidth rather than waiting serially, making a batch of 20 screenshots nearly as fast as a single one when network and browser rendering overlap.
SnapAPI's free tier includes 200 captures per month with no credit card required. The Starter plan at $19/month provides 5,000 captures — enough for most small-to-medium PHP applications. Pro ($79/month) and Business ($299/month) plans support 50,000 and 500,000 captures respectively. Sign up at snapapi.pics, retrieve your API key from the dashboard, and your first PHP screenshot call takes under five minutes from registration to response.
Running Puppeteer or Playwright on a PHP server requires Node.js as a side process, inter-process communication, memory management for browser instances, and crash recovery. PHP web servers like FPM are optimized for short-lived request handlers — long-running browser processes are fundamentally at odds with the FPM process model and require a separate worker tier.
SnapAPI eliminates this architectural friction. Your PHP application stays stateless — it calls an HTTP endpoint and receives data, the same pattern as any third-party API. Browser infrastructure, Chromium updates, memory limits, and anti-bot countermeasures are managed externally. Your team ships features instead of maintaining browser processes.
Stealth mode — which suppresses browser automation signals to bypass bot detection — is included on all plans. Proxy routing through residential IPs for geographic flexibility is available on Pro and Business plans. Both features are enabled with a single parameter and require no additional PHP code or infrastructure changes.
Screenshots of static pages rarely change between captures. Implement a cache layer using Redis or Memcached keyed on the URL and capture parameters. Before calling SnapAPI, check the cache — if a screenshot was captured within your freshness window (typically 1–24 hours), return the cached URL directly. This dramatically reduces API usage and improves response times for repeated requests.
Error handling should account for three categories: network errors where the API is unreachable, 4xx client errors indicating invalid parameters or exhausted quotas, and 5xx server errors that may resolve on retry. Wrap your HTTP call in a try-catch block and implement exponential backoff for 5xx and 429 responses. Log the response body on errors — SnapAPI returns structured JSON error messages with specific codes that identify whether the issue is a malformed URL, a timeout, or a rendering failure.
Beyond HTTP integrations, SnapAPI offers an MCP (Model Context Protocol) server — snapapi-mcp on npm — that connects directly to Claude Code, Claude Desktop, Cursor, VS Code, and other AI-powered development tools. Install with npx snapapi-mcp, set your API key as an environment variable, and your AI assistant gains nine tools including screenshot capture, web scraping, content extraction, and AI page analysis.
This makes SnapAPI accessible from natural language prompts: ask your AI assistant to "take a screenshot of example.com" and it executes the API call through the MCP server automatically. For PHP developers who also use AI coding assistants, the MCP server bridges the gap between your editor workflow and your production PHP integration.
Never expose your SnapAPI key in client-side code. PHP applications should call the API exclusively from server-side code — controllers, artisan commands, or queue workers — and serve the resulting screenshot URLs to the frontend. If users supply URLs for screenshot capture, validate them against an allowlist of domains or at minimum block private IP ranges and localhost to prevent server-side request forgery through your application.
Rate limit your own screenshot endpoint at the application layer so that a single user cannot exhaust your monthly quota. Laravel's built-in throttle middleware makes this straightforward — apply it to any route that triggers a SnapAPI call.