pax_global_header 0000666 0000000 0000000 00000000064 13231726634 0014521 g ustar 00root root 0000000 0000000 52 comment=429e6e9b894f1d91e93aa643925908fa58b2a41a
PyNamecheap-0.0.3/ 0000775 0000000 0000000 00000000000 13231726634 0013713 5 ustar 00root root 0000000 0000000 PyNamecheap-0.0.3/.gitignore 0000664 0000000 0000000 00000000515 13231726634 0015704 0 ustar 00root root 0000000 0000000 env
credentials.py
.DS_Store
*.py[cod]
# C extensions
*.so
# Packages
*.egg
*.egg-info
dist
build
eggs
parts
bin
var
sdist
develop-eggs
.installed.cfg
lib
lib64
# Installer logs
pip-log.txt
# Unit test / coverage reports
.coverage
.tox
nosetests.xml
# Translations
*.mo
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
PyNamecheap-0.0.3/LICENSE.txt 0000664 0000000 0000000 00000002070 13231726634 0015535 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2016 Bemmu Sepponen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
PyNamecheap-0.0.3/README.md 0000664 0000000 0000000 00000012471 13231726634 0015177 0 ustar 00root root 0000000 0000000 Namecheap API for Python
===========
PyNamecheap is a Namecheap API client in Python.
API itself is documented at
This client supports:
- Registering a domain
- Checking domain name availability
- Listing domains you have registered
- Getting contact information for a domain
- Setting DNS info to default values
- Set DNS host records
### Installation
Thanks to @inomoz, as simple as:
```
pip install PyNamecheap
```
### How to sign up to start using the API
The API has two environments, production and sandbox. Since this API will spend real money when registering domains, start with the sandbox by going to and creating an account. Accounts between production and sandbox are different, so even if you already have a Namecheap account you will need a new one.
After you have an account, go to "Profile".

From there, select the "Profile" menu again, then "Tools". Scroll to the bottom of the page to the "Business & Dev Tools" and select "Manage" on the "Namecheap API Access" section.

You'll get to your credentials page. From here you need to take note of your api key, username and add your IP to the whitelist of IP addresses that are allowed to access the account. You can check your public IP by searching "what is my ip" on Google and add it here. It might take some time before it actually starts working, so don't panic if API access doesn't work at first.

### How to access the API from Python
Copy namecheap.py to your project. In Python you can access the API as follows:
from namecheap import Api
api = Api(username, api_key, username, ip_address, sandbox = True)
The fields are the ones which appear in the credentials screen above. The username appears twice, because you might be acting on behalf of someone else.
### Registering a domain name using the API
Unfortunately you need a bunch of contact details to register a domain, so it is not as easy as just providing the domain name. In the sandbox, the following contact details are acceptable. Trickiest field is the phone number, which has to be formatted as shown.
api.domains_create(
DomainName = 'registeringadomainthroughtheapiwow.com',
FirstName = 'Jack',
LastName = 'Trotter',
Address1 = 'Ridiculously Big Mansion, Yellow Brick Road',
City = 'Tokushima',
StateProvince = 'Tokushima',
PostalCode = '771-0144',
Country = 'Japan',
Phone = '+81.123123123',
EmailAddress = 'jack.trotter@example.com'
)
This call should succeed in the sandbox, but if you use the API to check whether this domain is available after registering it, the availability will not change. This is normal.
### How to check if a domain name is available
The domains_check method returns True if the domain is available.
api.domains_check(domain_name)
You can also pass a list of domain names, in which case it does a batch check for all and returns a dictionary of the answers.
You should probably not be writing a mass domain checking tool using this, it is intended to be used before registering a domain.
### CLI tool usage
First, you need to edit `./credentials.py` file to provide API access for the script. The example is following:
#!/usr/bin/env python
api_key = '0123456789abcdef0123456789abcdef'
username = 'myusername'
ip_address = '10.0.0.1'
Then you just call the script with desired arguments:
./namecheap-api-cli --domain example.org --list
./namecheap-api-cli --domain example.org --add --type "A" --name "test" --address "127.0.0.1" --ttl 300
./namecheap-api-cli --domain example.org --add --type "CNAME" --name "alias-of-test" --address "test.example.org." --ttl 1800
./namecheap-api-cli --domain example.org --delete --type "CNAME" --name "alias-of-test" --address "test.example.org."
./namecheap-api-cli --domain example.org --delete --type "A" --name "test" --address "127.0.0.1"
### Basic host records management code
Here's the example of simple DNS records management script:
#!/usr/bin/env python
"""
Define variables regarding to your API account:
- api_key
- username
- ip_address
"""
api = Api(username, api_key, username, ip_address, sandbox=False)
domain = "example.org"
# list domain records
api.domains_dns_getHosts(domain)
record = {
# required
"Type": "A",
"Name": "test1",
"Address": "127.0.0.1",
# optional
"TTL": "1800",
"MXPref": "10"
}
# add A "test1" record pointing to 127.0.0.1
api.domains_dns_addHost(domain, record)
# delete record we just created,
# selecting it by Name, Type and Address values
api.domains_dns_delHost(domain, record)
### Retry mechanism
Sometimes you could face wrong API responses, which are related to server-side errors.
Thanks to @gstein, we implemented retry mechanism, one could enable it by adding 2 parameters to Api instance:
```
api = Api(username, api_key, username, ip_address, sandbox=False,
attempts_count=3,
attempts_delay=0.1)
```
Values of 2 or 3 should do the thing.
### More
Look at namecheap_tests.py to see more examples of things you can do.
PyNamecheap-0.0.3/img/ 0000775 0000000 0000000 00000000000 13231726634 0014467 5 ustar 00root root 0000000 0000000 PyNamecheap-0.0.3/img/apimenu.png 0000664 0000000 0000000 00000120616 13231726634 0016641 0 ustar 00root root 0000000 0000000 PNG
IHDR } g gAMA a @ IDATxx\Gv5rD"$)9M3]kߵߏxrF)Y D9y&0 M
ݸn{֭Ω*&'l?ݐ@__?/^+nzMPJ@ (%P3%`8yVJ@ (%PSrPw1\<EXBCcN>sB6ƛشq#VX7xK.1-\>أ`ٲO^*EhX(~;moģ7hoo/.\}gΞΝh_ħA (%PJ@ %=#؈V[(,,:WSO`L\<SaxҰR#< "jjjwLܴ}?ċ/ oy7oġCP$E
\.iPJ@ (%P7C@EPc:t䘾_u444@#232,V;iaP_/0.]8+B
b{ >>aaU+/GXSR(sF֎_6tRDGG#!!XﺛVJ@ (%u6=i>;~⤸U>իW/?)l,k_~ٚK_PpvޫC~y7qysEGFf=/o/dg/îݻEٌ\$35%
FHҝ;.8Lff|7%PJ@ (Wl\_Mܦ{vq3\~sNXef^Xdql^n^qL_Ќ
2c蚹mR%%%aAbD,b!;gOo/{/DOOOXj%jpA2oL9!8KVVR5ˤJ@ (%Ps_K`b} ٝio]}\ (%PJ@ 85K >ҥPPJ@ (%Pw7kD_rrMd便&Γh6PJ@ (%&kD_t&9u d%PJ@ (%nSDI9O<>OrPJ@ (%PJ`}2'5<
7eOw;S7v@`pHD-?8uI"ގN&