WebScrapingAI 4.0.0
dotnet add package WebScrapingAI --version 4.0.0
NuGet\Install-Package WebScrapingAI -Version 4.0.0
<PackageReference Include="WebScrapingAI" Version="4.0.0" />
<PackageVersion Include="WebScrapingAI" Version="4.0.0" />
<PackageReference Include="WebScrapingAI" />
paket add WebScrapingAI --version 4.0.0
#r "nuget: WebScrapingAI, 4.0.0"
#:package WebScrapingAI@4.0.0
#addin nuget:?package=WebScrapingAI&version=4.0.0
#tool nuget:?package=WebScrapingAI&version=4.0.0
WebScraping.AI .NET Client
Official .NET client for the WebScraping.AI API. Async, zero runtime dependencies, multi-targets netstandard2.0 and net8.0.
Install
dotnet add package WebScrapingAI
Or in your .csproj:
<PackageReference Include="WebScrapingAI" Version="4.0.0" />
Quickstart
using WebScrapingAI;
using var client = new WebScrapingAIClient(new WebScrapingAIClientOptions
{
ApiKey = "YOUR_API_KEY",
});
// Or read from the WEBSCRAPING_AI_API_KEY environment variable:
using var client2 = new WebScrapingAIClient();
// Get the HTML of a page
string html = await client.HtmlAsync(new HtmlRequest
{
Url = "https://example.com",
Js = true,
});
// Ask a question about a page
string answer = await client.QuestionAsync(new QuestionRequest
{
Url = "https://example.com",
Question = "What is this page about?",
});
// Extract structured fields
FieldsResult result = await client.FieldsAsync(new FieldsRequest
{
Url = "https://example.com/product/123",
Fields = new Dictionary<string, string>
{
["title"] = "Main product title",
["price"] = "Current price",
},
});
Console.WriteLine(result.Result?["price"]);
API
All methods are async and accept an optional CancellationToken.
| Method | Endpoint | Returns |
|---|---|---|
HtmlAsync(HtmlRequest) |
GET /html |
string |
TextAsync(TextRequest) |
GET /text |
string |
SelectedAsync(SelectedRequest) |
GET /selected |
string |
SelectedMultipleAsync(SelectedMultipleRequest) |
GET /selected-multiple |
SelectedMultipleResult |
QuestionAsync(QuestionRequest) |
GET /ai/question |
string |
FieldsAsync(FieldsRequest) |
GET /ai/fields |
FieldsResult |
AccountAsync() |
GET /account |
AccountInfo |
Common request options
Every request type extends CommonRequest, which exposes shared options like Js, Country, Proxy, Timeout, WaitFor, Headers, Device, JsScript, etc. See the API reference for the full list.
Errors
The SDK throws unchecked exceptions:
| Exception | When |
|---|---|
BadRequestException |
HTTP 400 |
PaymentRequiredException |
HTTP 402 — out of credits |
AuthenticationException |
HTTP 403 — bad API key |
RateLimitException |
HTTP 429 |
ServerException |
HTTP 500 |
GatewayTimeoutException |
HTTP 504 |
ApiException (base) |
Any other non-2xx |
ApiTimeoutException |
Per-request timeout exceeded |
ApiConnectionException |
Transport/connection failure |
All of the above extend WebScrapingAIException (a RuntimeException). The transport-level pair (ApiTimeoutException, ApiConnectionException) do not extend ApiException, so catch (ApiException) reliably means "we got an HTTP response back".
try
{
var html = await client.HtmlAsync(new HtmlRequest { Url = "..." });
}
catch (RateLimitException ex)
{
// back off
}
catch (ApiException ex)
{
// any other non-2xx; ex.Status has the HTTP code
}
catch (WebScrapingAIException ex)
{
// transport failure (timeout or connection)
}
Response-shape notes
Two endpoints return shapes that differ slightly from the OpenAPI spec examples; the SDK preserves them verbatim so the wire layout stays observable:
FieldsAsyncreturnsFieldsResultwhose.Resultholds the extracted fields under the API'sresultkey.SelectedMultipleAsyncreturnsSelectedMultipleResultwhose.ResultsisIReadOnlyList<IReadOnlyList<string>>(the API wraps matches in an outer array).
Configuration
new WebScrapingAIClientOptions
{
ApiKey = "...", // or WEBSCRAPING_AI_API_KEY env var
BaseUrl = "https://api.webscraping.ai", // override for staging/test
Timeout = TimeSpan.FromSeconds(60), // per-request
UserAgent = "webscraping-ai-dotnet/4.0.0", // overridable
HttpHandler = null, // plug in a custom HttpMessageHandler
};
Targets
netstandard2.0— covers .NET Framework 4.6.1+, Mono, Xamarin, Unity, every modern .NET.net8.0— current LTS; enables nullable annotations and modern BCL features at the call site.
Smoke test
The samples/Smoke console app exercises all 7 endpoints against the live API. Costs ~17 credits per run.
WEBSCRAPING_AI_API_KEY=... dotnet run --project samples/Smoke
Contributing
dotnet build
dotnet test
dotnet format
The repo pins .NET 10 via mise.toml; if you use mise, cd into the repo and run mise install to pick it up.
License
MIT — see LICENSE.
| Product | Versions 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Text.Json (>= 8.0.5)
-
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 |
|---|---|---|
| 4.0.0 | 97 | 5/17/2026 |