Skip to content

Commit

Permalink
Add unirest
Browse files Browse the repository at this point in the history
  • Loading branch information
mfasanya committed May 2, 2014
1 parent fe67775 commit 4d10b07
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
37 changes: 37 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -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;
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "node-jsonwhois",
"name": "jsonwhois",
"version": "0.0.0",
"description": "A NodeJS library for the JsonWhois API.",
"main": "index.js",
Expand All @@ -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"
}
}
9 changes: 9 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -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);
});

0 comments on commit 4d10b07

Please sign in to comment.