Skip to content

C#

Anyrow for .NET: every endpoint, typed, async, with no dependencies beyond the BCL.

The Anyrow package has a typed method, request and response for every endpoint, built on HttpClient and System.Text.Json with no other dependencies. It targets .NET 8 and later.

Install

dotnet add package Anyrow

Create a client

using Anyrow;var anyrow = new AnyrowClient(new ClientConfig{    BaseUrl = "https://api.anyrow.ai",    ApiKey = Environment.GetEnvironmentVariable("ANYROW_API_KEY"),    Timeout = TimeSpan.FromSeconds(30),});

The client sends the key as Authorization: ApiKey <key>. Create one client and reuse it.

Make a call

An operation's id is its method in Pascal case with Async, through one property per group (extract.table.once is anyrow.Extract.Table.OnceAsync(...)). Path parameters come first, then the body, then an options object named after the method, which holds the query parameters:

var page = await anyrow.Row.ListAsync("proj_...", "tbl_...", new RowListOptions { Limit = 50 });Console.WriteLine($"{page.Rows.Count} rows, more: {page.HasMore}");

Request bodies are records named after the operation's body (CreateProjectsTableRequest for table.create). Every method also takes a CancellationToken.

Errors

A failed call throws an AnyrowApiException with the status and the error body; each status has its own subclass:

try{    var table = await anyrow.Table.GetAsync("proj_...", "tbl_...");}catch (ForbiddenException){    Console.WriteLine("The key lacks tables:read");}catch (AnyrowApiException error){    Console.WriteLine($"{error.Status}: {error.Message}");}

Read every row

var rows = new List<Dictionary<string, JsonElement>>();var options = new RowListOptions { Limit = 100 };while (true){    var page = await anyrow.Row.ListAsync("proj_...", "tbl_...", options);    rows.AddRange(page.Rows);    if (page.NextCursor is null) break;    options = options with { Cursor = page.NextCursor };}

Extract a document

var batch = await anyrow.Extract.Table.OnceAsync("proj_...", "tbl_...", new Dictionary<string, string>{    ["text"] = await File.ReadAllTextAsync("./invoice.txt"),});Console.WriteLine(batch.Status);

Stream an extraction

The Stream methods return an IAsyncEnumerable of server-sent events:

var form = new Dictionary<string, string> { ["text"] = "Invoice 42 from Acme" };await foreach (var item in anyrow.Extract.Table.StreamAsync("proj_...", "tbl_...", form)){    Console.WriteLine($"{item.Event} {item.Data}");}

Verify webhooks

Deliveries follow Standard Webhooks; verify them with the StandardWebhooks (opens in a new tab) package as the Webhooks guide describes.