Urlbox.sdk.dotnet 1.0.2

dotnet add package Urlbox.sdk.dotnet --version 1.0.2                
NuGet\Install-Package Urlbox.sdk.dotnet -Version 1.0.2                
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="Urlbox.sdk.dotnet" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Urlbox.sdk.dotnet --version 1.0.2                
#r "nuget: Urlbox.sdk.dotnet, 1.0.2"                
#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.
// Install Urlbox.sdk.dotnet as a Cake Addin
#addin nuget:?package=Urlbox.sdk.dotnet&version=1.0.2

// Install Urlbox.sdk.dotnet as a Cake Tool
#tool nuget:?package=Urlbox.sdk.dotnet&version=1.0.2                

image

Urlbox .NET Library

The Urlbox .NET package provides easy access to the Urlbox website screenshot API from your application.

Just initialise the Urlbox class and generate a screenshot of a URL in no time.

Check out our blog for more insights on everything screenshots.

Documentation

See the Urlbox API Docs. It gives you an exhaustive list of all the options you could pass to our API, including what they do and example usage.

You can also upload to S3 for more control over your renders, or use proxies for geo-specific sites.

Requirements

To use this SDK, you need .NET Core 2.0 or later.

Installation

You can install the SDK via NuGet:

dotnet add package urlbox.sdk.dotnet

Usage

Pull in the Urlbox SDK with using Screenshots;, then create a new Urlbox instance and call any of the following methods:

Note - The 3 format related methods are not an exhaustive list of available formats. Please see the below example and documentation for a full list of available formats to pass into the main GenerateUrlboxUrl() method as an option. All of the below generate render links.

DownloadAsBase64(options) - Gets a render link, opens it, then downloads the screenshot file as a Base64 string.

DownloadToFile(options, filePath) - Gets a render link, opens it, then downloads and stores the screenshot to the given filePath.

GeneratePNGUrl(options) - Gets a render link for a screenshot in PNG format.

GenerateJPEGUrl(options) - Gets a render link for a screenshot in JPEG format.

GeneratePDFUrl(options) - Gets a render link for a screenshot in PDF format.

GenerateUrlboxUrl(options) - Gets a render link for a screenshot.

Example Usage:

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Screenshots;

namespace UrlboxTest
{
    class Program
    {
        static async Task Main(string[] args)
        {
            // We highly recommend storing your Urlbox API key and secret somewhere secure.
            string apiKey = Environment.GetEnvironmentVariable("URLBOX_API_KEY");
            string apiSecret = Environment.GetEnvironmentVariable("URLBOX_API_SECRET");

            // Create an instance of Urlbox
            Urlbox urlbox = new Urlbox(apiKey, apiSecret);

            // Define the options for the screenshot
            var options = new Dictionary<string, object>
            {
                { "url", "https://urlbox.com/screenshot-behind-login" },
            };

            // Example 1: Download screenshot as a Base64 string
            string base64Screenshot = await urlbox.DownloadAsBase64(options);
            Console.WriteLine("Screenshot as Base64: " + base64Screenshot);

            // Example 2: Download screenshot to a file
            string filePath = "screenshot.png";
            string result = await urlbox.DownloadToFile(options, filePath);
            Console.WriteLine($"Screenshot saved to {filePath}");

            // Optionally generate URL for the image without downloading
            string pngUrl = urlbox.GeneratePNGUrl(options);
            Console.WriteLine("Generated PNG URL: " + pngUrl);

            // Generate a PDF image without downloading
            string pdfUrl = urlbox.GeneratePDFUrl(options);
            Console.WriteLine("Generated PDF URL: " + pdfUrl);

            string jpegUrl = urlbox.GenerateJPEGUrl(options);
            Console.WriteLine("Generated JPEG URL: " + jpegUrl);

            // Define the options for the screenshot
            var optionsWithFormat = new Dictionary<string, object>
            {
                {"url", "https://urlbox.com/screenshot-behind-login"},
                { "format", "png" }, // One of png, jpeg, webp, avif, svg, pdf, html, mp4, webm or md
                { "full_page", true }, // Takes a full page screenshot
            };
            string url = urlbox.GenerateUrlboxUrl(optionsWithFormat);
            Console.WriteLine("Generated URL: " + url);
        }
    }
}

We also offer other methods of generating screenshots apart from render links, including POST requests via async calls, using webhooks or synchronously.

Feedback

Feel free to contact us if you spot a bug or have any suggestions at: support@urlbox.com or use our chat function on our website.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 is compatible.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETCoreApp 2.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.2 85 10/15/2024
1.0.1 67 10/15/2024
1.0.0 89 10/15/2024