From 09658ed5fbab0ea7acc060e53fa26e086d0d74b0 Mon Sep 17 00:00:00 2001 From: whoisxmlapi Date: Wed, 26 May 2021 12:39:05 +0300 Subject: [PATCH] - Updated: auth mechanics, links - Removed: deprecated mechanics --- README.md | 10 +- .../java/domainavailability-apikey-sample.iml | 19 -- apikey/java/pom.xml | 44 ---- .../java/DomainAvailabilityApiKeySample.java | 143 ------------ apikey/js/domain_availability_apikey.html | 50 ----- .../DomainAvailabilityApiKeyQuery.cs | 207 ------------------ .../domainAvailabilityApiKey.csproj | 63 ------ .../net/DomainAvailabilityApi/packages.config | 4 - apikey/net/domainAvailabilityApiKey.sln | 22 -- apikey/nodejs/domain_availability_apikey.js | 95 -------- apikey/perl/domain_availability_apikey.pl | 89 -------- apikey/php/domain_availability_apikey.php | 88 -------- .../powershell/domain_availability_apikey.ps1 | 24 -- apikey/python/domain_availability_apikey.py | 98 --------- apikey/ruby/domain_availability_apikey.rb | 68 ------ .../domainavailability-sample.iml | 0 {password/java => java}/pom.xml | 6 +- .../main/java/DomainAvailabilitySample.java | 17 +- .../js => js}/domain_availability_pass.html | 11 +- .../DomainAvailabilityQuery.cs | 29 ++- .../DomainAvailabilityApi/app.config | 0 .../domainAvailabilityAuth.csproj | 0 .../domainAvailabilityAuth.sln | 2 +- .../domain_availability_pass.js | 8 +- password/net/DomainAvailabilityApi/app.config | 3 - .../perl => perl}/domain_availability_pass.pl | 14 +- .../domain_availability_api_test.php | 15 +- .../domain_availability_pass.ps1 | 13 +- .../domain_availability_pass.py | 11 +- .../ruby => ruby}/domain_availability_pass.rb | 13 +- 30 files changed, 61 insertions(+), 1105 deletions(-) delete mode 100644 apikey/java/domainavailability-apikey-sample.iml delete mode 100644 apikey/java/pom.xml delete mode 100644 apikey/java/src/main/java/DomainAvailabilityApiKeySample.java delete mode 100644 apikey/js/domain_availability_apikey.html delete mode 100644 apikey/net/DomainAvailabilityApi/DomainAvailabilityApiKeyQuery.cs delete mode 100644 apikey/net/DomainAvailabilityApi/domainAvailabilityApiKey.csproj delete mode 100644 apikey/net/DomainAvailabilityApi/packages.config delete mode 100644 apikey/net/domainAvailabilityApiKey.sln delete mode 100644 apikey/nodejs/domain_availability_apikey.js delete mode 100644 apikey/perl/domain_availability_apikey.pl delete mode 100644 apikey/php/domain_availability_apikey.php delete mode 100644 apikey/powershell/domain_availability_apikey.ps1 delete mode 100644 apikey/python/domain_availability_apikey.py delete mode 100644 apikey/ruby/domain_availability_apikey.rb rename password/java/domainavailability-password-sample.iml => java/domainavailability-sample.iml (100%) rename {password/java => java}/pom.xml (88%) rename password/java/src/main/java/DomainAvailabilityPasswordSample.java => java/src/main/java/DomainAvailabilitySample.java (79%) rename {password/js => js}/domain_availability_pass.html (70%) rename {password/net => net}/DomainAvailabilityApi/DomainAvailabilityQuery.cs (94%) rename {apikey/net => net}/DomainAvailabilityApi/app.config (100%) rename password/net/DomainAvailabilityApi/domainAvailabilityPassAuth.csproj => net/DomainAvailabilityApi/domainAvailabilityAuth.csproj (100%) rename password/net/domainAvailabilityPassAuth.sln => net/domainAvailabilityAuth.sln (88%) rename {password/nodejs => nodejs}/domain_availability_pass.js (83%) delete mode 100644 password/net/DomainAvailabilityApi/app.config rename {password/perl => perl}/domain_availability_pass.pl (70%) rename {password/php => php}/domain_availability_api_test.php (59%) rename {password/powershell => powershell}/domain_availability_pass.ps1 (51%) rename {password/python => python}/domain_availability_pass.py (84%) rename {password/ruby => ruby}/domain_availability_pass.rb (78%) diff --git a/README.md b/README.md index 636c678..066a2cc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Using the Domain Availability API web service -[Domain Availability API](https://www.whoisxmlapi.com/domain-availability-api.php) +[Domain Availability API](https://domain-availability.whoisxmlapi.com/api) checks whether the specified domain name is available for registration for nearly all of the TLDs. @@ -8,13 +8,13 @@ Here you'll find examples of querying the API implemented in multiple languages. You'll need a -[WhoisXmlApi account](https://www.whoisxmlapi.com/user/create.php) to +[WhoisXmlApi account](https://domain-availability.whoisxmlapi.com/api/signup) to authenticate. This API also supports -[API key authentication](https://www.whoisxmlapi.com/user/management.php#api-key-management). +[API key authentication](https://domain-availability.whoisxmlapi.com/api/documentation/making-requests). Please, refer to the -[Domain availability API User Guide](https://www.whoisxmlapi.com/domain-availability-api-guide.php) +[Domain availability API User Guide](https://domain-availability.whoisxmlapi.com/api/documentation/making-requests) for info on input parameters, request/response formats, authentication -instructions and more. \ No newline at end of file +instructions and more. diff --git a/apikey/java/domainavailability-apikey-sample.iml b/apikey/java/domainavailability-apikey-sample.iml deleted file mode 100644 index bdc9e8c..0000000 --- a/apikey/java/domainavailability-apikey-sample.iml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/apikey/java/pom.xml b/apikey/java/pom.xml deleted file mode 100644 index 2831494..0000000 --- a/apikey/java/pom.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - 4.0.0 - - com.whoisxmlapi - domainavailability-apikey-sample - 1.0 - - - - commons-httpclient - commons-httpclient - 3.1 - - - org.json - json - 20171018 - - - - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - - java - - - - - DomainAvailabilityApiKeySample - - - - - - \ No newline at end of file diff --git a/apikey/java/src/main/java/DomainAvailabilityApiKeySample.java b/apikey/java/src/main/java/DomainAvailabilityApiKeySample.java deleted file mode 100644 index 68d63db..0000000 --- a/apikey/java/src/main/java/DomainAvailabilityApiKeySample.java +++ /dev/null @@ -1,143 +0,0 @@ -import java.net.URLEncoder; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.methods.GetMethod; -import org.json.JSONException; -import org.json.JSONObject; - -public class DomainAvailabilityApiKeySample -{ - private Logger logger = - Logger.getLogger(DomainAvailabilityApiKeySample.class.getName()); - - public static void main(String[]args) - { - new DomainAvailabilityApiKeySample().getSimpleDomainUsingApiKey(); - } - - private void getSimpleDomainUsingApiKey() - { - String domainName = "google.com"; - - String username = "Your domain availability api username"; - String apiKey = "Your domain availability api key"; - String secretKey = "Your domain availability api secret key"; - - getDomainNameUsingApiKey(domainName, username, apiKey, secretKey); - } - - private String executeURL(String url) - { - HttpClient c = new HttpClient(); - System.out.println(url); - HttpMethod m = new GetMethod(url); - String res = null; - - try { - c.executeMethod(m); - res = new String(m.getResponseBody()); - } catch (Exception e) { - logger.log(Level.SEVERE, "Cannot get url", e); - } finally { - m.releaseConnection(); - } - - return res; - } - - public void getDomainNameUsingApiKey( - String domainName, - String username, - String apiKey, - String secretKey - ) - { - String apiKeyAuthenticationRequest = - generateApiKeyAuthenticationRequest(username, apiKey, secretKey); - - if (apiKeyAuthenticationRequest == null) { - return; - } - - String domName = ""; - try { - domName = URLEncoder.encode(domainName, "UTF-8"); - } catch (Exception e) { - logger.log(Level.SEVERE, "an error occurred", e); - } - - String url = "https://www.whoisxmlapi.com/whoisserver/WhoisService?" - + apiKeyAuthenticationRequest - + "&cmd=GET_DN_AVAILABILITY" - + "&domainName=" + domName; - - String result = executeURL(url); - if (result != null) { - logger.log(Level.INFO, "result: " + result); - } - } - - private String generateApiKeyAuthenticationRequest( - String username, - String apiKey, - String secretKey - ) - { - try { - long timestamp = System.currentTimeMillis(); - - String request = generateRequest(username, timestamp); - String digest = - generateDigest(username, apiKey, secretKey, timestamp); - - String requestURL = URLEncoder.encode(request, "UTF-8"); - String digestURL = URLEncoder.encode(digest, "UTF-8"); - - return "requestObject=" + requestURL + "&digest=" + digestURL; - } catch (Exception e) { - logger.log(Level.SEVERE, "an error occurred", e); - } - return null; - } - - private String generateRequest(String username, long timestamp) - throws JSONException - { - JSONObject json = new JSONObject(); - json.put("u", username); - json.put("t", timestamp); - String jsonStr = json.toString(); - byte[] json64 = Base64.encodeBase64(jsonStr.getBytes()); - - return new String(json64); - } - - private String generateDigest( - String username, - String apiKey, - String secretKey, - long timestamp - ) - throws Exception - { - String sb = username + timestamp + apiKey; - - SecretKeySpec secretKeySpec = - new SecretKeySpec(secretKey.getBytes("UTF-8"), "HmacMD5"); - - Mac mac = Mac.getInstance(secretKeySpec.getAlgorithm()); - mac.init(secretKeySpec); - - byte[] digestBytes = mac.doFinal(sb.getBytes("UTF-8")); - - return new String(Hex.encodeHex(digestBytes)); - } -} \ No newline at end of file diff --git a/apikey/js/domain_availability_apikey.html b/apikey/js/domain_availability_apikey.html deleted file mode 100644 index adb7be6..0000000 --- a/apikey/js/domain_availability_apikey.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - Domain Availability API jQuery Api Key Search Sample - - - - - - \ No newline at end of file diff --git a/apikey/net/DomainAvailabilityApi/DomainAvailabilityApiKeyQuery.cs b/apikey/net/DomainAvailabilityApi/DomainAvailabilityApiKeyQuery.cs deleted file mode 100644 index 808a2f8..0000000 --- a/apikey/net/DomainAvailabilityApi/DomainAvailabilityApiKeyQuery.cs +++ /dev/null @@ -1,207 +0,0 @@ -using System; -using System.IO; -using System.Net; -using System.Security.Cryptography; -using System.Text; - -using Newtonsoft.Json; - -/* - * Target platform: .Net Framework 4.0 - * - * You need to install Newtonsoft JSON.NET - * - */ - -namespace DomainAvailabilityApi -{ - public static class DomainAvailabilityApiKeyQuery - { - private static void Main() - { - const string username = "Your domain availability api username"; - const string apiKey = "Your domain availability api key"; - const string secretKey ="Your domain availability api secret key"; - - const string url = - "https://whoisxmlapi.com/whoisserver/WhoisService"; - - string[] domains = - { - "google.com", - "example.com", - "whoisxmlapi.com", - "twitter.com" - }; - - ApiSample.PerformRequest(username, apiKey, secretKey,url,domains); - } - } - - public static class ApiSample - { - public static void PerformRequest( - string username, - string apiKey, - string secretKey, - string url, - string[] domains - ) - { - var timestamp = GetTimeStamp(); - - var digest = GenerateDigest(username, apiKey,secretKey,timestamp); - - foreach (var domain in domains) - { - try - { - var request = BuildRequest( - username, timestamp, digest, domain); - - var response = GetAvailabilityData(url + request); - - if (response.Contains("Request timeout")) - { - timestamp = GetTimeStamp(); - - digest = GenerateDigest( - username, apiKey, secretKey, timestamp); - - request = BuildRequest( - username, timestamp, digest, domain); - - response = GetAvailabilityData(url + request); - } - - PrintResponse(response); - } - catch (Exception) - { - Console.WriteLine( - "Error occurred\r\nCannot get whois data for "+domain); - } - } - - Console.WriteLine("Press any key to continue..."); - Console.ReadLine(); - } - - private static string GenerateDigest( - string username, - string apiKey, - string secretKey, - long timestamp - ) - { - var data = username + timestamp + apiKey; - var hmac = new HMACMD5(Encoding.UTF8.GetBytes(secretKey)); - - var hex = BitConverter.ToString( - hmac.ComputeHash(Encoding.UTF8.GetBytes(data))); - - return hex.Replace("-", "").ToLower(); - } - - private static string BuildRequest( - string username, - long timestamp, - string digest, - string domain - ) - { - var ud = new UserData - { - u = username, - t = timestamp - }; - - var userData = JsonConvert.SerializeObject(ud,Formatting.None); - var userDataBytes = Encoding.UTF8.GetBytes(userData); - - var userDataBase64 = Convert.ToBase64String(userDataBytes); - - var requestString = new StringBuilder(); - requestString.Append("?cmd=GET_DN_AVAILABILITY"); - requestString.Append("&requestObject="); - requestString.Append(Uri.EscapeDataString(userDataBase64)); - requestString.Append("&digest="); - requestString.Append(Uri.EscapeDataString(digest)); - requestString.Append("&domainName="); - requestString.Append(Uri.EscapeDataString(domain)); - requestString.Append("&outputFormat=json"); - - return requestString.ToString(); - } - - private static string GetAvailabilityData(string url) - { - var response = ""; - - try - { - var wr = WebRequest.Create(url); - var wp = wr.GetResponse(); - - using (var data = wp.GetResponseStream()) - { - - if (data == null) - return response; - - using (var reader = new StreamReader(data)) - { - response = reader.ReadToEnd(); - } - } - wp.Close(); - } - catch (Exception e) - { - Console.WriteLine(e.Message); - throw new Exception(e.Message); - } - - return response; - } - - private static void PrintResponse(string response) - { - dynamic responseObject = JsonConvert.DeserializeObject(response); - - if (responseObject.DomainInfo!= null) - { - var daRecord = responseObject.DomainInfo; - - if (daRecord.domainName != null) - { - Console.WriteLine( - "Domain name: " + daRecord.domainName.ToString()); - } - if (daRecord.domainAvailability != null) - { - Console.WriteLine( - "Domain availability: " - + daRecord.domainAvailability.ToString()); - } - Console.WriteLine("--------------------------------"); - - return; - } - - Console.WriteLine(response); - } - - private static long GetTimeStamp() - { - return (long)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)) - .TotalMilliseconds); - } - } - - internal class UserData - { - public string u { get; set; } - public long t { get; set; } - } -} \ No newline at end of file diff --git a/apikey/net/DomainAvailabilityApi/domainAvailabilityApiKey.csproj b/apikey/net/DomainAvailabilityApi/domainAvailabilityApiKey.csproj deleted file mode 100644 index 0bc9e4c..0000000 --- a/apikey/net/DomainAvailabilityApi/domainAvailabilityApiKey.csproj +++ /dev/null @@ -1,63 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9} - Exe - Properties - DomainAvailabilityApi - DomainAvailabilityApi - v4.0 - - - 512 - - - x86 - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - - - x86 - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - false - - - - - - - - ..\packages\Newtonsoft.Json.11.0.2\lib\net40\Newtonsoft.Json.dll - - - - - - - - - - - - \ No newline at end of file diff --git a/apikey/net/DomainAvailabilityApi/packages.config b/apikey/net/DomainAvailabilityApi/packages.config deleted file mode 100644 index 07048c7..0000000 --- a/apikey/net/DomainAvailabilityApi/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/apikey/net/domainAvailabilityApiKey.sln b/apikey/net/domainAvailabilityApiKey.sln deleted file mode 100644 index 0f28250..0000000 --- a/apikey/net/domainAvailabilityApiKey.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domainAvailabilityApiKey", "DomainAvailabilityApi\domainAvailabilityApiKey.csproj", "{F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9}.Debug|x86.ActiveCfg = Debug|x86 - {F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9}.Debug|x86.Build.0 = Debug|x86 - {F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9}.Release|x86.ActiveCfg = Release|x86 - {F19DE4B9-B7B3-4D8F-98DB-832ED949FEE9}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/apikey/nodejs/domain_availability_apikey.js b/apikey/nodejs/domain_availability_apikey.js deleted file mode 100644 index a23f1f1..0000000 --- a/apikey/nodejs/domain_availability_apikey.js +++ /dev/null @@ -1,95 +0,0 @@ -const crypto = require('crypto'); -const https = require('https'); -const queryString = require('querystring'); - -const url = 'https://whoisxmlapi.com/whoisserver/WhoisService'; - -const username = 'Your domain availability api username'; -const apiKey = 'Your domain availability api key'; -const secretKey = 'Your domain availability api secret key'; - -const domains = [ - 'google.com', - 'example.com', - 'whoisxmlapi.com', - 'twitter.com' -]; - -for(var i in domains) { - getAvailability(username, apiKey, secretKey, domains[i]); -} - -function getAvailability(username, apiKey, secretKey, domain) -{ - var timestamp = (new Date).getTime(); - var digest = generateDigest(username, timestamp, apiKey, secretKey); - var requestString = buildRequest(username, timestamp, digest, domain); - - https.get(url + '?' + requestString, function (res) { - const statusCode = res.statusCode; - - if (statusCode !== 200) { - console.log('Request failed: ' + statusCode); - } - - var rawData = ''; - - res.on('data', function(chunk) { - rawData += chunk; - }); - - res.on('end', function () { - printResponse(rawData); - }) - - }).on('error', function(e) { - console.log('Error: ' + e.message); - }); -} - -function generateDigest(username, timestamp, apiKey, secretKey) -{ - var data = username + timestamp + apiKey; - var hmac = crypto.createHmac('md5', secretKey); - hmac.update(data); - - return hmac.digest('hex'); -} - -function buildRequest(username, timestamp, digest, domain) -{ - var data = { - u: username, - t: timestamp - }; - - var dataJson = JSON.stringify(data); - var dataBase64 = Buffer.from(dataJson).toString('base64'); - - var request = { - requestObject: dataBase64, - cmd: 'GET_DN_AVAILABILITY', - digest: digest, - domainName: domain, - outputFormat: 'json' - }; - - return queryString.stringify(request); -} - -function printResponse(responseRaw) -{ - var response = JSON.parse(responseRaw); - - if (response.DomainInfo) { - var output = 'Domain name: '; - output += response.DomainInfo.domainName; - output += '\n'; - output += 'Domain availability: '; - output += response.DomainInfo.domainAvailability; - output += '\n'; - console.log(output); - } else { - console.log(response); - } -} \ No newline at end of file diff --git a/apikey/perl/domain_availability_apikey.pl b/apikey/perl/domain_availability_apikey.pl deleted file mode 100644 index a7f5a05..0000000 --- a/apikey/perl/domain_availability_apikey.pl +++ /dev/null @@ -1,89 +0,0 @@ -use Digest::HMAC_MD5 qw( hmac_md5_hex ); # From CPAN -use JSON qw( decode_json encode_json ); # From CPAN -use LWP::Protocol::https; # From CPAN -use LWP::Simple; # From CPAN -use MIME::Base64 qw( encode_base64 ); -use Time::HiRes qw( time ); # From CPAN -use URI::Escape qw( uri_escape ); # From CPAN - -use strict; -use warnings; - -my @domains = ( - 'google.com', - 'example.com', - 'whoisxmlapi.com', - 'twitter.com' -); -my $url = 'https://whoisxmlapi.com/whoisserver/WhoisService'; - -my $username = 'Your domain availability api username'; -my $api_key = 'Your domain availability api key'; -my $secret = 'Your domain availability api secret key'; - -my $timestamp = int((time * 1000 + 0.5)); -my $digest = generateDigest($username, $timestamp, $api_key, $secret); - -foreach my $domain (@domains) { - my $requstString = buildRequest($username, $timestamp, $digest, $domain); - my $response = get($url . $requstString); - - if (index($response, 'Request timeout')) { - $timestamp = int((time * 1000 + 0.5)); - $digest = generateDigest($username, $timestamp, $api_key, $secret); - $requstString = buildRequest($username, $timestamp, $digest, $domain); - $response = get($url . $requstString); - } - - printResponse($response); - print "---------------------------------------\n"; -} - -sub generateDigest -{ - my ($req_username, $req_timestamp, $req_key, $req_secret) = @_; - - my $res_digest = $req_username . $req_timestamp . $req_key; - my $res_hash = hmac_md5_hex($res_digest, $req_secret); - - return uri_escape($res_hash); -} - -sub buildRequest -{ - my ($req_username, $req_timestamp, $req_digest, $req_domain) = @_; - my $requestString = '?requestObject='; - - my %request =( - 'u' => $req_username, - 't' => $req_timestamp - ); - - my $requestJson = encode_json(\%request); - my $requestBase64 = encode_base64($requestJson); - - $requestString .= uri_escape($requestBase64); - $requestString .= '&cmd=GET_DN_AVAILABILITY'; - $requestString .= '&digest=' . $req_digest; - $requestString .= '&domainName=' . uri_escape($req_domain); - $requestString .= '&outputFormat=json'; - - return $requestString; -} - -sub printResponse -{ - my ($response) = @_; - my $responseObject = decode_json($response); - - if (exists $responseObject->{'DomainInfo'}->{'domainName'}) { - print 'Domain name: ', - $responseObject->{'DomainInfo'}->{'domainName'}, - "\n"; - } - if (exists $responseObject->{'DomainInfo'}->{'domainAvailability'}) { - print 'Domain availability: ', - $responseObject->{'DomainInfo'}->{'domainAvailability'}, - "\n"; - } -} \ No newline at end of file diff --git a/apikey/php/domain_availability_apikey.php b/apikey/php/domain_availability_apikey.php deleted file mode 100644 index e8af78d..0000000 --- a/apikey/php/domain_availability_apikey.php +++ /dev/null @@ -1,88 +0,0 @@ - $username, - 't' => $timestamp - ); - - $requestJson = json_encode($request); - $requestBase64 = urlencode(base64_encode($requestJson)); - - $requestString .= urlencode($requestBase64); - $requestString .= '&cmd=GET_DN_AVAILABILITY'; - $requestString .= '&digest=' . $digest; - $requestString .= '&domainName=' . urlencode($domain); - $requestString .= '&outputFormat=json'; - - return $requestString; -} \ No newline at end of file diff --git a/apikey/powershell/domain_availability_apikey.ps1 b/apikey/powershell/domain_availability_apikey.ps1 deleted file mode 100644 index 3cfc445..0000000 --- a/apikey/powershell/domain_availability_apikey.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -$url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService' - -$domain = 'google.com' -$username = 'Your domain availability api username' -$key = 'Your domain availability api key' -$secret = 'Your domain availability api secret key' - -$time = [DateTimeOffset]::Now.ToUnixTimeMilliseconds() -$req=[Text.Encoding]::UTF8.GetBytes("{`"t`":$($time),`"u`":`"$($username)`"}") -$req = [Convert]::ToBase64String($req) - -$data = $username + $time + $key -$hmac = New-Object System.Security.Cryptography.HMACMD5 -$hmac.key = [Text.Encoding]::UTF8.GetBytes($secret) -$hash = $hmac.ComputeHash([Text.Encoding]::UTF8.GetBytes($data)) -$digest = [BitConverter]::ToString($hash).Replace('-', '').ToLower() - -$uri = $url` - + '?cmd=GET_DN_AVAILABILITY'` - + '&requestObject=' + [uri]::EscapeDataString($req)` - + '&digest=' + [uri]::EscapeDataString($digest)` - + '&domainName=' + [uri]::EscapeDataString($domain) - -echo (Invoke-WebRequest -Uri $uri).Content \ No newline at end of file diff --git a/apikey/python/domain_availability_apikey.py b/apikey/python/domain_availability_apikey.py deleted file mode 100644 index 9e59c7d..0000000 --- a/apikey/python/domain_availability_apikey.py +++ /dev/null @@ -1,98 +0,0 @@ -try: - # For Python v.3 and later - from urllib.request import urlopen, pathname2url - from urllib.parse import quote -except ImportError: - # For Python v.2 - from urllib import pathname2url - from urllib2 import urlopen, quote - -import base64 -import hashlib -import hmac -import json -import time - -username = 'Your domain availability api username' -api_key = 'Your domain availability api key' -secret = 'Your domain availability api secret key' - -domains = [ - 'google.com', - 'example.com', - 'whoisxmlapi.com', - 'twitter.com' -] - -url = 'https://whoisxmlapi.com/whoisserver/WhoisService' - - -def build_request(req_username, req_timestamp, req_digest, req_domain): - res = '?requestObject=' - - data = { - 'u': req_username, - 't': req_timestamp - } - - data_json = json.dumps(data) - data_b64 = base64.b64encode(bytearray(data_json.encode('utf-8'))) - - res += pathname2url(data_b64.decode('utf-8')) - res += '&cmd=GET_DN_AVAILABILITY' - res += '&digest=' - res += pathname2url(req_digest) - res += '&domainName=' - res += pathname2url(req_domain) - res += '&outputFormat=json' - - return res - - -def generate_digest(req_username, req_timestamp, req_key, req_secret): - res_digest = req_username + str(req_timestamp) + req_key - - res_hash = hmac.new(bytearray(req_secret.encode('utf-8')), - bytearray(res_digest.encode('utf-8')), - hashlib.md5) - - return quote(str(res_hash.hexdigest())) - - -def generate_parameters(req_username, req_key, req_secret): - res_timestamp = int(round(time.time() * 1000)) - - res_digest = generate_digest(req_username, res_timestamp, - req_key, req_secret) - - return res_timestamp, res_digest - - -def print_response(req_response): - response_json = json.loads(req_response) - - if 'DomainInfo' in response_json: - if 'domainName' in response_json['DomainInfo']: - print('Domain Name: ') - print(response_json['DomainInfo']['domainName']) - if 'domainAvailability' in response_json['DomainInfo']: - print('Domain availability: ') - print(response_json['DomainInfo']['domainAvailability']) - - -def request(req_url, req_username, req_timestamp, req_digest, req_domain): - res_request = build_request(req_username, req_timestamp, - req_digest, req_domain) - - return urlopen(req_url + res_request).read().decode('utf8') - - -timestamp, digest = generate_parameters(username, api_key, secret) - -for domain in domains: - response = request(url, username, timestamp, digest, domain) - if 'Request timeout' in response: - timestamp, digest = generate_parameters(username, api_key, secret) - response = request(url, username, timestamp, digest, domain) - print_response(response) - print('---------------------------\n') diff --git a/apikey/ruby/domain_availability_apikey.rb b/apikey/ruby/domain_availability_apikey.rb deleted file mode 100644 index e983d64..0000000 --- a/apikey/ruby/domain_availability_apikey.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'base64' -require 'erb' -require 'json' -require 'net/https' -require 'openssl' -require 'yaml' - -domains = %w[ - google.com - example.com - whoisxmlapi.com - twitter.com -] - -url = 'https://whoisxmlapi.com/whoisserver/WhoisService' - -username = 'Your domain availability api username' -api_key = 'Your domain availability api key' -secret = 'Your domain availability api secret key' - -def generate_digest(username, timestamp, api_key, secret) - digest = username + timestamp.to_s + api_key - OpenSSL::HMAC.hexdigest(OpenSSL::Digest::MD5.new, secret, digest) -end - -def build_request(username, timestamp, digest, domain) - data = { - u: username, - t: timestamp - } - '?requestObject=' + ERB::Util.url_encode(Base64.encode64(data.to_json)) + - '&cmd=GET_DN_AVAILABILITY' \ - '&digest=' + ERB::Util.url_encode(digest) + - '&domainName=' + ERB::Util.url_encode(domain) + - '&outputFormat=json' -end - -def print_response(response) - hash = JSON.parse(response) - - return unless hash.key? 'DomainInfo' - - if hash['DomainInfo'].key? 'domainName' - puts 'Domain name: ' + hash['DomainInfo']['domainName'] - end - - return unless hash['DomainInfo'].key? 'domainAvailability' - - puts 'Domain availability: ' + hash['DomainInfo']['domainAvailability'] -end - -timestamp = (Time.now.to_f * 1000).to_i -digest = generate_digest(username, timestamp, api_key, secret) - -domains.each do |domain| - request_string = build_request(username, timestamp, digest, domain) - response = Net::HTTP.get(URI.parse(url + request_string)) - - if response.include? 'Request timeout' - timestamp = (Time.now.to_f * 1000).to_i - digest = generate_digest(username, timestamp, api_key, secret) - request_string = build_request(username, timestamp, digest, domain) - response = Net::HTTP.get(URI.parse(url + request_string)) - end - - print_response(response) - puts "--------------------------------\n" -end \ No newline at end of file diff --git a/password/java/domainavailability-password-sample.iml b/java/domainavailability-sample.iml similarity index 100% rename from password/java/domainavailability-password-sample.iml rename to java/domainavailability-sample.iml diff --git a/password/java/pom.xml b/java/pom.xml similarity index 88% rename from password/java/pom.xml rename to java/pom.xml index 893a51c..e0dd01b 100644 --- a/password/java/pom.xml +++ b/java/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.whoisxmlapi - domainavailability-password-sample + domainavailability-sample 1.0 @@ -30,9 +30,9 @@ - DomainAvailabilityPasswordSample + DomainAvailabilitySample - \ No newline at end of file + diff --git a/password/java/src/main/java/DomainAvailabilityPasswordSample.java b/java/src/main/java/DomainAvailabilitySample.java similarity index 79% rename from password/java/src/main/java/DomainAvailabilityPasswordSample.java rename to java/src/main/java/DomainAvailabilitySample.java index edcd4b3..0f1fbb1 100644 --- a/password/java/src/main/java/DomainAvailabilityPasswordSample.java +++ b/java/src/main/java/DomainAvailabilitySample.java @@ -20,26 +20,23 @@ * * @author jonz */ -public class DomainAvailabilityPasswordSample +public class DomainAvailabilitySample { public static void main(String[]args) throws IOException { - String API_URL="https://www.whoisxmlapi.com/whoisserver/WhoisService"; + String API_URL="https://domain-availability.whoisxmlapi.com/api/v1"; String domainName = "test.com"; - String getMode = "DNS_ONLY"; //or DNS_AND_WHOIS - String username = "Your domain availability api username"; - String password = "Your domain availability api password"; + String mode = "DNS_ONLY"; //or DNS_AND_WHOIS + String apiKey = "Your domain availability api key"; CloseableHttpClient httpclient = null; try { String url = API_URL + "?domainName=" + URLEncoder.encode(domainName, "UTF-8") - + "&cmd=GET_DN_AVAILABILITY" - + "&getMode=" + URLEncoder.encode(getMode, "UTF-8") - + "&username=" + URLEncoder.encode(username, "UTF-8") - + "&password=" + URLEncoder.encode(password, "UTF-8"); + + "&mode=" + URLEncoder.encode(mode, "UTF-8") + + "&apiKey=" + URLEncoder.encode(apiKey, "UTF-8"); httpclient = HttpClients.createDefault(); HttpGet httpget = new HttpGet(url); @@ -75,4 +72,4 @@ public static void main(String[]args) throws IOException httpclient.close(); } } -} \ No newline at end of file +} diff --git a/password/js/domain_availability_pass.html b/js/domain_availability_pass.html similarity index 70% rename from password/js/domain_availability_pass.html rename to js/domain_availability_pass.html index d8bcea0..b431fb4 100644 --- a/password/js/domain_availability_pass.html +++ b/js/domain_availability_pass.html @@ -5,10 +5,9 @@ - \ No newline at end of file + diff --git a/password/net/DomainAvailabilityApi/DomainAvailabilityQuery.cs b/net/DomainAvailabilityApi/DomainAvailabilityQuery.cs similarity index 94% rename from password/net/DomainAvailabilityApi/DomainAvailabilityQuery.cs rename to net/DomainAvailabilityApi/DomainAvailabilityQuery.cs index 078155f..b4efe8f 100644 --- a/password/net/DomainAvailabilityApi/DomainAvailabilityQuery.cs +++ b/net/DomainAvailabilityApi/DomainAvailabilityQuery.cs @@ -20,15 +20,12 @@ private static void Main() ////////////////////////// // Fill in your details // ////////////////////////// - const string username = "Your domain availability api username"; - const string password = "Your domain availability api password"; + const string apiKey = "Your domain availability api key"; const string domain = "google.com"; - var apiUrl = "https://www.whoisxmlapi.com/whoisserver/" - + "WhoisService?cmd=GET_DN_AVAILABILITY" - + "&domainName=" + Uri.EscapeDataString(domain) - + "&username=" + Uri.EscapeDataString(username) - + "&password=" + Uri.EscapeDataString(password); + var apiUrl = "https://domain-availability.whoisxmlapi.com/api/v1" + + "?domainName=" + Uri.EscapeDataString(domain) + + "&apiKey=" + Uri.EscapeDataString(apiKey); ///////////////////////// // Use a JSON resource // @@ -37,12 +34,12 @@ private static void Main() var url = apiUrl + "&outputFormat=" + Uri.EscapeDataString(format); - + // Create our JSON parser var jsc = new JavaScriptSerializer(); jsc.RegisterConverters(new JavaScriptConverter[] { new DynamicJsonConverter() - }); + }); // Download and parse the JSON into a dynamic object dynamic result = jsc.Deserialize( @@ -73,10 +70,10 @@ private static void Main() format = "XML"; url = apiUrl + "&outputFormat=" + Uri.EscapeDataString(format); - + var settings = new XmlReaderSettings(); var reader = XmlReader.Create(url, settings); - + try { var domType = typeof(DomainInfo); @@ -293,13 +290,13 @@ public class ErrorMessage [Serializable()] public class DomainInfo - { + { [System.Xml.Serialization.XmlElement("domainName")] public string domainName { get; set; } [System.Xml.Serialization.XmlElement("domainAvailability")] public string domainAvailability { get; set; } - + public void PrintToConsole() { Console.WriteLine("DomainInfo:"); @@ -307,8 +304,8 @@ public void PrintToConsole() Console.WriteLine("\tdomainAvailability: " + domainAvailability); - + } } - } -} \ No newline at end of file + } +} diff --git a/apikey/net/DomainAvailabilityApi/app.config b/net/DomainAvailabilityApi/app.config similarity index 100% rename from apikey/net/DomainAvailabilityApi/app.config rename to net/DomainAvailabilityApi/app.config diff --git a/password/net/DomainAvailabilityApi/domainAvailabilityPassAuth.csproj b/net/DomainAvailabilityApi/domainAvailabilityAuth.csproj similarity index 100% rename from password/net/DomainAvailabilityApi/domainAvailabilityPassAuth.csproj rename to net/DomainAvailabilityApi/domainAvailabilityAuth.csproj diff --git a/password/net/domainAvailabilityPassAuth.sln b/net/domainAvailabilityAuth.sln similarity index 88% rename from password/net/domainAvailabilityPassAuth.sln rename to net/domainAvailabilityAuth.sln index 358dafa..eb7c165 100644 --- a/password/net/domainAvailabilityPassAuth.sln +++ b/net/domainAvailabilityAuth.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.26430.16 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domainAvailabilityPassAuth", "DomainAvailabilityApi\domainAvailabilityPassAuth.csproj", "{BC22B4C1-2E9C-4F53-B6D6-222F1E63F795}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "domainAvailabilityAuth", "DomainAvailabilityApi\domainAvailabilityAuth.csproj", "{BC22B4C1-2E9C-4F53-B6D6-222F1E63F795}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/password/nodejs/domain_availability_pass.js b/nodejs/domain_availability_pass.js similarity index 83% rename from password/nodejs/domain_availability_pass.js rename to nodejs/domain_availability_pass.js index 5bdefd8..7115646 100644 --- a/password/nodejs/domain_availability_pass.js +++ b/nodejs/domain_availability_pass.js @@ -1,13 +1,11 @@ var https = require('https'); var querystring = require('querystring'); -var url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService'; +var url = 'https://domain-availability.whoisxmlapi.com/api/v1'; var parameters = { - cmd: 'GET_DN_AVAILABILITY', domainName: 'google.com', - username: 'Your domain availability api username', - password: 'Your domain availability api password', + apiKey: 'Your domain availability api key', outputFormat: 'json' }; @@ -44,4 +42,4 @@ https.get(url, function (res) { }) }).on('error', function(e) { console.log('Error: ' + e.message); -}); \ No newline at end of file +}); diff --git a/password/net/DomainAvailabilityApi/app.config b/password/net/DomainAvailabilityApi/app.config deleted file mode 100644 index 7b25307..0000000 --- a/password/net/DomainAvailabilityApi/app.config +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/password/perl/domain_availability_pass.pl b/perl/domain_availability_pass.pl similarity index 70% rename from password/perl/domain_availability_pass.pl rename to perl/domain_availability_pass.pl index 009e534..bae6e47 100644 --- a/password/perl/domain_availability_pass.pl +++ b/perl/domain_availability_pass.pl @@ -9,20 +9,16 @@ use strict; use warnings; -my $base_url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService'; -my $cmd = 'GET_DN_AVAILABILITY'; +my $base_url = 'https://domain-availability.whoisxmlapi.com/api/v1'; my $domain_name = 'google.com'; my $format = 'json'; -my $user_name = 'Your domain availability api username'; -my $password = 'Your domain availability api password'; +my $api_key = 'Your domain availability api key'; my $url = $base_url - . '?cmd=' . uri_escape($cmd) - . '&domainName=' . uri_escape($domain_name) + . '?domainName=' . uri_escape($domain_name) . '&outputFormat=' . uri_escape($format) - . '&username=' . uri_escape($user_name) - . '&password=' . uri_escape($password); + . '&apiKey=' . uri_escape($api_key); print "Get data by URL: $url\n"; @@ -43,4 +39,4 @@ my $err = 'Empty. Something went wrong.'; print 'Domain Name: ', ($domainNameJson)? $domainNameJson: $err, "\n"; -print 'Domain Availability: ', ($availJson)? $availJson: $err, "\n"; \ No newline at end of file +print 'Domain Availability: ', ($availJson)? $availJson: $err, "\n"; diff --git a/password/php/domain_availability_api_test.php b/php/domain_availability_api_test.php similarity index 59% rename from password/php/domain_availability_api_test.php rename to php/domain_availability_api_test.php index 11bb80c..cad7f56 100644 --- a/password/php/domain_availability_api_test.php +++ b/php/domain_availability_api_test.php @@ -1,14 +1,11 @@ ErrorMessage)) { echo $res->ErrorMessage->msg; - } + } else { $domainInfo = $res->DomainInfo; if ($domainInfo) { @@ -27,4 +24,4 @@ . print_r($domainInfo->domainAvailability, 1) . PHP_EOL; } } -} \ No newline at end of file +} diff --git a/password/powershell/domain_availability_pass.ps1 b/powershell/domain_availability_pass.ps1 similarity index 51% rename from password/powershell/domain_availability_pass.ps1 rename to powershell/domain_availability_pass.ps1 index 4276667..261c0f6 100644 --- a/password/powershell/domain_availability_pass.ps1 +++ b/powershell/domain_availability_pass.ps1 @@ -1,15 +1,12 @@ -$url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService' +$url = 'https://domain-availability.whoisxmlapi.com/api/v1' -$username = 'Your domain availability api username' -$password = 'Your domain availability api password' +$apiKey = 'Your domain availability api key' $domain = 'whoisxmlapi.com' $format = 'json' $uri = $url` - + '?cmd=GET_DN_AVAILABILITY'` - + '&domainName=' + [uri]::EscapeDataString($domain)` - + '&username=' + [uri]::EscapeDataString($username)` - + '&password=' + [uri]::EscapeDataString($password)` + + '?domainName=' + [uri]::EscapeDataString($domain)` + + '&apiKey=' + [uri]::EscapeDataString($apiKey)` + '&outputFormat=' + [uri]::EscapeDataString($format) $j = Invoke-WebRequest -Uri $uri -UseBasicParsing | ` @@ -20,4 +17,4 @@ if ([bool]($j.PSObject.Properties.name -match 'DomainInfo')) { echo "Domain availability: $($j.DomainInfo.domainAvailability)" } else { echo $j -} \ No newline at end of file +} diff --git a/password/python/domain_availability_pass.py b/python/domain_availability_pass.py similarity index 84% rename from password/python/domain_availability_pass.py rename to python/domain_availability_pass.py index ad63fda..6d3dc98 100644 --- a/password/python/domain_availability_pass.py +++ b/python/domain_availability_pass.py @@ -12,15 +12,12 @@ ######################## # Fill in your details # ######################## -username = 'Your domain availability api username' -password = 'Your domain availability api password' +apiKey = 'Your domain availability api key' domain = 'google.com' -url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService?'\ - + 'cmd=GET_DN_AVAILABILITY'\ - + '&domainName=' + pathname2url(domain)\ - + '&username=' + pathname2url(username)\ - + '&password=' + pathname2url(password)\ +url = 'https://domain-availability.whoisxmlapi.com/api/v1?'\ + + '?domainName=' + pathname2url(domain)\ + + '&apiKey=' + pathname2url(apiKey)\ + '&outputFormat=' diff --git a/password/ruby/domain_availability_pass.rb b/ruby/domain_availability_pass.rb similarity index 78% rename from password/ruby/domain_availability_pass.rb rename to ruby/domain_availability_pass.rb index bdd2991..94d9b00 100644 --- a/password/ruby/domain_availability_pass.rb +++ b/ruby/domain_availability_pass.rb @@ -9,15 +9,12 @@ ######################## # Fill in your details # ######################## -username = 'Your domain availability api username' -password = 'Your domain availability api password' +apiKey = 'Your domain availability api key' domain = 'google.com' -url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService'\ - '?cmd=GET_DN_AVAILABILITY'\ - '&domainName=' + ERB::Util.url_encode(domain) + - '&username=' + ERB::Util.url_encode(username) + - '&password=' + ERB::Util.url_encode(password) + +url = 'https://domain-availability.whoisxmlapi.com/api/v1'\ + '?domainName=' + ERB::Util.url_encode(domain) + + '&apiKey=' + ERB::Util.url_encode(apiKey) + '&outputFormat=' ####################### @@ -55,4 +52,4 @@ info = (info = REXML::XPath.first(result, da_path)).nil? ? '' : info.text dom = (dom = REXML::XPath.first(result, dom_path)).nil? ? '' : dom.text puts "XML:\n---\n" + ' availability: ' + info + "\n domainName: " + dom -end \ No newline at end of file +end