Pxshot 1.0.0

dotnet add package Pxshot --version 1.0.0
                    
NuGet\Install-Package Pxshot -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pxshot" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pxshot" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Pxshot" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pxshot --version 1.0.0
                    
#r "nuget: Pxshot, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pxshot@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pxshot&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Pxshot&version=1.0.0
                    
Install as a Cake Tool

Pxshot .NET SDK

The official .NET SDK for the Pxshot screenshot API.

NuGet License

Installation

dotnet add package Pxshot

Quick Start

using Pxshot;
using Pxshot.Models;

var client = new PxshotClient("px_your_api_key");

// Capture a screenshot as bytes
byte[] imageBytes = await client.ScreenshotAsync(new ScreenshotRequest
{
    Url = "https://example.com"
});

// Save to file
await File.WriteAllBytesAsync("screenshot.png", imageBytes);

Features

  • ✅ .NET 6, 7, and 8 support
  • ✅ Async-first API
  • ✅ Strongly-typed request/response models
  • ✅ Rate limit header parsing
  • ✅ Comprehensive exception handling
  • ✅ Zero external dependencies (uses System.Text.Json)

Usage Examples

Basic Screenshot

var client = new PxshotClient("px_your_api_key");

byte[] image = await client.ScreenshotAsync(new ScreenshotRequest
{
    Url = "https://example.com"
});

Full Page Screenshot with Options

byte[] image = await client.ScreenshotAsync(new ScreenshotRequest
{
    Url = "https://example.com",
    Format = "png",
    Width = 1920,
    Height = 1080,
    FullPage = true,
    DeviceScaleFactor = 2,
    WaitUntil = "networkidle",
    BlockAds = true
});

Store Screenshot and Get URL

var result = await client.ScreenshotWithStorageAsync(new ScreenshotRequest
{
    Url = "https://example.com"
});

Console.WriteLine($"Screenshot URL: {result.Url}");
Console.WriteLine($"Expires at: {result.ExpiresAt}");
Console.WriteLine($"Size: {result.SizeBytes} bytes");

Wait for Specific Element

byte[] image = await client.ScreenshotAsync(new ScreenshotRequest
{
    Url = "https://example.com",
    WaitForSelector = ".main-content",
    WaitForTimeout = 2000 // Additional 2 second wait
});

Check Usage Statistics

var usage = await client.GetUsageAsync();

Console.WriteLine($"Screenshots taken: {usage.ScreenshotsTaken}");
Console.WriteLine($"Screenshots remaining: {usage.ScreenshotsRemaining}");
Console.WriteLine($"Period ends: {usage.PeriodEnd}");

Monitor Rate Limits

var client = new PxshotClient("px_your_api_key");

await client.ScreenshotAsync(new ScreenshotRequest { Url = "https://example.com" });

if (client.LastRateLimitInfo is { } rateLimit)
{
    Console.WriteLine($"Rate limit: {rateLimit.Remaining}/{rateLimit.Limit}");
    Console.WriteLine($"Resets at: {rateLimit.Reset}");
}

Using Custom HttpClient

// Useful for dependency injection or custom configurations
var httpClient = new HttpClient();
httpClient.Timeout = TimeSpan.FromMinutes(2);

var client = new PxshotClient("px_your_api_key", null, httpClient);

Custom Base URL

// For self-hosted or staging environments
var client = new PxshotClient("px_your_api_key", "https://staging-api.pxshot.com");

Exception Handling

using Pxshot.Exceptions;

try
{
    var image = await client.ScreenshotAsync(new ScreenshotRequest
    {
        Url = "https://example.com"
    });
}
catch (RateLimitException ex)
{
    Console.WriteLine($"Rate limited. Retry after: {ex.RetryAfter}");
    if (ex.RateLimitInfo is { } info)
    {
        Console.WriteLine($"Limit: {info.Limit}, Remaining: {info.Remaining}");
    }
}
catch (AuthenticationException ex)
{
    Console.WriteLine($"Authentication failed: {ex.Message}");
}
catch (ValidationException ex)
{
    Console.WriteLine($"Invalid request: {ex.Message}");
}
catch (PxshotException ex)
{
    Console.WriteLine($"API error ({ex.StatusCode}): {ex.Message}");
}

Request Options

Option Type Description
Url string Required. The URL to capture.
Format string Image format: "png", "jpeg", "webp". Default: "png"
Quality int Image quality for JPEG/WebP (1-100). Default: 80
Width int Viewport width in pixels. Default: 1280
Height int Viewport height in pixels. Default: 720
FullPage bool Capture full scrollable page. Default: false
WaitUntil string Wait condition: "load", "domcontentloaded", "networkidle"
WaitForSelector string CSS selector to wait for before capturing
WaitForTimeout int Additional wait time in milliseconds
DeviceScaleFactor double Device pixel ratio. Default: 1
Store bool Store screenshot and return URL. Default: false

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 122 2/1/2026