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

@rqt/namecheap-web

v1.5.0

Published

An API To Namecheap.com Via The Web Interface, With An Ability To Log In Using 2-Factor Auth To Whitelist IPs And Check Whois And Coupons.

Downloads

18

Readme

namecheap

@rqt/namecheap-web

npm version

@rqt/namecheap-web is an API to namecheap.com via the web interface, with an ability to log in using 2-factor Auth, check Whois and retrieve a coupon code.

The web API is currently used in the Expensive package to authenticate and white-list IP addresses. This is useful for dynamic-IP holders. Because the API implemented with gzip compression, the amount of traffic is minimized as well, helping to save data on mobile networks.

yarn add @rqt/namecheap-web

Table Of Contents

API

The package is available by importing its default class:

import NamecheapWeb from '@rqt/namecheap-web'

constructor(  options=: WebOptions,): NamecheapWeb

Create a new instance of the NamecheapWeb class. The sandbox version can be specified in the options.

  • options WebOptions (optional): Options for the web client.

To remember the session cookies on the local filesystem, the readSession parameter can be passed. On the production version, the session expires after 20 minutes, but can be renewed after 10 minutes of using an existing session.

WebOptions: Options for the web client.

/* yarn example/ */
import NamecheapWeb from '@rqt/namecheap-web'
import bosom from 'bosom'

(async () => {
  try {
    // 0. Read stored username and password from a local file.
    const { username, password } = await bosom('.auth-sandbox.json')
    const nw = new NamecheapWeb({
      sandbox: true,
      readSession: true, // save cookies in a file.
    })
    // 1. Authenticate and create a session.
    await nw.auth(username, password)

    // 2. Read white-listed IPs.
    const ips = await nw.getWhitelistedIPList()
    console.log(JSON.stringify(ips[0], null, 2))

    // 3. Whitelist a new IP.
    const ip = await NamecheapWeb.LOOKUP_IP()
    await nw.whitelistIP(ip, 'example')

    // 4. Remove white-listed IP.
    await nw.removeWhitelistedIP('example')
  } catch ({ message }) {
    console.error(message)
  }
})()

async auth(  username: string,  password: string,  phone=: string,  force=: boolean,): !Promise

Authenticate the app and obtain the cookies.

  • username* string: The username to log in with.
  • password* string: The password to enter.
  • phone string (optional): The phone number to select for 2-factor auth.
  • force boolean (optional): Try to log in even if session exists.

If 2-factor authentication is enabled, it will also be carried out. The phone argument can be passed which is the last 3 digits of the phone used to receive the confirmation text. If it is not passed, a question will be asked via the CLI. The code should be then entered in the CLI as well.

async static LOOKUP_IP(): string

Get the public IP address using https://api.ipify.org.

async static WHOIS(domain): string

Return WHOIS data for the domain.

