Demografix 0.1.0
dotnet add package Demografix --version 0.1.0
NuGet\Install-Package Demografix -Version 0.1.0
<PackageReference Include="Demografix" Version="0.1.0" />
<PackageVersion Include="Demografix" Version="0.1.0" />
<PackageReference Include="Demografix" />
paket add Demografix --version 0.1.0
#r "nuget: Demografix, 0.1.0"
#:package Demografix@0.1.0
#addin nuget:?package=Demografix&version=0.1.0
#tool nuget:?package=Demografix&version=0.1.0
Demografix for C#
Run demographic analysis over names — predicted gender, age, and nationality — from one client. The official C# package covers genderize.io, agify.io, and nationalize.io.
Install
dotnet add package Demografix
The package targets netstandard2.0, net8.0, and net10.0.
Quickstart
Construct a client, run a batch over a list of names, read the predictions in aggregate, and read the remaining quota.
using System.Linq;
using Demografix;
using var client = new DemografixClient(apiKey: "YOUR_API_KEY");
var names = new[] { "michael", "matthew", "jane" };
var ages = await client.AgifyBatchAsync(names);
// Aggregate the predictions across the list.
var distribution = ages.Results
.Where(r => r.Age.HasValue)
.GroupBy(r => r.Age!.Value / 10 * 10)
.ToDictionary(g => $"{g.Key}s", g => g.Count());
Console.WriteLine(ages.Quota.Remaining); // 24987
The constructor takes a required apiKey and an optional timeout (default ten seconds). The service hosts
and the User-Agent are fixed constants, not options.
An API key is required. Creating one is free and includes 2,500 requests per month. Generate a key in your dashboard at genderize.io, agify.io, or nationalize.io. One key works across all three services.
genderize
Predict gender across a list and summarize the split.
using var client = new DemografixClient("YOUR_API_KEY");
var one = await client.GenderizeAsync("peter");
// one.Gender -> "male", one.Probability -> 1.0
var batch = await client.GenderizeBatchAsync(new[] { "peter", "lois", "jane" });
var split = batch.Results
.GroupBy(r => r.Gender ?? "unknown")
.ToDictionary(g => g.Key, g => g.Count());
GenderizePrediction exposes Name, Gender ("male", "female", or null), Probability, Count, and
CountryId.
agify
Predict age across a list and build a distribution.
using var client = new DemografixClient("YOUR_API_KEY");
var one = await client.AgifyAsync("michael");
// one.Age -> 57
var batch = await client.AgifyBatchAsync(new[] { "michael", "matthew", "jane" });
var byDecade = batch.Results
.Where(r => r.Age.HasValue)
.GroupBy(r => r.Age!.Value / 10 * 10)
.ToDictionary(g => $"{g.Key}s", g => g.Count());
AgifyPrediction exposes Name, Age (int or null), Count, and CountryId.
nationalize
Predict nationality across a list and tally the mix.
using var client = new DemografixClient("YOUR_API_KEY");
var one = await client.NationalizeAsync("nguyen");
// one.Country[0].CountryId -> "VN"
var batch = await client.NationalizeBatchAsync(new[] { "nguyen", "smith", "garcia" });
var mix = batch.Results
.Where(r => r.Country.Count > 0)
.GroupBy(r => r.Country[0].CountryId)
.ToDictionary(g => g.Key, g => g.Count());
NationalizePrediction exposes Name, Country (up to five NationalizeCountry candidates in descending
probability), and Count. NationalizeCountry exposes CountryId and Probability.
country_id
GenderizeAsync, GenderizeBatchAsync, AgifyAsync, and AgifyBatchAsync accept an optional countryId
(ISO 3166-1 alpha-2) that scopes the prediction to one country. The server echoes it back uppercase on each
prediction. nationalize does not take this parameter. Pass it on a batch to scope a whole list and summarize
the result in aggregate.
var names = new[] { "kim", "andrea", "jan" };
var batch = await client.GenderizeBatchAsync(names, countryId: "us");
var split = batch.Results
.GroupBy(r => r.Gender ?? "unknown")
.ToDictionary(g => g.Key, g => g.Count());
// batch.Results[0].CountryId -> "US" on every row
Quota
Every result and every raised error carries a Quota with three fields read from the rate-limit response
headers. Read it off the returned value or the caught error; it is never cached on the client.
| Field | Meaning |
|---|---|
Limit |
names allowed in the current window |
Remaining |
names left in the current window |
Reset |
seconds until the window resets |
Errors
Non-2xx responses throw a typed exception. Transport failures throw TransportException. Every exception
extends DemografixException and carries Status, Message, and Quota (when the headers were present).
| Status | Exception |
|---|---|
| 401 | AuthException |
| 402 | SubscriptionException |
| 422 | ValidationException |
| 429 | RateLimitException |
| other non-2xx | DemografixException |
| network / timeout / non-JSON | TransportException |
A batch of more than ten names throws ValidationException before any HTTP call. A RateLimitException
always carries Quota, so Quota.Reset tells you how long to wait.
try
{
var batch = await client.GenderizeBatchAsync(names);
}
catch (RateLimitException ex)
{
await Task.Delay(TimeSpan.FromSeconds(ex.Quota!.Reset));
// retry
}
Methods
| Method | Returns | country_id |
|---|---|---|
GenderizeAsync(name, countryId?) |
GenderizeResult |
yes |
GenderizeBatchAsync(names, countryId?) |
Batch<GenderizePrediction> |
yes |
AgifyAsync(name, countryId?) |
AgifyResult |
yes |
AgifyBatchAsync(names, countryId?) |
Batch<AgifyPrediction> |
yes |
NationalizeAsync(name) |
NationalizeResult |
no |
NationalizeBatchAsync(names) |
Batch<NationalizePrediction> |
no |
A single result exposes the prediction fields plus a Quota. A batch result exposes Results (the per-name
predictions) plus one Quota for the response.
Reference
Full API reference: https://genderize.io/documentation/api. One API key works across all three services.
| 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 is compatible. 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)
-
net10.0
- No dependencies.
-
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 |
|---|---|---|
| 0.1.0 | 81 | 6/26/2026 |