diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34977ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.idea \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..c21dad0 --- /dev/null +++ b/index.js @@ -0,0 +1,37 @@ +var unirest = require('unirest'); + +JsonWhois = { + apiKey: function (key){ + this.apiKey = key; + this.base = "http://jsonwhois.com/api/"; + return module.exports; + }, + whois : function(domain, done){ + unirest.get(this.base + 'whois') + .headers({ 'Accept': 'application/json' }) + + .query({ + "apiKey": this.apiKey, + "domain": domain + }) + + .end(function (response) { + return done(response.body); + }); + }, + screenshot: function(domain, done){ + unirest.get(this.base + 'screenshot') + .headers({ 'Accept': 'application/json' }) + + .query({ + "apiKey": this.apiKey, + "domain": domain + }) + + .end(function (response) { + return done(response.body); + }); + } +} + +module.exports = JsonWhois; \ No newline at end of file diff --git a/package.json b/package.json index 9202945..c8296c1 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "node-jsonwhois", + "name": "jsonwhois", "version": "0.0.0", "description": "A NodeJS library for the JsonWhois API.", "main": "index.js", @@ -15,5 +15,8 @@ "bugs": { "url": "https://github.com/mfasanya/node-jsonwhois/issues" }, - "homepage": "https://github.com/mfasanya/node-jsonwhois" + "homepage": "https://github.com/mfasanya/node-jsonwhois", + "dependencies": { + "unirest": "^0.2.6" + } } diff --git a/tests/test.js b/tests/test.js new file mode 100644 index 0000000..706253d --- /dev/null +++ b/tests/test.js @@ -0,0 +1,9 @@ +var JsonWhois = require('../index.js').apiKey('API KEY'); + +JsonWhois.whois("google.com", function(res){ + console.log(res); +}); + +JsonWhois.screenshot("google.com", function(res){ + console.log(res); +});