pageflock, meet C# / .NET.
Call pageflock from a .NET console application or backend. Use the built-in HTTP and JSON libraries; no pageflock SDK is needed.
Your first connection.
- 01
Create a console application with a supported .NET SDK: dotnet new console -n WaggleDemo. The example supports .NET 8 and newer.
- 02
Store WAGGLE_API_KEY in the server environment. Replace WaggleDemo/Program.cs with the C# example below.
- 03
Run dotnet run --project WaggleDemo. In a long-running service, reuse HttpClient or use IHttpClientFactory instead of creating a client for every call.
Tool reference: C# / .NET documentation ↗
Build the request.
Set the environment variables in your terminal for these code examples. In automation tools, enter the URL and credentials in the tool’s own fields.
// .NET 8+ console app; API key is read on the server.
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
var apiKey = Environment.GetEnvironmentVariable("WAGGLE_API_KEY")
?? throw new InvalidOperationException("Set WAGGLE_API_KEY");
using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(45) };
using var request = new HttpRequestMessage(new HttpMethod("POST"), "https://pageflock.hyvelabs.tech/api/pageflock/v1/scrape");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent("{\n \"url\": \"https://example.com\"\n}", Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode) throw new HttpRequestException($"pageflock HTTP {(int)response.StatusCode}: {body}");
using var result = JsonDocument.Parse(body);
Console.WriteLine(result.RootElement);This edits a code example. It does not send a request or use credits.
Run a request in your workspace