Laravel Screenshot API

Capture screenshots of any URL from Laravel using the HTTP facade. Queue support, automatic retries, clean service architecture — no Puppeteer or headless browser setup required.

Start Free — 200 captures/month

Quick Start with Laravel HTTP Facade

Laravel ships with a powerful HTTP client built on Guzzle. Calling SnapAPI requires just a few lines — set the API key header, post the request, and parse the JSON response. The HTTP facade provides fluent methods for headers, retries, timeouts, and error handling.


use Illuminate\Support\Facades\Http;

$response = Http::withHeaders([
    'X-Api-Key' => config('services.snapapi.key'),
])->retry(3, 2000)->post('https://api.snapapi.pics/v1/screenshot', [
    'url'       => 'https://example.com',
    'full_page' => true,
    'format'    => 'png',
    'width'     => 1280,
]);

$screenshotUrl = $response->json('screenshot_url');

Add SNAPAPI_KEY=sk_live_xxx to your .env file and reference it in config/services.php. The retry(3, 2000) chain automatically retries failed requests three times with a 2-second delay — handling transient network errors and rate limits without custom code.

The response includes a screenshot_url field with a hosted image URL valid for 72 hours, plus metadata like page title, final URL after redirects, and render duration in milliseconds.

Screenshot Service Class Pattern

For production applications, encapsulate SnapAPI calls in a dedicated service class. This provides a single point of change for API configuration, enables mocking in tests, and keeps controllers thin.

Create app/Services/ScreenshotService.php with a capture(string $url, array $options = []): string method. Inject the service via constructor injection in your controllers — Laravel's autowiring resolves it automatically. The method calls SnapAPI, handles errors, and returns the screenshot URL.

For caching, check Redis or your cache store before calling the API. Key on the URL and options hash. If a cached screenshot exists within your freshness window, return it directly. This reduces API usage and improves response times for frequently captured pages.

Rate limiting your own endpoint with Laravel's throttle middleware prevents individual users from exhausting your monthly SnapAPI quota. Apply it to any route that triggers a screenshot capture.

Queue-Based Screenshot Generation

For user-facing features where screenshot generation should not block the HTTP response, dispatch a queued job. Create a CaptureScreenshotJob that calls your ScreenshotService and stores the result in the database. The user interface polls or uses broadcasting (WebSockets) to display the screenshot when ready.

Laravel Queues support Redis, SQS, database, and Beanstalkd as backends. For most applications, Redis via the predis or phpredis extension provides the lowest latency. The job class handles retries, backoff, and failure logging through Laravel's built-in queue infrastructure.

Batch processing multiple URLs uses Bus::batch() — Laravel's job batching feature. Queue one job per URL, track overall progress, and execute a callback when all screenshots complete. This is ideal for generating thumbnails for a collection of links or capturing multiple pages of a report.

PDF Generation and Web Scraping in Laravel

The same HTTP facade pattern works for every SnapAPI endpoint. Switch the URL to /v1/pdf for PDF generation, /v1/scrape for web scraping, or /v1/extract for structured data extraction. All endpoints use the same authentication header and return JSON responses — your service class can expose methods for each capability without duplicating HTTP client configuration.

PDF generation from Laravel is ideal for automated invoice, receipt, and report creation. Design your document as an HTML Blade template, render it at a local route, and call SnapAPI to convert it to PDF. The separation between template design and PDF generation means your frontend team edits HTML and CSS while your backend handles routing and API calls.

Web scraping with stealth mode bypasses anti-bot protection on Cloudflare, Imperva, and DataDome-protected pages. Extract product prices, monitor competitor pages, or aggregate content from external sources — all from Laravel queued jobs that process URLs in the background.

The AI analysis endpoint (/v1/analyze) sends page content to a large language model with your custom prompt. Use it for content classification, summarization, or structured data extraction from pages with inconsistent HTML. The BYOK mode routes the LLM call through your own API key for cost control.

Testing and Deployment

Mock SnapAPI responses in your Laravel feature tests using Http::fake(). Define a response fixture that returns a screenshot URL and register it for the SnapAPI domain. Your tests run without making real API calls, execute instantly, and verify that your application handles the response correctly.

