npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

namecheap-api

v1.0.5

Published

Node.JS library for the Namecheap API

Downloads

693

Readme

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");