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

To call a screenshot API from C#, send an HTTP request, check the response, and save its bytes. ScreenshotAPI.to’s documented C# approach uses .NET’s built-in HttpClient—no third-party package is required. This guide shows a .NET 6+ quick start, a reusable client, full-page and WebP captures, concurrent requests, and an ASP.NET integration, then explains how to choose between the API’s GET, POST, and batch request patterns.

Make your first screenshot request from C#

The documented ScreenshotAPI.to C# example targets .NET 6+ and sends the API key in the x-api-key header. It puts the page URL in the request query string, reads the response as bytes, and writes those bytes to a file. Store the key in an environment variable rather than committing it to source control.

using System.Web;

var apiKey = Environment.GetEnvironmentVariable("SCREENSHOTAPI_KEY")
             ?? throw new InvalidOperationException("Missing API key");
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("x-api-key", apiKey);
var query = HttpUtility.ParseQueryString(string.Empty);
query["url"] = "https://example.com";
using var response = await client.GetAsync(
    $"https://screenshotapi.to/api/v1/screenshot?{query}");
response.EnsureSuccessStatusCode();
var bytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("screenshot.png", bytes);

The vendor’s C# page says there is no official .NET SDK yet; the example uses HttpClient directly. See the ScreenshotAPI.to C# documentation for its documented implementation. The System.Web namespace provides HttpUtility; if it is unavailable to your project, use an available query-string encoder or construct the URL with a URI builder rather than concatenating an unescaped page URL.

Run it safely

  • Set SCREENSHOTAPI_KEY in the process environment before running the app. In production, use your deployment platform’s secret store.
  • Use a public, valid page URL for the first test. Query-string encoding matters: a target URL may itself contain &, ?, or other characters with meaning in the API request.
  • Check the HTTP status before treating the response body as an image. Error responses can contain text or JSON, not image data.
  • Match the output extension to the requested image format. The quick start writes PNG; do not name bytes .png if you requested WebP or JPEG.

Build a reusable C# capture client

A one-off call is fine for a test. In an application, reuse an HttpClient rather than creating one for every capture, keep the key outside code, and wrap request options and response metadata in types. The vendor’s documented options include URL, nullable width and height, full-page mode, format (default png), quality, color scheme, wait condition, selector wait, and delay. Its example wrapper reads content-type, x-credits-remaining, x-screenshot-id, and x-duration-ms from response headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Here is a compact adaptation of that design. It returns the raw bytes along with response metadata and includes the upstream status and error text when a request fails. Confirm the response mode enabled for your account before relying on bytes: the API reference also documents a JSON/redirect workflow.

using System.Net;
using System.Web;

public sealed record ScreenshotOptions(
    string Url,
    int? Width = null,
    int? Height = null,
    bool? FullPage = null,
    string? Format = null,
    int? Quality = null,
    string? ColorScheme = null,
    string? WaitUntil = null,
    string? WaitForSelector = null,
    int? Delay = null);

public sealed record ScreenshotResult(
    byte[] Content,
    string ContentType,
    string? CreditsRemaining,
    string? ScreenshotId,
    string? DurationMs);

public sealed class ScreenshotApiClient
{
    private readonly HttpClient _http;

    public ScreenshotApiClient(HttpClient http, string apiKey)
    {
        _http = http;
        _http.DefaultRequestHeaders.Remove("x-api-key");
        _http.DefaultRequestHeaders.Add("x-api-key", apiKey);
    }

    public async Task<ScreenshotResult> CaptureAsync(
        ScreenshotOptions options, CancellationToken cancellationToken = default)
    {
        var query = HttpUtility.ParseQueryString(string.Empty);
        query["url"] = options.Url;
        if (options.Width is not null) query["width"] = options.Width.ToString();
        if (options.Height is not null) query["height"] = options.Height.ToString();
        if (options.FullPage is not null) query["fullPage"] = options.FullPage.Value.ToString().ToLowerInvariant();
        if (options.Format is not null) query["format"] = options.Format;
        if (options.Quality is not null) query["quality"] = options.Quality.ToString();
        if (options.ColorScheme is not null) query["colorScheme"] = options.ColorScheme;
        if (options.WaitUntil is not null) query["waitUntil"] = options.WaitUntil;
        if (options.WaitForSelector is not null) query["waitForSelector"] = options.WaitForSelector;
        if (options.Delay is not null) query["delay"] = options.Delay.ToString();

        using var response = await _http.GetAsync(
            $"https://screenshotapi.to/api/v1/screenshot?{query}",
            HttpCompletionOption.ResponseHeadersRead, cancellationToken);
        if (!response.IsSuccessStatusCode)
        {
            var error = await response.Content.ReadAsStringAsync(cancellationToken);
            throw new HttpRequestException(
                $"Screenshot request failed ({(int)response.StatusCode} {response.StatusCode}): {error}",
                null, response.StatusCode);
        }

        var content = await response.Content.ReadAsByteArrayAsync(cancellationToken);
        return new ScreenshotResult(
            content,
            response.Content.Headers.ContentType?.MediaType ?? "application/octet-stream",
            Header(response, "x-credits-remaining"),
            Header(response, "x-screenshot-id"),
            Header(response, "x-duration-ms"));
    }

