Skip to main content

Python Namecheap API wrapper

Project description

Python Namecheap API wrapper for simple domain name registration and management.

NOTE: you will need API key from Namecheap to use this module (see below).


This is work in progress. Official API docs:

For now I’m trying not to use anything outside the standard library. Most methods are more or less well-documented, so don’t be shy to use help(). Type hints (PEP 484) are available for every method. Method names are NOT in 100% match with those from Namecheap, but they are more pythonic and/or hopefully make more sense.


  • domain registration/renewal
  • domain availability check
  • DNS updates
  • WHOIS information updates
  • get your domain’s information
  • get a list of your Namecheap domains
  • set/remove registrar lock

… and more.

Namecheap API

Namecheap offers two API endpoints: sandbox (for development & testing) and production (for real world). You can sign up for a free sandbox account at and activate API access at

Make sure to add your public IP address in Whitelisted IPs section.

Keep in mind that sandbox domains are not ‘real’, i.e. they exist only in Namecheap sandbox (not on the actual Web). With that you may be able to see as available for registration. At the same time, you will need to make sure to register your ‘virtual’ domains if you want to test domain-specific options, such as renewal, DNS updates, etc.


$ pip install namecheapapi

Example usage

# Initialize API
>>> from namecheapapi import DomainAPI
>>> api = DomainAPI(
...    api_user='api_user',
...    api_key='api_key,
...    username='username',  # usually the same as api_user
...    client_ip='your IP address',
...    sandbox=True,  # recommended for testing
...    coupon='coupon'  # optional

# Check availability of
>>> api.check('')
{'': False}

# Check multiple domains at once
>>> api.check(['', ''])
{'': False, '': True}

# Register a domain
>>> address = {
...    'FirstName': 'Peter',
...    'LastName': 'Griffin',
...    'Address1': '31 Spooner St.',
...    'City': 'Quahog',
...    'StateProvince': 'RI',
...    'PostalCode': '00093',
...    'Country': 'US',
...    'Phone': '+1.123456789',
...    'EmailAddress': ''
>>> api.register('', address=address)
{'NonRealTimeDomain': False, 'TransactionID': 1216215, 'WhoisGuardEnabled': False, 'Domain': '', 'OrderID': 823656, 'Success': True, 'ChargedAmount': 10.87, 'ID': 117154}

# Custom query (a raw XML response is returned)
>>> q = api.raw_query(command='', query={})
>>> print(q)
<?xml version="1.0" encoding="utf-8"?>
<ApiResponse Status="OK" xmlns="">
  <Errors />
  <Warnings />
  <CommandResponse Type="">
    <TransferGetListResult />

Implemented methods

  • domains.register (
  • domains.check (
  • domains.get_info (
  • domains.get_list (
  • domains.get_tld_list (
  • domains.renew (
  • domains.reactivate (
  • domains.get_lock (
  • domains.set_lock (
  • domains.get_nameservers (
  • domains.set_nameservers (,
  • domains.get_contacts (
  • domains.set_contacts (

Next up

  • domains.create_nameserver (
  • domains.delete_nameserver (
  • domains.update_nameserver (
  • domains.get_nameserver_info (
  • domains.get_host_records (
  • domains.set_host_records (


(does have one dependency)

  1. Install nosetests (pip install nose)
  2. Create in namecheapapi/tests/ directory, fill it in:
  • API_KEY = ‘string’ – API key that you got from Namecheap
  • API_USER = ‘string’ – your Namecheap username
  • USERNAME = ‘string’ – in most cases it would be your Namecheap username
  • CLIENT_IP = ‘string’ – your public IP address (MUST be whitelisted in your Namecheap account)
  • SANDBOX = True (recommended!)
  • COUPON = ‘string’ – coupon code if you have any, ‘’ otherwise
  • DOMAIN = ‘string’ – a domain name you ALREADY HAVE in your Namecheap account
  1. Run nosetests /path/to/namecheapapi/dir



  • minor bugfixes


  • documentation update
  • domains.get_contacts/set_contacts methods added


  • First published working version.


Alex Sanchez.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for namecheapapi, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size namecheapapi-0.2.1.tar.gz (10.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page