GhostCrawlApi 2.3.5

dotnet add package GhostCrawlApi --version 2.3.5
                    
NuGet\Install-Package GhostCrawlApi -Version 2.3.5
                    
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="GhostCrawlApi" Version="2.3.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GhostCrawlApi" Version="2.3.5" />
                    
Directory.Packages.props
<PackageReference Include="GhostCrawlApi" />
                    
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 GhostCrawlApi --version 2.3.5
                    
#r "nuget: GhostCrawlApi, 2.3.5"
                    
#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 GhostCrawlApi@2.3.5
                    
#: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=GhostCrawlApi&version=2.3.5
                    
Install as a Cake Addin
#tool nuget:?package=GhostCrawlApi&version=2.3.5
                    
Install as a Cake Tool

ghostcrawl — C# SDK

The official C# client for the GhostCrawl API. Collect web data at scale — scrape, crawl, search, and extract structured data.

Install

Minimum runtime: .NET 8.

dotnet add package GhostCrawlApi --version 2.3.0

Or add to your .csproj:

<PackageReference Include="GhostCrawlApi" Version="2.3.0" />

Quickstart

using GhostCrawlSdk;

// Token from constructor or GHOSTCRAWL_API_KEY environment variable
var client = new GhostCrawlClient("gck_live_YOUR_KEY");

// Scrape a URL
var result = await client.ScrapeAsync("https://example.com");
Console.WriteLine(result["content"]);

// Start a crawl run and WAIT for it to finish — event-driven, no poll loop.
// The wait is server-blocking (the API long-polls on the run's completion
// event); it returns when the run is terminal or waitTimeout elapses.
var run = await client.CrawlRuns.StartAsync(
    "https://example.com",
    wait: true,
    waitTimeout: TimeSpan.FromMinutes(5));
Console.WriteLine($"Status: {run["status"]}");  // completed | failed | cancelled

// Already have a run_id? Wait on it directly (honours CancellationToken):
var final = await client.CrawlRuns.WaitForCompletionAsync((string)run["run_id"]!);

// Prefer fire-and-forget? Start without wait and register a webhook instead:
//   var started = await client.CrawlRuns.StartAsync("https://example.com");
//   await client.Webhooks.CreateAsync("https://you.example.com/hook",
//       new[] { "crawl.completed" });

// Search
var search = await client.SearchAsync("latest C# releases");
Console.WriteLine(search["results"]);

Authentication

Pass your API key directly to the constructor:

var client = new GhostCrawlClient("gck_live_YOUR_KEY");

Or set the GHOSTCRAWL_API_KEY environment variable and use the no-arg constructor:

var client = new GhostCrawlClient();

All requests are authenticated with Authorization: Bearer <token>. No other auth scheme is supported.

For self-hosted deployments, override the base URL:

var client = new GhostCrawlClient("gck_live_YOUR_KEY", "https://your-instance.example.com");

Or set GHOSTCRAWL_BASE_URL.

Timeouts

Scrape and crawl jobs run through the rendering fleet and can take longer than the framework's default 100s. The client defaults to a 180s per-request timeout; override it (or disable it) via the constructor:

using System;

// Custom 5-minute timeout for heavy crawls
var client = new GhostCrawlClient("gck_live_YOUR_KEY", timeout: TimeSpan.FromMinutes(5));

// Disable the timeout entirely
var noTimeout = new GhostCrawlClient("gck_live_YOUR_KEY", timeout: System.Threading.Timeout.InfiniteTimeSpan);

Extract structured data

var schema = new Dictionary<string, object?>
{
    ["type"] = "object",
    ["properties"] = new Dictionary<string, object?>
    {
        ["title"]       = new Dictionary<string, object?> { ["type"] = "string" },
        ["price"]       = new Dictionary<string, object?> { ["type"] = "number" },
        ["description"] = new Dictionary<string, object?> { ["type"] = "string" },
    }
};

var result = await client.ExtractAsync("https://example.com/product/123", schema);
Console.WriteLine(result["data"]);

Browser utilities — content, screenshot, PDF

// Rendered content as a JSON envelope: {url, status, format, status_code, content, bytes}
var page = await client.ContentAsync("https://example.com");
Console.WriteLine($"{page["status_code"]} — {page["bytes"]} bytes");