    private static string? Header(HttpResponseMessage response, string name) =>
        response.Headers.TryGetValues(name, out var values) ? values.FirstOrDefault() : null;
}

Register the client through .NET dependency injection in an ASP.NET application, or create one long-lived client for a small console program. Validate or constrain caller-supplied URLs if this client is exposed through a service: otherwise your application can be abused to request arbitrary sites. Log the upstream status and error message in structured form, but never log the API key.

Set capture size, format, and page readiness

Capture options help match the output to its use. Exact accepted parameter values and names should be checked against the vendor’s current API reference; the C# page documents the option concepts, while the REST reference describes additional rendering controls.

Full page and viewport dimensions

Set FullPage = true in the options object to capture beyond the initial viewport. Specify width and height when the output needs a predictable viewport, such as a dashboard thumbnail or a fixed-size visual test. Full-page output can be much taller and larger than a viewport capture, especially on pages with long feeds or large images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

WebP and JPEG output

To request WebP, set Format = "webp" and a quality value such as 85, then save the returned bytes with a .webp extension. JPEG is useful when transparency is not needed; PNG is often appropriate when preserving sharp edges matters. Treat quality as a format-specific setting and verify that the returned content type matches the requested format before serving or processing the file.

Wait for dynamic content

Use the documented wait-condition, selector-wait, and delay options when a page renders important content after its initial HTML arrives. A selector wait is more targeted than an arbitrary delay when the page exposes a reliable element. A fixed delay can help with known animations or deferred content but increases latency and does not guarantee that a page is ready. The API reference also lists network and selector-related rendering controls; choose the narrowest wait that makes the needed content appear.

Other documented rendering controls

The REST reference lists viewport size, full-page capture, device scale, wait strategy, selector capture, delay, ad and cookie blocking, dark mode, injected CSS and JavaScript, geolocation, timezone, locale, cache, and timeout controls. It also documents PDF options. For detailed configurations, POST JSON is usually more convenient than encoding every setting in a query string.

Capture several pages concurrently

For a small list of independent URLs, start one task per capture and await them together. Handle failures per URL so a single unavailable page does not hide the results for successful captures. Limit concurrency for large lists: issuing an unbounded number of requests can hit service rate limits and consume local memory while images are in flight.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
var urls = new[]
{
    "https://example.com",
    "https://example.org"
};

var tasks = urls.Select(async (url, index) =>
{
    try
    {
        var result = await screenshotClient.CaptureAsync(
            new ScreenshotOptions(url), cancellationToken);
        await File.WriteAllBytesAsync($"screenshot-{index}.png", result.Content,
            cancellationToken);
        return (Url: url, Error: (Exception?)null);
    }
    catch (Exception ex)
    {
        return (Url: url, Error: ex);
    }
});

var results = await Task.WhenAll(tasks);
foreach (var item in results)
{
    if (item.Error is not null)
        Console.Error.WriteLine($"Failed: {item.Url}: {item.Error.Message}");
}

This example assumes the client and cancellation token have already been configured. For larger workloads, use a bounded worker pool or the vendor’s batch endpoint rather than creating a task for every URL at once.

Use the API from ASP.NET

A minimal API can accept a URL, call the reusable client, and return the image with its content type. Validate input and translate upstream failures rather than exposing exceptions as successful image responses.

app.MapGet("/capture", async (string url, ScreenshotApiClient client,
    CancellationToken cancellationToken) =>
{
    if (!Uri.TryCreate(url, UriKind.Absolute, out var target) ||
        (target.Scheme != Uri.UriSchemeHttp && target.Scheme != Uri.UriSchemeHttps))
        return Results.BadRequest(new { error = "A valid HTTP or HTTPS URL is required." });

    try
    {
        var result = await client.CaptureAsync(
            new ScreenshotOptions(target.ToString()), cancellationToken);
        return Results.File(result.Content, result.ContentType);
    }
    catch (HttpRequestException ex)
    {
        return Results.Problem(statusCode: 502, title: "Screenshot provider request failed",
            detail: ex.Message);
    }
});

A controller can apply the same checks: return 400 for a missing or malformed URL, return the bytes with the response content type on success, and map provider errors to a gateway failure. The vendor’s controller example sets Cache-Control: public, max-age=3600; only use public caching when the target page and resulting screenshot are safe to share from a cache. Sensitive pages or user-specific captures should not be made publicly cacheable.

Choose GET, POST, or batch requests

Request type Best fit What the reference says
GET /api/v1/screenshot Simple requests and query-string options The REST reference documents GET and says it returns JSON by default; redirect=1 requests a 302 to an image or PDF.
POST /api/v1/screenshot Advanced configurations Accepts a JSON body and is suited to complex options.
POST /api/v1/screenshot/batch Multiple URLs handled as a batch The reference documents a batch endpoint and progress endpoints.

