Docs

.NET SDK

The official .NET SDK for the Screenshot Scout screenshot API. It is distributed on NuGet as ScreenshotScout and developed in the screenshotscout-dotnet repository.

Installation

Install the package from NuGet:

dotnet add package ScreenshotScout

The SDK requires .NET 8 or later.

Get your API credentials

Sign up for Screenshot Scout or sign in. We automatically create a default API key for you when you sign up. Open the API Keys page, copy the access key and secret key, and store them in a safe place.

Capture a screenshot

Create a client with your access key and call CaptureAsync with the URL of the page you would like to take a screenshot of:

using ScreenshotScout;

using var client = new ScreenshotScoutClient("YOUR_ACCESS_KEY");

var response = await client.CaptureAsync(
    "https://example.com",
    new CaptureOptions { FullPage = true });

if (response is not BinaryCaptureResponse binary)
{
    throw new InvalidOperationException("Expected a binary response.");
}

await File.WriteAllBytesAsync("screenshot.png", binary.Bytes);
Console.WriteLine(binary.ScreenshotUrl);

CaptureAsync sends a POST request by default. The ResponseType option on CaptureOptions selects the response format. When you leave it unset, or set it to CaptureResponseType.Binary, the call returns a BinaryCaptureResponse: the image data is in Bytes, and the exact screenshot URL is in ScreenshotUrl when available.

Request a JSON result

Set ResponseType to CaptureResponseType.Json to receive a JSON object with the screenshot URL instead of the image bytes:

using ScreenshotScout;

using var client = new ScreenshotScoutClient("YOUR_ACCESS_KEY");

var response = await client.CaptureAsync(
    "https://example.com",
    new CaptureOptions
    {
        ResponseType = CaptureResponseType.Json,
    });

if (response is JsonCaptureResponse json)
{
    Console.WriteLine(json.Result.ScreenshotUrl);
}

The parsed JSON body is in Result.

Set capture options

CaptureOptions supports every option in the screenshot option reference through PascalCase properties: full_page becomes FullPage, block_cookie_banners becomes BlockCookieBanners, and so on. Options with a fixed set of documented values have constants, such as CaptureFormat.Webp and CaptureResponseType.Json. For a value the constants do not cover yet, construct one explicitly, for example new CaptureFormat("future-format").

Build a capture URL

BuildCaptureUrl creates a capture URL without making an API request, for cases where another application or an HTML <img> element loads the screenshot directly:

using ScreenshotScout;

using var client = new ScreenshotScoutClient("YOUR_ACCESS_KEY");

var captureUrl = client.BuildCaptureUrl(
    "https://example.com",
    new CaptureOptions
    {
        FullPage = true,
        BlockAds = true,
    });

Console.WriteLine(captureUrl);

The generated URL contains the access key. When a secret key is configured (see Signed requests), the SDK signs the URL automatically; otherwise it is unsigned. Treat generated URLs as sensitive. Before exposing one to browsers or users, configure a secret key and enable Require signed requests on the API Keys page.

Signed requests

Pass the API key's secret key as the second constructor argument:

using ScreenshotScout;

using var client = new ScreenshotScoutClient(
    "YOUR_ACCESS_KEY",
    "YOUR_SECRET_KEY");

The secret is used locally and is never transmitted. The client signs capture requests and generated capture URLs automatically. See the signed requests guide for details.

Errors

When the API returns a non-2xx response, the SDK throws ScreenshotScoutApiException, with the machine-readable error code in ErrorCode and the descriptive message in ErrorMessage. The repository README documents the full exception hierarchy.

Full reference

This page covers installation and your first captures. For everything else, see: