Python Nominet EPP Client API

Aaron

Member
Joined
Jul 13, 2024
Posts
30
Reaction score
74
Trophy points
19
Had a message this week asking for some assistance with doing some bulk calls to Nominet and avoiding the horror show of the WDM, I've had an API which i've been using locally for a while which I shared with @Hook so thought I'd stick the repo live on Github, not here for critic or anything just sharing some code I use which may be of interest to a few people on here.

I won't be actively supporting this as a release, but have some additional plans for it. It's not the tidiest but it's functional and does me a solid most days with setting nameservers, doing renewals, and the odd hand register without the requirement of logging into Nominet. If you make a little wrapper for the API can do bulk NS updates, renewals.

 
Clifford strikes again. What a lad
 
@Aaron Thank you for developing this, it is really appreciated.

I've tested this and it works really well, all I initially needed it for was bulk changing NS1 & NS2 - however Aaron went much further. Easy to setup too.

I used python 3.7, I don't believe you needed any extra packages and it was ready to go on my home server.

I was initially prompting it over terminal with this script:


Code:
import sys
import requests
import json

def send_request(url, api_key, username, domain, ns_list):
    # Construct the payload
    data = {
        "username": username,
        "domain_name": domain,
        "nameservers": ns_list,
        "keepNS": False
    }

    headers = {
        'Content-Type': 'application/json',
        'API-Key': api_key  # Use the provided API key
    }

    try:
        response = requests.post(url, headers=headers, json=data)
        response.raise_for_status()
        print("Response:", json.dumps(response.json(), indent=2))
    except requests.exceptions.HTTPError as http_err:
        print(f"HTTP error occurred: {http_err}")
    except Exception as err:
        print(f"An error occurred: {err}")

def main():
    if len(sys.argv) < 6:
        print("Usage: python epp_client_cli.py <url> <api_key> <username> <domain> <ns1> [ns2] ...")
        sys.exit(1)

    url = sys.argv[1]
    api_key = sys.argv[2]
    username = sys.argv[3]
    domain = sys.argv[4]
    ns_list = sys.argv[5:]

    send_request(url, api_key, username, domain, ns_list)

if __name__ == "__main__":
    main()

Then the request looked like this:

python3 wrapper.py http://localhost:5000/setNS APIPassKey TAGANAME domain.com ns1.domain.com. ns2.domain.com.

This was just for initial testing. Great utility to have if you own your own TAG
 
Back
Top