C# SDK
The official stat-api client for C#. A typed, zero-dependency wrapper over the REST API — construct StatApiClient, call the league/table accessors, and every response is a typed row. Version v0.1.0.
Install
git clone https://github.com/stat-api/stat-apiA published package is coming; for now install from source.
Quickstart
The smallest end-to-end program: construct a client, list a few rows, and print them.
// Hello, NBA
// Generated from schema/api/examples/hello-stat-api.yml — do not edit.
using StatApi;
using System.Text.Json;
var client = new StatApiClient(); // reads STAT_API_KEY from the environment
// List a few teams
var teams = (await client.Nba.Teams.ListAsync(new NbaTeamsListParams { Limit = 3 })).Rows;
// Print what came back
Console.WriteLine(JsonSerializer.Serialize(teams, new JsonSerializerOptions { WriteIndented = true }));Authentication
The client reads your API key from the STAT_API_KEY environment variable — the zero-argument constructor above needs nothing else. To pass it explicitly, hand the key to the StatApiClient constructor. The base URL defaults to https://api.stat-api.com. Get a key on the pricing page — the free tier covers 50,000 records a month.
Pagination & iteration
Every list call returns one bounded page (default 50 rows, max 200) wrapped in the list envelope, plus a next_from_id keyset cursor. Pass it back as from_id to fetch the next page, or let the built-in auto-paging iterator, IterateAsync(), stream every row across pages for you — available on every table.
Errors
Failed requests raise a typed error rather than returning a status code: AuthenticationError (401), PlanRequiredError (402), QuotaExceededError (429), NotFoundError (404), and ValidationError (400, e.g. a missing required filter) — all subclasses of StatApiError. GET requests are retried automatically on transient network errors and 5xx responses; quota exhaustion (429) is never retried.
Quota
Every response reports your monthly usage through X-Quota-* headers, surfaced on each page (and on QuotaExceededError) as a Quota value with limit, used, and remaining record counts — the same metering as the REST API.
More
Every endpoint in the API reference carries a copy-pasteable C# call, and the examples walk through longer recipes.