Skip to content

Commit

Permalink
Fixes, readme edits.
Browse files Browse the repository at this point in the history
  • Loading branch information
whoisxmlapi committed Jul 16, 2018
1 parent f3cd7d1 commit 34e7a4e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 32 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
[Whois](https://www.whoisxmlapi.com/whois-api-doc.php) records for a
list of Domains/IPs via a single REST API query.

Here you'll find examples of using the API implemented in multiple languages.
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)
You'll need a
[WhoisXmlApi account](https://www.whoisxmlapi.com/user/create.php)
to authenticate.

Please, refer to the
[Bulk Whois API User Guide](https://www.whoisxmlapi.com/bulk-whois-api-userguide.php) for
info on input parameters, request/response formats and more.
[Bulk Whois API User Guide](https://www.whoisxmlapi.com/bulk-whois-api-userguide.php)
for info on input parameters, request/response formats, authentication
instructions and more.
28 changes: 0 additions & 28 deletions node/bulk.search.js

This file was deleted.

57 changes: 57 additions & 0 deletions node/bulk_whois_api_sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var fs = require('fs'), https = require('https');

var dom = ['google.com', 'youtube.com', 'facebook.com', 'whoisxmlapi.com'];
var srv = 'www.whoisxmlapi.com', url = '/BulkWhoisLookup/bulkServices/';
var username = 'Your bulk whois api username';
var pass = 'Your bulk whois api password';
var file = 'bulk.csv';

function api(path, data, callback)
{
var baseData = {
password: pass,
username: username,
outputFormat: 'json'
};

var body = '';
var opts = {
host: srv,
path: url + path,
method:'POST',
headers: {'Content-Type': 'application/json'}
};

https.request(opts, function(response) {
response.on('data', function(chunk) {
body += chunk;
});
response.on('end', function() {
callback(body);
});
}).end(JSON.stringify(Object.assign({}, baseData, data)));
}

// This will save whois record info for all domains as 'bulk.csv' in current
// directory.

api('bulkWhois', {domains:dom}, function(body) {
var id = {
requestId: JSON.parse(body).requestId,
startIndex: dom.length + 1
};
var timer = setInterval(function() {
api('getRecords', Object.assign({},id,{maxRecords:0}),function(body) {
if (JSON.parse(body).recordsLeft) {
return;
}
clearInterval(timer);
if (typeof JSON.parse(body).recordsLeft === 'undefined') {
return;
}
api('download', id, function(csv) {
fs.writeFile(file,csv);
});
});
}, 3000);
});
File renamed without changes.
File renamed without changes.

0 comments on commit 34e7a4e

Please sign in to comment.