Name Cheap API Key Boiler Plate Code - gamesharkmike/PyNamecheap GitHub Wiki
home
# Set API key for sandbox or production
prod_key = "my_production_env_api_Key"
sand_key = "my_sandbox_env_api_Key"
api_key = sand_key
api_key = prod_key# Comment out for sandbox,leave4prod
ip = "my_ip_address"
# Set API object
username = "gamesharkmike"
from namecheap import Api
if api_key == prod_key:
api = Api(username, api_key, username, ip, sandbox = False)
elif api_key == sand_key:
api = Api(username, api_key, username, ip, sandbox = True)
if api_key == sand_key:
domain = "example.com"
elif api_key == prod_key:
domain = input("Domain> ")
hosts = api.domains_dns_getHosts(domain)
LIST = []
for host in hosts:
LIST.append("{} ({})".format(host['Name'], host["Address"]) )
print(" ,".join(LIST))