Skip to content

Repository files navigation

WhoisFreaks - the C# library for the WhoisFreaks API

Complete WhoisFreaks API — WHOIS, DNS, SSL, Geolocation, Typosquatting, IP Intelligence, Domain Reputation, and bulk database downloads.

Authentication

All requests require an apiKey query parameter.

Resources

This C# SDK is automatically generated by the OpenAPI Generator project:

  • API version: 1.0.0
  • SDK version: 0.21.0
  • Generator version: 7.11.0
  • Build package: org.openapitools.codegen.languages.CSharpClientCodegen For more information, please visit https://whoisfreaks.com

Frameworks supported

Dependencies

The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:

Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations

Installation

Run the following command to generate the DLL

  • [Mac/Linux] /bin/sh build.sh
  • [Windows] build.bat

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using WhoisFreaks.Api;
using WhoisFreaks.Client;
using WhoisFreaks.Model;

Packaging

A .nuspec is included with the project. You can follow the Nuget quickstart to create and publish packages.

This .nuspec uses placeholders from the .csproj, so build the .csproj directly:

nuget pack -Build -OutputDirectory out WhoisFreaks.csproj

Then, publish to a local feed or other host and consume the new package via Nuget as usual.

Usage

To use the API client with a HTTP proxy, setup a System.Net.WebProxy

Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;

Connections

Each ApiClass (properly the ApiClient inside it) will create an instance of HttpClient. It will use that for the entire lifecycle and dispose it when called the Dispose method.

To better manager the connections it's a common practice to reuse the HttpClient and HttpClientHandler (see here for details). To use your own HttpClient instance just pass it to the ApiClass constructor.

HttpClientHandler yourHandler = new HttpClientHandler();
HttpClient yourHttpClient = new HttpClient(yourHandler);
var api = new YourApiClass(yourHttpClient, yourHandler);

If you want to use an HttpClient and don't have access to the handler, for example in a DI context in Asp.net Core when using IHttpClientFactory.

HttpClient yourHttpClient = new HttpClient();
var api = new YourApiClass(yourHttpClient);

You'll loose some configuration settings, the features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. You need to either manually handle those in your setup of the HttpClient or they won't be available.

Here an example of DI setup in a sample web project:

services.AddHttpClient<YourApiClass>(httpClient =>
   new PetApi(httpClient));

Getting Started

using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using WhoisFreaks.Api;
using WhoisFreaks.Client;
using WhoisFreaks.Model;