For staging environments, use a dedicated SnapAPI key with a lower quota to prevent accidental overuse during testing. The free tier at 200 captures per month is sufficient for most staging workloads. Production uses a Starter ($19/month, 5,000), Pro ($79/month, 50,000), or Business ($299/month, 500,000) plan depending on volume.

Deploy with confidence knowing that SnapAPI handles browser infrastructure, Chromium updates, memory management, and crash recovery. Your Laravel application stays stateless — it makes HTTP requests and processes responses. No Puppeteer process management, no Docker containers with Chrome, no memory leak debugging.

The MCP server (snapapi-mcp on npm) connects SnapAPI to Claude Code and Cursor, enabling AI-assisted development of your Laravel screenshot integration. Ask your AI assistant to capture a test screenshot and it handles the API call through the MCP protocol.

Laravel Screenshot API vs Browsershot

Spatie's Browsershot package wraps Puppeteer to capture screenshots from Laravel. It works but requires Node.js installed alongside PHP, a Chromium binary on the server, and careful memory management — each Chromium instance consumes 100-300 MB of RAM. On shared hosting, serverless deployments, and container environments with limited resources, Browsershot is difficult to deploy and maintain.

SnapAPI replaces the Chromium dependency with an HTTP call. Your Laravel application needs only the HTTP client that ships with the framework — no Node.js, no Chromium binary, no additional system packages. The rendering quality is identical because both use Chromium, but the infrastructure burden shifts from your team to the API provider.

SnapAPI also provides scraping, content extraction, PDF generation, video recording, and AI analysis through the same API key — capabilities that would require multiple additional packages alongside Browsershot. Sign up at snapapi.pics for 200 free captures per month.

Device Emulation and Ad Blocking

Capture mobile screenshots from Laravel using the device parameter with over 30 presets including iPhone 15, Samsung Galaxy S23, iPad Pro, and Pixel 8. Each preset configures the correct viewport, pixel density, and user agent string. Combine with full_page: true to capture the complete mobile rendering of responsive pages.

Ad blocking with block_ads: true strips advertising elements before capture. Cookie banner dismissal with hide_cookie_banners: true removes GDPR consent overlays automatically. Both produce cleaner screenshots for archiving, thumbnails, and visual testing without requiring custom CSS injection.

Custom CSS injection overrides page styling before capture — hide navigation bars, adjust widths for print, or force specific color schemes. Custom JavaScript injection triggers interactions: click a button to expand a collapsed section, dismiss a popup, or switch tabs before the screenshot fires.

Stealth mode suppresses browser automation signals to capture pages protected by Cloudflare, Imperva, and DataDome. Enable it with stealth: true in the request body. Proxy routing through residential IPs is available on Pro and Business plans for geographic compliance and access to region-restricted content.

Pricing and Getting Started

SnapAPI's free tier includes 200 captures per month across all endpoints with no credit card required. This covers evaluation, development, and low-volume production use. Starter at $19/month provides 5,000 captures for growing applications. Pro at $79/month gives 50,000 for high-traffic services. Business at $299/month supports 500,000 captures for enterprise-scale deployments.

Sign up at snapapi.pics, add SNAPAPI_KEY to your Laravel .env, and your first screenshot takes three lines of code with the HTTP facade. Full documentation with Laravel-specific examples is available at snapapi.pics/docs.html.

Frequently Asked Questions

Do I need to install Puppeteer or Chromium? No. SnapAPI is a cloud API — your Laravel application makes HTTP requests using the built-in HTTP facade. No browser binary, no Node.js dependency, no additional system packages required on your server.

Does it work with Laravel Vapor and serverless? Yes. Since SnapAPI is an HTTP API, it works in any environment that can make outbound HTTPS requests, including Lambda-based deployments through Laravel Vapor, Docker containers, shared hosting, and traditional VPS setups.

Can I capture pages behind authentication? Yes. Pass session cookies or custom headers with the API request. The browser uses these credentials to access the protected page before taking the screenshot.

How do I handle rate limits? Laravel's retry() method on the HTTP facade automatically retries on 429 responses with configurable backoff. For queue-based workflows, Laravel's job retry mechanism handles transient failures without custom code.

Laravel screenshot API integration supports HTTP facade Guzzle queue jobs batch processing retry middleware and cache with Redis Memcached and database backends for production deployment.