Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Laravel’s HTTP client to send a server-side GET request to Screenshotlayer’s capture endpoint, passing your access key and the target website URL as query parameters. Keep the key in server-side configuration, set a timeout, and handle both provider errors and network failures before returning a result to your application.

What you need before making a request

  • A Screenshotlayer account and access key. The key is a credential: keep it out of browser code, public repositories, and logs. Screenshotlayer’s terms say users are responsible for keeping credentials secret.
  • A Laravel application using the HTTP client documented for Laravel 13.x.
  • A complete target URL, including https:// or http://.

Screenshotlayer documents http://api.screenshotlayer.com/api/capture as its capture endpoint and requires an access_key and target url. Its specification is at the Screenshotlayer API specification. The example below uses HTTPS for the API connection; Screenshotlayer says HTTPS availability depends on paid-plan entitlements, so verify your plan before relying on encrypted API transport. Do not assume the free plan includes it.

Configure the key outside your code

Put the key in your deployment environment, then expose it to Laravel through a service configuration entry. For example, add this to config/services.php:

'screenshotlayer' => [
    'key' => env('SCREENSHOTLAYER_ACCESS_KEY'),
],

Set SCREENSHOTLAYER_ACCESS_KEY in the server environment or a protected local environment file, and never commit a real credential. After changing environment-backed configuration in a production deployment that uses Laravel’s config cache, rebuild the cache as part of deployment. Do not place the key in a Blade template or a JavaScript bundle: a browser-visible request would expose it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the capture request in Laravel

This controller example accepts a target URL, calls Screenshotlayer, and returns the provider’s successful response body. Validate the URL according to your application’s needs and restrict destinations if users can submit URLs; otherwise your server may be induced to request unintended hosts.

<?php

namespace AppHttpControllers;

use IlluminateHttpRequest;
use IlluminateSupportFacadesHttp;
use IlluminateSupportFacadesLog;
use IlluminateHttpJsonResponse;
use IlluminateHttpResponse;
use Throwable;

class ScreenshotController extends Controller
{
    public function capture(Request $request): Response|JsonResponse
    {
        $validated = $request->validate([
            'url' => ['required', 'url'],
        ]);

        $key = config('services.screenshotlayer.key');
        if (!$key) {
            return response()->json(['error' => 'Screenshot service is not configured.'], 503);
        }

        try {
            $providerResponse = Http::timeout(20)->get(
                'https://api.screenshotlayer.com/api/capture',
                [
                    'access_key' => $key,
                    'url' => $validated['url'],
                    'fullpage' => 1,
                    'format' => 'png',
                ]
            );
        } catch (Throwable $e) {
            Log::warning('Screenshotlayer request failed before a response was received.', [
                'exception' => $e::class,
            ]);

            return response()->json(['error' => 'Screenshot provider could not be reached.'], 502);
        }

        if ($providerResponse->failed()) {
            // Record status only. Do not log the request URL or access key.
            Log::warning('Screenshotlayer returned an unsuccessful HTTP response.', [
                'status' => $providerResponse->status(),
            ]);

            return response()->json(['error' => 'Screenshot provider returned an error.'], 502);
        }

        return response($providerResponse->body(), 200)
            ->header('Content-Type', 'image/png');
    }
}

Passing parameters as an array lets Laravel build and encode the GET query rather than requiring you to concatenate a query string yourself. The sample asks for a full-page PNG; check Screenshotlayer’s live API documentation and your plan for the exact output options you need. Treat a provider response as external input: do not expose raw error details to end users, and avoid logging full request URLs because query strings can contain the access key.

Handle provider and transport errors deliberately