namespace Example
{
    public class Example
    {
        public static void Main()
        {

            Configuration config = new Configuration();
            config.BasePath = "https://api.whoisfreaks.com";
            // Configure API key authorization: ApiKeyAuth
            config.ApiKey.Add("apiKey", "YOUR_API_KEY");
            // Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
            // config.ApiKeyPrefix.Add("apiKey", "Bearer");

            // create instances of HttpClient, HttpClientHandler to be reused later with different Api classes
            HttpClient httpClient = new HttpClient();
            HttpClientHandler httpClientHandler = new HttpClientHandler();
            var apiInstance = new ASNWHOISApi(httpClient, config, httpClientHandler);
            var asn = as15169;  // string | 
            var format = "json";  // string? |  (optional)  (default to json)

            try
            {
                // ASN WHOIS Lookup
                AsnWhoisResponse result = apiInstance.AsnWhois(asn, format);
                Debug.WriteLine(result);
            }
            catch (ApiException e)
            {
                Debug.Print("Exception when calling ASNWHOISApi.AsnWhois: " + e.Message );
                Debug.Print("Status Code: "+ e.ErrorCode);
                Debug.Print(e.StackTrace);
            }

        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://api.whoisfreaks.com

Class Method HTTP request Description
ASNWHOISApi AsnWhois GET /v2.0/asn-whois ASN WHOIS Lookup
AccountApi AccountUsage GET /v1.0/whoisapi/usage Account Usage
AccountApi DatabaseFileStatus GET /v3.4/status Database File Status (Public)
AccountApi RotateApiKey GET /v1.0/api-key/rotate Rotate API Key
DNSApi DnsBulk POST /v2.0/dns/bulk/live Bulk DNS Lookup
DNSApi DnsHistorical GET /v2.0/dns/historical Historical DNS Lookup
DNSApi DnsLive GET /v2.0/dns/live Live DNS Lookup
DNSApi DnsReverse GET /v2.1/dns/reverse Reverse DNS Lookup
DatabasesASNWHOISApi DbAsnWhois GET /v3.3/download/snapshot/asn/whois ASN WHOIS Snapshot
DatabasesASNWHOISApi DbAsnWhoisStatus GET /v3.3/status/snapshot/asn/whois ASN WHOIS Snapshot Status
DatabasesDNSApi DbDnsDaily GET /v3.2/download/dbupdate/daily/dns DNS Database Daily
DatabasesDNSApi DbDnsMonthly GET /v3.2/download/dbupdate/monthly/dns DNS Database Monthly
DatabasesDNSApi DbDnsWeekly GET /v3.2/download/dbupdate/weekly/dns DNS Database Weekly
DatabasesExpiringDroppedApi DbDropped GET /v3.1/download/domainer/dropped Dropped Domains
DatabasesExpiringDroppedApi DbDroppedBacklinks GET /v3.3/download/domainer/dropped/backlinks Dropped With Backlinks
DatabasesExpiringDroppedApi DbDroppedJson GET /v3.1/domains/dropped Dropped Domains (JSON)
DatabasesExpiringDroppedApi DbExpired GET /v3.1/download/domainer/expired Expiring Domains
DatabasesExpiringDroppedApi DbExpiredCleaned GET /v3.1/download/domainer/expired/cleaned Expiring Cleaned WHOIS
DatabasesIPGeolocationApi DbIpCity GET /v3.3/download/snapshot/ip/city IP to City Snapshot
DatabasesIPGeolocationApi DbIpCityStatus GET /v3.3/status/snapshot/ip/city IP to City Snapshot Status
DatabasesIPGeolocationApi DbIpCountry GET /v3.3/download/snapshot/ip/country IP to Country Snapshot
DatabasesIPGeolocationApi DbIpCountryStatus GET /v3.3/status/snapshot/ip/country IP to Country Snapshot Status
DatabasesIPSecurityApi DbIpSecurity GET /v3.3/download/snapshot/ip/security IP Security Snapshot
DatabasesIPSecurityApi DbIpSecurityStatus GET /v3.3/status/snapshot/ip/security IP Security Snapshot Status
DatabasesIPWHOISApi DbIpWhois GET /v3.3/download/snapshot/ip/whois IP WHOIS Snapshot
DatabasesIPWHOISApi DbIpWhoisStatus GET /v3.3/status/snapshot/ip/whois IP WHOIS Snapshot Status
DatabasesNewlyRegisteredApi DbNewlyCctld GET /v3.1/download/domainer/cctld Newly Registered ccTLD (CSV)
DatabasesNewlyRegisteredApi DbNewlyCctldCleaned GET /v3.1/download/domainer/cctld/cleaned Newly Registered ccTLD Cleaned WHOIS (CSV)
DatabasesNewlyRegisteredApi DbNewlyCctldJson GET /v3.1/domains/newly/cctld Newly Registered ccTLD (JSON)
DatabasesNewlyRegisteredApi DbNewlyDns GET /v3.1/download/domainer/newly/dns Newly Registered With DNS
DatabasesNewlyRegisteredApi DbNewlyGtld GET /v3.1/download/domainer/gtld Newly Registered gTLD (CSV)
DatabasesNewlyRegisteredApi DbNewlyGtldCleaned GET /v3.1/download/domainer/gtld/cleaned Newly Registered gTLD Cleaned WHOIS (CSV)
DatabasesNewlyRegisteredApi DbNewlyGtldJson GET /v3.1/domains/newly/gtld Newly Registered gTLD (JSON)
DatabasesSubdomainsApi DbSubdomainsDaily GET /v3.2/download/dbupdate/daily/subdomains Subdomains Daily
DatabasesSubdomainsApi DbSubdomainsMonthly GET /v3.2/download/dbupdate/monthly/subdomains Subdomains Monthly
DatabasesSubdomainsApi DbSubdomainsWeekly GET /v3.2/download/dbupdate/weekly/subdomains Subdomains Weekly
DatabasesThreatFeedApi DownloadThreatFeedMalware GET /v3.4/download/threat-feed/malware Download the daily malware threat feed (CSV)
DatabasesThreatFeedApi DownloadThreatFeedMalwareSample GET /v3.4/download/threat-feed/malware/sample Download a sample of the malware threat feed (CSV)
DatabasesThreatFeedApi DownloadThreatFeedPhishing GET /v3.4/download/threat-feed/phishing Download the daily phishing threat feed (CSV)
DatabasesThreatFeedApi DownloadThreatFeedPhishingSample GET /v3.4/download/threat-feed/phishing/sample Download a sample of the phishing threat feed (CSV)
DatabasesThreatFeedApi DownloadThreatFeedSpam GET /v3.4/download/threat-feed/spam Download the daily spam threat feed (CSV)
DatabasesThreatFeedApi DownloadThreatFeedSpamSample GET /v3.4/download/threat-feed/spam/sample Download a sample of the spam threat feed (CSV)
DatabasesWHOISApi DbWhoisDaily GET /v3.3/download/dbupdate/daily/domains/whois WHOIS Database Daily
DatabasesWHOISApi DbWhoisMonthly GET /v3.3/download/dbupdate/monthly/domains/whois WHOIS Database Monthly
DatabasesWHOISApi DbWhoisWeekly GET /v3.3/download/dbupdate/weekly/domains/whois WHOIS Database Weekly
DomainAvailabilityApi BulkDomainAvailabilityV2 POST /v2.0/domain/availability Bulk Domain Availability Check
DomainAvailabilityApi DomainAvailabilityV2 GET /v2.0/domain/availability Domain Availability Check with Suggestions
DomainReputationApi DomainReputation GET /v1/domain/security Domain Reputation Lookup
GeolocationApi BulkGeolocation POST /v1.0/geolocation Bulk IP Geolocation
GeolocationApi Geolocation GET /v1.0/geolocation IP Geolocation Lookup
IPReputationApi BulkIpReputation POST /v1.0/security Bulk IP Reputation
IPReputationApi IpReputation GET /v1.0/security IP Reputation Lookup
IPWHOISApi IpWhois GET /v1.0/ip-whois IP WHOIS Lookup
SSLApi SslLookup GET /v1.0/ssl/live SSL Certificate Lookup
SubdomainsApi Subdomains GET /v1.0/subdomains Subdomains Lookup
TyposquattingApi Typosquatting GET /v3.0/domain/typos Typosquatting Lookup
WHOISApi BulkWhois POST /v2.0/bulkwhois/live Bulk WHOIS Lookup
WHOISApi WhoisHistory GET /v2.0/whois/history Historical WHOIS records for a domain
WHOISApi WhoisLive GET /v2.0/whois/live Live WHOIS Lookup
WHOISApi WhoisReverse GET /v2.0/whois/reverse Reverse WHOIS lookup by keyword

Documentation for Models

Documentation for Authorization

Authentication schemes defined for the API:

ApiKeyAuth

  • Type: API key
  • API key parameter name: apiKey
  • Location: URL query string

About

Official WhoisFreaks C# SDK for WHOIS, DNS, SSL, IP geolocation and reputation, domain availability, ASN, and domain intelligence APIs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages