Giter VIP home page Giter VIP logo

namecheapapi's Introduction

namecheap-api Build Status npm

NodeJS library to make Namecheap API requests

Getting Started

Namecheap has an unfriendly and unsightly XML API. This library makes it easier for you to call on Namecheap's API without the hassle!

To start, set your Namecheap global parameters. These parameters are required for every API call you make to Namecheap. These parameters are:

  • ApiUser - Username required of the account accessing the API.
  • ApiKey - Password required of the account accessing the API.
  • ClientIp - IP address of the client accessing your API that uses this Namecheap API library

Since the ApiUser and UserName parameters tend to be the same, if you fill in either property, the other will automatically be filled in as well. However, should you want to fill in such parameters with different values, you can do that as well by manually setting them.

The CommandName global parameter will be automatically filled in as you use this library, so don't worry about it and do not try setting it!

After filling the global parameters in, you can now make API calls to Namecheap!

Setting Global Parameters

To set the Namecheap global parameters, do the following. Remember to set all your Namecheap global parameters!

var namecheapApi = require('namecheap-api');

namecheapApi.config.set("ApiUser", "YourUsernameHere");

Response and the Response Structure

namecheap-api's apiCall functionality always returns a promise response with 3 properties: requestUrl, requestPayload and response.

response holds an Error object if there are XML parsing/network errors or if Namecheap returns an ERROR (with the promise, rejected). response holds the parsed XML (turned into an object) if there are no XML parsing/network errors AND Namecheap returns an OK (with the promise, resolved). The parsed XML object is obtained using xml2js. A StackOverflow article of how the output is like can be viewed here.

var namecheapApi = require('namecheap-api');

// If there are no XML parsing/network errors and Namecheap returns an OK
namecheapApi.apiCall("SomeCommand", {}).then(function (data) {
    console.log(data.requestUrl);
    console.log(data.requestPayload);
    console.log(data.response); // data.response is the parsed response
});

// If there are XML parsing/network errors OR Namecheap returns an ERROR
namecheapApi.apiCall("SomeCommand", {}).catch(function (data) {
    console.log(data.requestUrl);
    console.log(data.requestPayload);
    console.log(data.response); // data.response is an Error object
});

Sandbox mode

You can now use Namecheap API's sandbox mode within namecheap-api! Whenever using the apiCall function, if you want to use Namecheap's sandbox server, just make sure to pass in true as third parameter.

namecheapApi.apiCall("SomeCommand", {}, true);

Web proxy

namecheap-api uses the request module to make api calls which will obey the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables. To specify a specific proxy for Namecheap API calls only you can set the "Proxy" config variable.

namecheapApi.config.set("Proxy", "http://user:[email protected]:80");

namecheapapi's People

Contributors

alastairparagas avatar jeremy-brenner avatar mesrop avatar megheaiulian avatar atlanteh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.