Screenshotlayer documents missing or invalid keys, usage-limit exhaustion, and invalid target URLs. These are not transient failures, so blindly retrying them will not fix the cause. Laravel’s HTTP client also supports response inspection, timeouts, and retries; use retries only when repeating a request is appropriate.

  • Missing or invalid access key: check the server environment and Laravel configuration cache, then confirm the key in the provider account. Return a service-configuration error to your caller without revealing the key.
  • Invalid URL: require a fully qualified URL and validate it before sending. If your application accepts user-submitted destinations, apply an allowlist or other destination restrictions suited to the application.
  • Usage limit reached: inspect account usage and plan quota. Repeating the same request will not restore quota.
  • Timeout or connection failure: keep a finite timeout, return a gateway-style application error, and permit a carefully bounded retry only if the operation is safe to repeat and the error is plausibly temporary.
  • Unexpected response: check status and expected content type before returning bytes. Avoid returning an HTML provider error page with an image content type.

Test without calling the live service

Laravel’s HTTP client supports fakes and sent-request assertions, so routine tests can verify request construction without depending on Screenshotlayer availability or consuming account usage. A focused feature test can fake an image response and assert the outgoing endpoint and parameters:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
use IlluminateSupportFacadesHttp;

public function test_capture_sends_expected_parameters(): void
{
    config(['services.screenshotlayer.key' => 'test-key']);

    Http::fake([
        'api.screenshotlayer.com/*' => Http::response('fake-png-bytes', 200, [
            'Content-Type' => 'image/png',
        ]),
    ]);

    $response = $this->get('/capture?url=https%3A%2F%2Fexample.com');

    $response->assertOk();
    $response->assertHeader('Content-Type', 'image/png');

    Http::assertSent(function ($request) {
        return $request->url() === 'https://api.screenshotlayer.com/api/capture'
            && $request['access_key'] === 'test-key'
            && $request['url'] === 'https://example.com'
            && $request['fullpage'] == 1
            && $request['format'] === 'png';
    });
}

Add separate tests for an unsuccessful provider response and a transport timeout. Assert your application’s chosen error status and safe message, and ensure those cases do not leak the key. A fake response test checks your code’s behavior; it does not prove that a live key, plan entitlement, target site, or provider account quota is valid.

Check Screenshotlayer pricing and Indian billing details

Screenshotlayer’s pricing page lists these USD plan terms as accessed in 2026. Provider pricing and entitlements can change, so confirm the current page and account terms before choosing a plan.

Plan Listed monthly snapshots Listed price Commercial use
Free 100 Free Non-commercial
Basic 10,000 USD 19.99/month Paid plans include commercial use
Professional 30,000 USD 59.99/month Paid plans include commercial use
Enterprise 75,000 USD 149.99/month Paid plans include commercial use

The provider also lists plan-dependent options such as dedicated workers, HTTPS, and higher-tier export features, and says overage fees can apply after quota. Review the current pricing and plan page for which options apply to the plan you intend to use. Choose based on expected monthly volume, commercial-use permission, HTTPS needs, concurrency, export requirements, and exposure to overage—not price alone.

The listed prices are in USD. The available provider information does not establish India-specific INR pricing, taxes, GST treatment, or whether a particular Indian bank or card will be accepted. Screenshotlayer’s FAQ names Visa, MasterCard, Discover, and Diners Club as payment methods, but that does not confirm local acceptance or billing treatment for an Indian account. Check those details with the provider and your payment issuer before purchase.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If you want an API that returns the capture directly, ScreenshotNeo offers a one-request option. Its API removes cookie banners, popups, and chat widgets before capture; bot checks, blank pages, and failed loads are not billed. It also provides an MCP server for AI agents and includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Sign up for the free plan to get 1,000 screenshots a month with no card.

Frequently Asked Questions

Can I call Screenshotlayer directly from frontend JavaScript?

No. Make the request from your Laravel server so the access key stays private.

Does Screenshotlayer’s free plan allow commercial use?

The provider’s pricing page marks its free plan as non-commercial; verify the current terms before using it for commercial work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Does the listed Screenshotlayer pricing confirm INR billing or GST for India?

No. The listed prices are in USD, and the available provider information does not establish INR pricing, taxes, or GST treatment for Indian customers.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.