Skip to content

rqt/namecheap

Repository files navigation

namecheap

@rqt/namecheap

npm version

@rqt/namecheap is an implementation of the namecheap.com API.

yarn add @rqt/namecheap

Table Of Contents

API

The package is available by importing its default function:

import NameCheap from '@rqt/namecheap'

constructor(
  options: Options,
): void

Create a new instance of the NameCheap class.

Options: Options for the NameCheap client.

Name Type Description Default
user* string The username required to access the API. -
key* string The password required used to access the API. -
ip* string The IP address of the client accessing the application (End-user IP address). -
sandbox boolean Whether to use the sandbox version of the API. false
import NameCheap from '@rqt/namecheap'
import bosom from 'bosom'

(async () => {
  try {
    // 0. Create a client.
    const { user, key, ip } = await bosom('.namecheap.json')
    const namecheap = new NameCheap({
      user, key, sandbox: true, ip,
    })

    // 1. Check a domain.
    const c = await namecheap.domains.check('test.co')
    console.log('Check:', c, '\n')

    // 2. Get list of addresses on the account.
    const cc = await namecheap.address.getList()
    console.log('Addresses:', cc, '\n')

    // 3. Find the default address and get its info.
    const { AddressId } = cc.find(({ IsDefault }) => IsDefault)
    const address = await namecheap.address.getInfo(AddressId)

    // 4. Register the domain using the address.
    const d = new Date().toLocaleString().replace(/[ :]/g, '-')
    const domain = `rqt-example-${d}.com`
    const r = await namecheap.domains.create({
      domain,
      address,
    })
    console.log('Registered:', r, '\n')

    // 5. Retrieve info about domain.
    const info = await namecheap.domains.getInfo(domain)
    console.log('Info:', info, '\n')

    // 6. Get a list of domains (with filter).
    const list = await namecheap.domains.getList({
      filter: domain,
    })
    console.log('List:', list, '\n')
  } catch (err) {
    console.log(err)
  }
})()
Check: [ { Domain: 'test.co',
    Available: false,
    ErrorNo: 0,
    Description: '',
    IsPremiumName: false,
    PremiumRegistrationPrice: 0,
    PremiumRenewalPrice: 0,
    PremiumRestorePrice: 0,
    PremiumTransferPrice: 0,
    IcannFee: 0,
    EapFee: '0.0' } ] 

Addresses: [ { AddressId: 0,
    AddressName: 'Primary Address',
    IsDefault: false },
  { AddressId: 101235,
    AddressName: 'Planet Express',
    IsDefault: true } ] 

Registered: { Domain: 'rqt-example-2019-8-2-02-13-44.com',
  Registered: true,
  ChargedAmount: '9.0600',
  DomainID: 429348,
  OrderID: 1549920,
  TransactionID: 2120538,
  WhoisguardEnable: true,
  FreePositiveSSL: false,
  NonRealTimeDomain: false } 

Info: { Status: 'Ok',
  ID: 429348,
  DomainName: 'rqt-example-2019-8-2-02-13-44.com',
  OwnerName: 'zavr',
  IsOwner: true,
  IsPremium: false,
  DomainDetails: 
   { CreatedDate: '08/01/2019',
     ExpiredDate: '08/01/2020',
     NumYears: 0 },
  Whoisguard: 
   { Enabled: 'True',
     ID: 351830,
     ExpiredDate: '08/01/2020',
     EmailDetails: 
      { WhoisGuardEmail: '9bf5db38cf0a41cfa4b94223080e4a9f.protect@whoisguard.com',
        ForwardedTo: 'zoidberg@futurama.bz',
        LastAutoEmailChangeDate: '',
        AutoEmailChangeFrequencyDays: 3 } },
  PremiumDnsSubscription: 
   { UseAutoRenew: false,
     SubscriptionId: -1,
     CreatedDate: 0000-12-31T21:00:00.000Z,
     ExpirationDate: 0000-12-31T21:00:00.000Z,
     IsActive: false },
  DnsDetails: 
   { ProviderType: 'FREE',
     IsUsingOurDNS: true,
     HostCount: 2,
     EmailType: 'FWD',
     DynamicDNSStatus: false,
     IsFailover: false,
     Nameserver: [ 'dns1.registrar-servers.com', 'dns2.registrar-servers.com' ] },
  Modificationrights: { All: true } } 

List: { domains: 
   [ { ID: 429348,
       Name: 'rqt-example-2019-8-2-02-13-44.com',
       User: 'zavr',
       Created: '08/01/2019',
       Expires: '08/01/2020',
       IsExpired: false,
       IsLocked: false,
       AutoRenew: false,
       WhoisGuard: 'ENABLED',
       IsPremium: false,
       IsOurDNS: true } ],
  TotalItems: 1,
  CurrentPage: 1,
  PageSize: 20 }

domains

Methods to check availability, register and retrieve account domains' info. 🎟Read Domains Wiki

users

Methods related to the user. 👩‍💻Read Users Wiki

address

Methods to manipulate addresses. In contrast to the NameCheap API, it does not fall under the group users. 🏡Read Address Wiki

dns

Methods to work with DNS records, such as getting a list of current hosts, and setting a new list. 🗺Read DNS Wiki

Progress

  • domains: 4/11
  • domains.dns: 2/7
  • domains.ns: 0/4
  • domains.transfer: 0/4
  • ssl: 0/13
  • users: 1/9
  • users.address: 2/6
  • whoisguard: 0/8

9/62 = 15%

Copyright

(c) Rqt 2019

About

An implementation of the namecheap.com API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published