Search code examples
pythondjangonamecheap

PyNamecheap update the contact info


recently I'm using PyNamecheap to register domains as it's registering, but I want to configure my domain contacts information for each Registrant, Administrative, Technical and Billing user.

but it doesn't provide the option as looked into their code they are just looping through users contact_types = ['Registrant', 'Tech', 'Admin', 'AuxBilling'] and creating with the same details for all account types. and also there isn't any update userinfo method or anything.

is there any way to update or customize them while creation and also later to update.


Solution

  • As Namecheap Docs says. It's just sending a get request as

    https://api.sandbox.namecheap.com/xml.response?ApiUser=myuser&ApiKey=mykey&UserName=myuser&Command=namecheap.domains.setContacts&ClientIp=116.204.161.41&DomainName=mycooldomainxyz123.com&AuxBillingFirstName=Daisy&AuxBillingLastName=Smith&AuxBillingAddress1=8939%20S.cross%20Blvd&AuxBillingCity=califonia&AuxBillingOrganizationName=Org1&AuxBillingStateProvince=CA&AuxBillingPostalCode=90045&AuxBillingCountry=US&AuxBillingPhone=+1.6613102107&AuxBillingEmailAddress=john@gmail.com&TechFirstName=Daisy&TechLastName=Smith&TechAddress1=8939%20S.cross%20Blvd&TechStateProvince=CA&TechCity=california&TechPostalCode=90045&TechOrganizationName=Org1&TechCountry=US&TechPhone=+1.6613102107&TechEmailAddress=john@gmail.com&AdminFirstName=Daisy&AdminLastName=Smith&AdminAddress1=8939%20S.cross%20Blvd&AdminStateProvince=CA&AdminPostalCode=90045&AdminOrganizationName=org1&AdminCountry=US&AdminPhone=+1.6613102107&AdminCity=california&AdminEmailAddress=john@gmail.com&RegistrantFirstName=Daisy&RegistrantLastName=Smith&RegistrantAddress1=8939%20S.cross%20Blvd&RegistrantStateProvince=CA&RegistrantPostalCode=90045&RegistrantCountry=US&RegistrantPhone=+1.6613102107&RegistrantEmailAddress=john@gmail.com&RegistrantCity=california&RegistrantOrganizationName=Org1
    

    it may looks messy but it isn't. just set your params ApiUser, ApiKey, UserName, Command, ClientIp, DomainName and other parameters as you needed to implement your task.

    in my views.py you have to do something like this

    import requests
    
    url = "above-url"
    result = requests.get(url)
    
    print(result) 
    

    Note: the result is in XML format and you could use lxml.etree to parse and read it. it may helps you for parsing xml. How to get XML tag value in Python