// Screenshot — returns raw PNG bytes
byte[] png = await client.ScreenshotAsync("https://example.com", fullPage: true);
await File.WriteAllBytesAsync("page.png", png);

// PDF — returns raw application/pdf bytes (Chrome-only; a Firefox/WebKit identity
// is rejected with a 400 pdf_engine_unsupported)
byte[] pdf = await client.PdfAsync("https://example.com", paperFormat: "a4");
await File.WriteAllBytesAsync("page.pdf", pdf);

Agent (BYO model, account-gated)

The agent lane runs a natural-language browser task. It is bring-your-own-model — supply your own providerConfig — and account-gated: the API returns 404 not_found unless the capability is enabled for your account. AgentAsync does not throw on that 404 — it returns the problem+json body as a dictionary, so branch on result.ContainsKey("detail").

// provider_config is BYO — reference your provider key by env-var name, never a literal.
var providerConfig = new Dictionary<string, object?>
{
    ["provider"] = "openai",
    ["api_key"]  = "OPENAI_API_KEY",
    ["model"]    = "gpt-4o",
};

var result = await client.AgentAsync(
    "https://books.toscrape.com",
    "click the 'Books to Scrape' link",
    providerConfig);

if (result.ContainsKey("detail"))
    Console.WriteLine("agent lane not enabled for this account (BYO/gated)");
else
    Console.WriteLine(result);

Error handling

using GhostCrawlSdk;

try
{
    var result = await client.ScrapeAsync("https://example.com");
}
catch (AuthenticationException e)
{
    Console.Error.WriteLine($"Check your API key: {e.Message}");
}
catch (RateLimitException e)
{
    Console.Error.WriteLine($"Rate limit — back off and retry: {e.Message}");
}
catch (PaymentRequiredException e)
{
    Console.Error.WriteLine($"Spend limit reached: {e.Message}");
}
catch (InvalidRequestException e)
{
    Console.Error.WriteLine($"Bad request: {e.Message}");
}
catch (ApiException e)
{
    Console.Error.WriteLine($"Server error {e.StatusCode}: {e.Message}");
}
catch (GhostCrawlException e)
{
    Console.Error.WriteLine($"API error: {e.Message}");
}

All resources

Method / property Endpoint Key methods
client.ScrapeAsync(url) POST /v1/scrape Scrape a URL
client.SearchAsync(query) POST /v1/search Web search
client.ExtractAsync(url, schema) POST /v1/extract Extract structured data
client.CrawlAsync(url) POST /v1/crawl/deep Deep crawl
client.MapAsync(url) POST /v1/map Map reachable URLs
client.ContentAsync(url) POST /v1/content Rendered content JSON envelope
client.ScreenshotAsync(url) POST /v1/screenshot Capture a URL to PNG bytes
client.PdfAsync(url) POST /v1/pdf Render a URL to PDF bytes (Chrome-only)
client.AgentAsync(url, instruction) POST /v1/agent NL browser task — account-gated, BYO model
client.CrawlRuns /v1/crawl-runs StartAsync, ListAsync, GetAsync, CancelAsync
client.Sessions /v1/sessions CreateAsync, ListAsync, ExtendAsync, ReleaseAsync
client.Profiles /v1/profiles ListAsync, GetAsync, CreateAsync, UpdateAsync, DeleteAsync
client.Webhooks /v1/webhooks ListAsync, GetAsync, CreateAsync, DeleteAsync, RotateSecretAsync
client.Schedules /v1/schedules ListAsync, GetAsync, CreateAsync, DeleteAsync
client.Datasets /v1/datasets ListAsync, GetAsync, CreateAsync, DeleteAsync, RowsAsync, AppendAsync
client.Recordings /v1/recordings ListAsync, GetAsync, DeleteAsync
client.Kv /v1/kv GetAsync, SetAsync, DeleteAsync

Architecture

The facade delegates all HTTP transport, URL routing, serialization, and authentication to the Kiota-generated canonical core (_generated/). The facade is the shipped API surface; the Kiota core regenerates automatically when the spec changes.

License

Proprietary — GhostCrawl Software License. See LICENSE.

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.

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
2.3.5 107 7/27/2026
2.3.4 107 7/23/2026