domainr-api
This is simple and lightweight NodeJS wrapper for Domainr API V2. All methods are returning Promises!
Requirements
For using this library, you will need Mashape Key (How to get free mashape key?). You will can use 10000 request for free each month!
Package requires NodeJS version >= 4.0.0
Installation
To install domainr-api
, run:
npm install domainr-api --save
Usage
Domainr-api class comes with three main methods. Methods always return a promise.
Methods are:
Initialization
To initialize domainr-api class, you need to pass your Mashape key.
let domainrApi = new domainr('some-key');
Search method
Search method let's you search for domain. You will get results
array with some domain recommendations.
It accepts these arguments:
Parameter | Required | Type | Description | Example |
---|---|---|---|---|
query | Yes | String | Term(s) to search against. | acme cafe |
location | No | String | Optionally override the IP location detection for country-code zones, with a two-character country code. | de |
registrar | No | String | The domain name of a specific registrar to filter results by that registrar’s supported list of extensions (optional). | namecheap.com |
defaults | No | String | Optional comma-separated list of default zones to include in the response. | bike,cab |
Example request:
let searchObj = {
defaults: 'club,coffee',
location: 'de',
query: 'acme cafe',
registrar: 'namecheap.com'
};
let domainrApi = new domainr('some-key');
domainrApi
.search(searchObj)
.then(data => console.log(data))
.catch(err => console.log(err));
Data returned
[
{
"domain": "acme.coffee",
"host": "",
"subdomain": "acme.",
"zone": "coffee",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acme.coffee®istrar=namecheap.com&source=api"
},
{
"domain": "acme.kitchen",
"host": "",
"subdomain": "acme.",
"zone": "kitchen",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acme.kitchen®istrar=namecheap.com&source=api"
},
{
"domain": "acme.restaurant",
"host": "",
"subdomain": "acme.",
"zone": "restaurant",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acme.restaurant®istrar=namecheap.com&source=api"
},
{
"domain": "acmecafe.de",
"host": "",
"subdomain": "acmecafe.",
"zone": "de",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.de®istrar=namecheap.com&source=api"
},
{
"domain": "acmecafe.com",
"host": "",
"subdomain": "acmecafe.",
"zone": "com",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.com®istrar=namecheap.com&source=api"
},
{
"domain": "acmecafe.net",
"host": "",
"subdomain": "acmecafe.",
"zone": "net",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.net®istrar=namecheap.com&source=api"
},
{
"domain": "acmecafe.org",
"host": "",
"subdomain": "acmecafe.",
"zone": "org",
"path": "",
"registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.org®istrar=namecheap.com&source=api"
}
]
Status method
Status method gives you status for each domain you send in array. You will get status
array with domain information.
It has limit to 10 domains per call.
It accepts these arguments:
Parameter | Required | Type | Description | Example |
---|---|---|---|---|
domains | Yes | Array of strings | Array of domains to check | ['acme.coffee', 'acmecafe.com'] |
Example request:
let domains = ['ace.coffee', 'acecafe.com', 'acecafe.net', 'acecafe.co', 'acecafe.io'];
let domainrApi = new domainr('some-key');
domainrApi
.status(domains)
.then(data => console.log(data))
.catch(err => console.log(err));
Data returned
[
{
"domain": "acecafe.net",
"zone": "net",
"status": "active",
"summary": "active"
},
{
"domain": "acecafe.com",
"zone": "com",
"status": "active",
"summary": "active"
},
{
"domain": "acecafe.co",
"zone": "co",
"status": "active",
"summary": "active"
},
{
"domain": "ace.coffee",
"zone": "coffee",
"status": "undelegated active",
"summary": "active"
},
{
"domain": "acecafe.io",
"zone": "io",
"status": "undelegated inactive",
"summary": "inactive"
}
]
Register method
Register method gives generated URL that redirects user to checkout page. It's sent as a string.
It accepts these arguments:
Parameter | Required | Type | Description | Example |
---|---|---|---|---|
domain | Yes | String | Domain name. | example.com |
registrar | No | String | Registrar domain name | namecheap.com |
Example request:
let domainrApi = new domainr('some-key');
domainrApi
.register('example.com')
.then(data => console.log(data))
.catch(err => console.log(err));
Data returned
https://www.shareasale.com/r.cfm?b=210737&m=25581&u=303669&urllink=https%3A%2F%2Fiwantmyname.com%2Fsearch%2Fadd%2Fexample.com%3Fr%3Ddomai.nr
Official documentation
Official Domainr documentation can be found on: http://domainr.build/docs
Author
Author of the package is Ivan Jovanovic.
Future
I have couple things in mind for the future:
-
Add Register method to the class - Create a ChatBot that will easily search/check/register domains
Started working on chatbot on https://github.com/IvanJov/domain-bot