NameGender 0.1.0
See the version list below for details.
dotnet add package NameGender --version 0.1.0
NuGet\Install-Package NameGender -Version 0.1.0
<PackageReference Include="NameGender" Version="0.1.0" />
<PackageVersion Include="NameGender" Version="0.1.0" />
<PackageReference Include="NameGender" />
paket add NameGender --version 0.1.0
#r "nuget: NameGender, 0.1.0"
#:package NameGender@0.1.0
#addin nuget:?package=NameGender&version=0.1.0
#tool nuget:?package=NameGender&version=0.1.0
NameGender .NET
Official .NET client for the NameGender API: gender from a first name, full name, email address or username, with the probability, sample size and source behind every answer.
Targets .NET Standard 2.0 (so .NET Framework 4.6.2 and later) and .NET 8.
dotnet add package NameGender
using NameGender;
using var client = new NameGenderClient(Environment.GetEnvironmentVariable("NAMEGENDER_API_KEY")!);
var result = await client.NameAsync("Andrea", new LookupOptions { Country = "IT" });
Console.WriteLine($"{result.Gender} {result.Probability}% from {result.SampleSize} records ({result.Confidence})");
Gender is male, female or null. Null is an answer, not an error: keep it
nullable in your own model. Probability is 0–100, not a fraction.
A free account gives 100 lookups a day: https://namegender.com/register
Emails, usernames and full names
await client.EmailAsync("ayse.yilmaz@example.com");
await client.UsernameAsync("andrea_89", new LookupOptions { Country = "IT" });
var full = await client.NameAsync("Dr. Ayşe Nur Yılmaz");
// full.FirstName "Ayşe", full.MiddleName "Nur", full.LastName "Yılmaz", full.NameType "personal"
Bulk
Up to 100 values per request, answered in the order sent, one credit each.
var batch = await client.BulkAsync(new[] { "Ayşe", "Mehmet", "Priya", "Wei" }, new LookupOptions { Country = "TR" });
foreach (var row in batch.Results)
{
Console.WriteLine($"{row.Query} {row.Gender ?? "?"} {row.Probability}");
}
Console.WriteLine(batch.Summary.MatchRate);
Pass type: InputType.Email or InputType.Username for a list of emails or
usernames. For files of hundreds of thousands of rows, the CSV/XLSX upload in the
dashboard is faster than looping over this method.
Options
| Option | Sent as | Effect |
|---|---|---|
Country |
country |
ISO 3166-1 alpha-2 hint. Andrea is male in Italy and female in Germany. |
AiFallback |
ai_fallback |
Ask a language model when the name is not in the data. Needs AI consent on the account. |
BestGuess |
best_guess |
Return the likelier gender even below the probability threshold. |
Country distribution
Which countries a name is recorded in. This is not a country-of-origin or
ethnicity inference: Registrations is counted volume, comparable only among the
countries that publish counted birth statistics, and AttestedIn is presence with
no weight attached. Show Basis.Note next to any percentage.
var dist = await client.CountriesAsync("Mehmet", limit: 10);
foreach (var r in dist.Registrations)
{
Console.WriteLine($"{r.Country} {r.Share:0.##}%");
}
Account
var account = await client.AccountAsync(); // costs no credits
Console.WriteLine(account.CreditsRemaining);
Errors
Success is the HTTP status. A non-2xx response throws NameGenderException:
try
{
await client.NameAsync("Andrea");
}
catch (NameGenderException e) when (e.Code == "no_credits")
{
// e.StatusCode 402, e.RequestId for support, e.Docs links to the error
}
catch (NameGenderException e) when (e.Code == "rate_limited")
{
await Task.Delay(e.RetryAfter ?? TimeSpan.FromSeconds(1));
}
The full list of codes is in the API reference.
HttpClient
Reuse one NameGenderClient; it is thread-safe. With dependency injection, pass
a client from IHttpClientFactory and it will not be disposed for you:
services.AddHttpClient("namegender");
services.AddSingleton(sp => new NameGenderClient(
configuration["NameGender:ApiKey"]!,
sp.GetRequiredService<IHttpClientFactory>().CreateClient("namegender")));
License
MIT
| 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.