There is an important integration distinction: the C# example reads the successful response directly as image bytes, while the REST reference describes JSON by default and an optional redirect workflow for GET. Do not assume these modes are interchangeable. Check the response mode configured for your API account and endpoint, then implement the matching flow: read bytes, parse JSON, or follow the documented redirect. Avoid writing a JSON response body to a file with an image extension.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The reference lists advanced controls including custom CSS and JavaScript, selectors, geolocation, timezone, and PDF settings. Review the API reference for their exact parameter names and accepted values before adding them to a production request.

Plan for quotas, latency, and failures

The ScreenshotAPI.to API reference, accessed in 2026, shows the free plan at 60 requests per minute and 500 screenshots per month. It also says response headers expose remaining rate and quota values. These are plan figures from that reference, not a guarantee that an individual capture will finish within a particular time; verify current limits in the provider documentation and your account before sizing a workload.

  • Reuse connections: retain the injected or long-lived HttpClient to avoid connection churn.
  • Bound concurrency: a small worker limit makes throughput predictable and reduces bursts against request-rate limits.
  • Set an application timeout: rendering can take longer than a normal quick web request. Choose a timeout appropriate to your page and workload, and let cancellation reach the HTTP request.
  • Track metadata: retain screenshot IDs, duration, remaining-credit values, and upstream status codes where returned. They help diagnose failures and monitor consumption.
  • Retry selectively: do not blindly retry invalid input, invalid credentials, missing credits, or selectors that are not present. For transient rate limits or rendering failures, use a bounded retry policy with delay and respect any provider guidance.
  • Protect output: screenshots may contain personal or confidential information from the target page. Apply appropriate access controls and retention rules before storing or serving them.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot common C# errors

Symptom or status Likely cause What to do
Missing API key exception SCREENSHOTAPI_KEY is unset in the process environment. Set the environment variable in the runtime or secret store, then restart the process.
401 unauthorized Key is absent or not accepted. Confirm the key, account, and header name; do not put the key in a URL or source repository.
403 or 402 The C# guide’s catch example identifies 403 as an invalid key and 402 as out of credits. Check the key and account balance/plan. Preserve the status and provider error text in logs.
400 invalid_request A required value is missing or malformed. Validate the target URL and option values before sending; inspect the response body for the provider’s field-level message.
429 rate_limited or quota_exceeded Request-rate or plan quota limit reached. Reduce concurrency, delay retries, and inspect returned rate or quota headers and account limits.
422 selector_not_found The requested selector did not appear on the rendered page. Confirm the selector against the target page, allow for its load behavior, or remove the selector wait.
502 render_failed The provider could not render the target page. Check that the page is reachable and retry only with a bounded policy; preserve the provider message and screenshot ID if present.
File exists but is not an image The endpoint returned JSON or another response mode, but the body was saved as image bytes. Inspect the status and content type; use the configured direct-byte, JSON, or redirect flow.
HttpUtility is unavailable The project does not reference an assembly/package that supplies the namespace. Use a URI/query builder available in the target framework or add the appropriate reference; retain proper URL encoding.

The REST reference lists unauthorized (401), invalid_request (400), rate_limited (429), quota_exceeded (429), render_failed (502), and selector_not_found (422). Use both the HTTP status and response body in diagnostics; do not rely only on exception text.

Or skip the browser setup

If you want a screenshot endpoint without implementing and maintaining the rendering integration, ScreenshotNeo is a website screenshot API with a one-request workflow. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, and failed loads are never billed; an MCP server lets AI agents use screenshot tools; and the free plan includes 1,000 screenshots a month with no card, while paid plans start at $5 for 3,000. The API also returns PNG, JPEG, WebP, or PDF and provides options such as full-page capture, element selection, device presets, and async jobs. See the ScreenshotNeo API documentation for request parameters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

The same endpoint can be called from C# with HttpClient; adapt the request to the documented query parameter names:

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
using var client = new HttpClient();
var query = new Dictionary<string, string>
{
    ["access_key"] = Environment.GetEnvironmentVariable("SCREENSHOTNEO_API_KEY")
        ?? throw new InvalidOperationException("Missing API key"),
    ["url"] = "https://example.com"
};
using var response = await client.GetAsync(
    "https://api.screenshotneo.com/v1/shot?" +
    await new FormUrlEncodedContent(query).ReadAsStringAsync());
response.EnsureSuccessStatusCode();
var bytes = await response.Content.ReadAsByteArrayAsync();
await File.WriteAllBytesAsync("shot.webp", bytes);

For AI workflows, ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf. Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

Frequently Asked Questions

Does ScreenshotAPI.to have an official C# SDK?

Its C# documentation says there is no official .NET SDK; the documented approach uses HttpClient.

Which .NET version does the documented C# quick start target?

The ScreenshotAPI.to C# example targets .NET 6 or later.

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.

Why might a successful GET response be JSON instead of an image?

The REST reference says GET returns JSON by default, while the C# example reads bytes. Check your account’s configured response mode and use the matching bytes, JSON, or redirect handling.

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.