Whois 4.0.0-beta.1
dotnet add package Whois --version 4.0.0-beta.1
NuGet\Install-Package Whois -Version 4.0.0-beta.1
<PackageReference Include="Whois" Version="4.0.0-beta.1" />
<PackageVersion Include="Whois" Version="4.0.0-beta.1" />
<PackageReference Include="Whois" />
paket add Whois --version 4.0.0-beta.1
#r "nuget: Whois, 4.0.0-beta.1"
#:package Whois@4.0.0-beta.1
#addin nuget:?package=Whois&version=4.0.0-beta.1&prerelease
#tool nuget:?package=Whois&version=4.0.0-beta.1&prerelease
.NET WHOIS Lookup and Parser
Query and parse WHOIS domain registration information with this library for .NET Standard 2.0, .NET 8, and .NET 10.
// Create a WhoisLookup instance
var lookup = new WhoisLookup();
// Query github.com
var response = await lookup.Lookup("github.com");
// Output the response
Console.WriteLine(response.Content);
// Domain Name: github.com
// Registry Domain ID: 1264983250_DOMAIN_COM-VRSN
// Registrar WHOIS Server: whois.markmonitor.com
// Registrar URL: http://www.markmonitor.com
// ...
Parsing
WHOIS data is parsed into objects using extensible Tokenizer templates.
// Query github.com
var response = await lookup.Lookup("github.com");
// Convert the response to JSON
var json = JsonSerializer.Serialize(response, new JsonSerializerOptions { WriteIndented = true });
// Output the json
Console.WriteLine(json);
// {
// "ContentLength": 3730,
// "Status": 1,
// "DomainName": {
// "IsPunyCode": false,
// "IsTld": false,
// "Tld": "com",
// "Value": "github.com"
// },
// "RegistryDomainId": "1264983250_DOMAIN_COM-VRSN",
// "DomainStatus": [
// "clientUpdateProhibited",
// "clientTransferProhibited",
// "clientDeleteProhibited"
// ],
// "Registered": "2007-10-09T18:20:50Z",
// "Updated": "2020-09-08T09:18:27Z",
// "Expiration": "2022-10-09T07:00:00Z",
// ...
CancellationToken Support
All async methods accept a CancellationToken for cooperative cancellation:
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
var response = await lookup.Lookup("github.com", cts.Token);
Configuration
Configure the lookup per-instance using the options constructor parameter:
var lookup = new WhoisLookup(new WhoisOptions
{
TimeoutSeconds = 30,
FollowReferrer = true
});
Dependency Injection
The library integrates with Microsoft.Extensions.DependencyInjection via the AddWhois() extension method:
// In Startup/Program.cs — configure with a lambda
services.AddWhois(options =>
{
options.TimeoutSeconds = 30;
options.FollowReferrer = true;
});
// Or bind from IConfiguration
services.AddWhois(configuration.GetSection("Whois"));
Inject IWhoisLookup into your services:
public class MyService(IWhoisLookup whoisLookup)
{
public async Task<WhoisResponse> CheckDomain(string domain, CancellationToken ct)
=> await whoisLookup.Lookup(domain, ct);
}
Logging
The library uses Microsoft.Extensions.Logging. When registered via DI, an ILogger<WhoisLookup> is automatically injected. For standalone use, pass a logger factory explicitly:
using var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var lookup = new WhoisLookup(logger: loggerFactory.CreateLogger<WhoisLookup>());
Extending
Parsing More Data
If a registrar's WHOIS data isn't being parsed correctly, you can simply add a new template:
var lookup = new WhoisLookup();
// Clear the embedded templates (not recommended)
lookup.Parser.ClearTemplates();
// Add a custom WHOIS response parsing template
lookup.Parser.AddTemplate("Domain: { DomainName$ }", "Simple Pattern");
See the existing patterns and Tokenizer documentation for information about creating patterns. You can also add validation and transformation functions to your patterns.
Networking
The library communicates via an ITcpReader interface. The default implementation will talk directly to a WHOIS server over port 43. You can change this behaviour by creating a new ITcpReader implementation and passing it to the constructor:
// Create a custom ITcpReader implementation
class MyCustomTcpReader : ITcpReader
{
private readonly ITcpReader _inner = new TcpReader();
public Task<string> Read(string url, int port, string command, Encoding encoding, int timeoutSeconds, CancellationToken cancellationToken)
{
Console.WriteLine($"Reading from URL: {url}");
return _inner.Read(url, port, command, encoding, timeoutSeconds, cancellationToken);
}
}
// Create a WhoisLookup instance with the custom reader
var lookup = new WhoisLookup(tcpReader: new MyCustomTcpReader());
// Lookups will now use the custom TcpReader
var response = await lookup.Lookup("github.com");
Installation
You can install the library via the NuGet GUI or by entering the following command into the Package Manager Console:
Install-Package Whois -Version 4.0.0
The source code is available on Github and can be downloaded and compiled.
Further Reading
Further details about how the library works can be found on this blog post.
| 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
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- Tokenizer (>= 2.2.2)
-
net10.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- Tokenizer (>= 2.2.2)
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 9.0.0)
- Microsoft.Extensions.Options (>= 9.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 9.0.0)
- Tokenizer (>= 2.2.2)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on Whois:
| Package | Downloads |
|---|---|
|
DevSDK
Proje Geliştirme Araçları |
|
|
OneRow.Utils
Utility Library for lot of stuff. Use as-is, no support. |
|
|
EmailLookup
A nuget package that provides a means of looking up various information about a person given just their email address. |
|
|
OneRow.Utils.NetworkManager
Some Network Utilities. Use as-is. No support. |
|
|
Microsoft.CST.OSSGadget.Shared.CLI
OSS Gadget - Shared CLI Functionality |
GitHub repositories (3)
Showing the top 3 popular GitHub repositories that depend on Whois:
| Repository | Stars |
|---|---|
|
Leo-Corporation/InternetTest
InternetTest is a modern connection utility for Windows. It can locate IP addresses, send ping request, recover your WiFi passwords and more!
|
|
|
microsoft/OSSGadget
Collection of tools for analyzing open source packages.
|
|
|
Stratus-Security/Subdominator
The Internets #1 Subdomain Takeover Tool
|