Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including domainr-api with all npm packages installed. Try it out:

var domainrApi = require("domainr-api")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

domainr-api v1.2.1

Unofficial Domainr API client for NodeJS

domainr-api

npm version npm downloads Build Status License: MIT

This is simple and lightweight NodeJS wrapper for Domainr API V2. All methods are returning Promises!

  1. Requirements
  2. Instalation
  3. Usage
    1. Initialization
    2. Search method
    3. Status method
    4. Register method
  4. Official documentation
  5. Author
  6. Future

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:

ParameterRequiredTypeDescriptionExample
queryYesStringTerm(s) to search against.acme cafe
locationNoStringOptionally override the IP location detection for country-code zones, with a two-character country code.de
registrarNoStringThe domain name of a specific registrar to filter results by that registrar’s supported list of extensions (optional).namecheap.com
defaultsNoStringOptional 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&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acme.kitchen",
      "host": "",
      "subdomain": "acme.",
      "zone": "kitchen",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acme.kitchen&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acme.restaurant",
      "host": "",
      "subdomain": "acme.",
      "zone": "restaurant",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acme.restaurant&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acmecafe.de",
      "host": "",
      "subdomain": "acmecafe.",
      "zone": "de",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.de&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acmecafe.com",
      "host": "",
      "subdomain": "acmecafe.",
      "zone": "com",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.com&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acmecafe.net",
      "host": "",
      "subdomain": "acmecafe.",
      "zone": "net",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.net&registrar=namecheap.com&source=api"
    },
    {
      "domain": "acmecafe.org",
      "host": "",
      "subdomain": "acmecafe.",
      "zone": "org",
      "path": "",
      "registerURL": "https://api.domainr.com/v2/register?&domain=acmecafe.org&registrar=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:

ParameterRequiredTypeDescriptionExample
domainsYesArray of stringsArray 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:

ParameterRequiredTypeDescriptionExample
domainYesStringDomain name.example.com
registrarNoStringRegistrar domain namenamecheap.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:

  • [x] Add Register method to the class
  • [x] Create a ChatBot that will easily search/check/register domains

Started working on chatbot on https://github.com/IvanJov/domain-bot

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free