import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.WHOIS('test.org')
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
Domain Name: test.org
Registry Domain ID: D380528-LROR
Registrar WHOIS Server: whois.psi-usa.info
Registrar URL: https://www.psi-usa.info
Updated Date: 2019-09-14T07:09:46Z
Creation Date: 1997-07-27T04:00:00Z
Registrar Registration Expiration Date: 2020-10-15T16:17:16Z
Registrar: PSI-USA, Inc. dba Domain Robot
Registrar IANA ID: 151
Registrar Abuse Contact Email: [email protected]
Registrar Abuse Contact Phone: +49.94159559482
Domain Status: clientTransferProhibited https://www.icann.org/epp#clientTransferProhibited
Registry Registrant ID: REDACTED FOR PRIVACY
Registrant Name: REDACTED FOR PRIVACY
Registrant Organization: TMT Teleservice GmbH & Co.KG
Registrant Street: REDACTED FOR PRIVACY
Registrant City: REDACTED FOR PRIVACY
Registrant State/Province: Bayern
Registrant Postal Code: REDACTED FOR PRIVACY
Registrant Country: DE
Registrant Phone: REDACTED FOR PRIVACY
Registrant Phone Ext: REDACTED FOR PRIVACY
Registrant Fax: REDACTED FOR PRIVACY
Registrant Fax Ext: REDACTED FOR PRIVACY
Registrant Email: https://contact.domain-robot.org/test.org
Registry Admin ID: REDACTED FOR PRIVACY
Admin Name: REDACTED FOR PRIVACY
Admin Organization: REDACTED FOR PRIVACY
Admin Street: REDACTED FOR PRIVACY
Admin City: REDACTED FOR PRIVACY
Admin State/Province: REDACTED FOR PRIVACY
Admin Postal Code: REDACTED FOR PRIVACY
Admin Country: REDACTED FOR PRIVACY
Admin Phone: REDACTED FOR PRIVACY
Admin Phone Ext: REDACTED FOR PRIVACY
Admin Fax: REDACTED FOR PRIVACY
Admin Fax Ext: REDACTED FOR PRIVACY
Admin Email: https://contact.domain-robot.org/test.org
Registry Tech ID: REDACTED FOR PRIVACY
Tech Name: REDACTED FOR PRIVACY
Tech Organization: REDACTED FOR PRIVACY
Tech Street: REDACTED FOR PRIVACY
Tech City: REDACTED FOR PRIVACY
Tech State/Province: REDACTED FOR PRIVACY
Tech Postal Code: REDACTED FOR PRIVACY
Tech Country: REDACTED FOR PRIVACY
Tech Phone: REDACTED FOR PRIVACY
Tech Phone Ext: REDACTED FOR PRIVACY
Tech Fax: REDACTED FOR PRIVACY
Tech Fax Ext: REDACTED FOR PRIVACY
Tech Email: https://contact.domain-robot.org/test.org
Name Server: ns0.tmt.de
Name Server: ns2.tmt.de
Name Server: ns3.tmt.de
Name Server: ns4.tmt.de
Name Server: ns1.tmt.de
DNSSEC: unsigned
URL of the ICANN WHOIS Data Problem Reporting System: https://wdprs.internic.net/
>>> Last update of WHOIS database: 2020-01-07T22:34:28Z <<<

For more information on Whois status codes, please visit https://www.icann.org/epp


# Terms and conditions:
#
# The data in the WHOIS database of PSI-USA, Inc. is provided by
# PSI-USA, Inc. for information purposes, and to assist persons in
# obtaining information about or related to a domain name registration
# record.  PSI-USA, Inc. does not guarantee its accuracy.  By submitting
# a WHOIS query, you agree that you will use this data only for lawful
# purposes and that, under no circumstances, you will use this data to
#  (1) allow, enable, or otherwise support the transmission of mass
#      unsolicited, commercial advertising or solicitations via E-mail
#      (spam); or
#  (2) enable high volume, automated, electronic processes that apply to
#      PSI-USA, Inc. or its systems.
# PSI-USA, Inc. reserves the right to modify these terms at any time.
# By submitting this query, you agree to abide by this policy.
#

async static COUPON(): string

Returns this month's coupon from the https://www.namecheap.com/promos/coupons/ page.

/* yarn example/whois.js */
import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.COUPON()
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
TLDEALZ01

async static SANDBOX_COUPON(): string

Returns this month's coupon from the https://www.sandbox.namecheap.com/promos/coupons/ page.

import NamecheapWeb from '@rqt/namecheap-web'

(async () => {
  try {
    const res = await NamecheapWeb.SANDBOX_COUPON()
    console.log(res)
  } catch ({ message }) {
    console.error(message)
  }
})()
TLDEALZ01

async getWhitelistedIPList(): !Promise>

Get a list of white-listed IP addresses which can make API calls. The maximum of 20 IP addresses is allowed.

WhitelistedIP: A white-listed IP which can be used for API calls.

async whitelistIP(  ip: string,  name=: string,): !Promise

Add an IP address to the white-listed IPs.

  • ip* string: The IP to add.
  • name string (optional): The name to save the IP as. If not given, it is automatically generated as rqt {date}.

async removeWhitelistedIP(  name: string,): !Promise

Remove the IP from the white-listed IPs by its name.

  • name* string: The name of the saved IP to remove.

Copyright