In this short lightning talk I’ll register a domain and demonstrate how to use the DNSimple NodeJS API client to register a domain name and set up the DNS needed to make it point to a web service in just a few minutes.
How to Register a Domain Using Node and the DNSimple API in 5 min

AI Generated Video Summary
Today's Talk is a demo of the DnSimple node client, including the installation process, authentication, domain availability check, and registration. The speaker emphasizes testing in the sandbox environment before moving to production. Setting up DNS records and registering domains are also covered, with the importance of verifying the code's functionality. Additional information about other clients and the DNSimple API is available at dnsimple.com/API.
1. Introduction to DnSimple Node Client
Today I'm going to give you a demo of the DnSimple node client. First, I install the DnSimple client using npm. Then I get a token from my Sandbox account to use the API. Next, I write the first bit of code to authenticate using the token. After that, I check if the domain is available and register it if it is. I pass the account ID and domain name to the client for the request.
Hello Node Congress. Today I'm going to give you a demo of the DnSimple node client 5 minutes.
First I install the DnSimple client using npm. Once that's done I need to go get a token. I'm going to get it from my Sandbox account now. This token is going to let me use the API. Once I have that token the next step is to install .env which is going to allow us to pull the token value from an environment file.
Now that's done and I have the token setup the next thing that I'm going to do is I'm going to write the first bit of code. I just want to check to make sure that I can actually authenticate using that token that I've created. As you can see it's pretty straightforward. We require the client. We're going to set the base URL to the Sandbox URL to start with so that we can do testing there. I pulled the access token from the process environment and then the next thing I'm going to do is get the account details using the client, so I've asked it who am I? It's going to give me a response and I'm going to just log that for the moment.
Now when I execute that code you'll see that it actually works and it connects to our Sandbox environment, pulls my information. Now I'm going to take the account ID store into a variable and then I'm going to use that account ID to check to see if the domain is available. Before we register a domain we need to ensure that it's available. We're going to pull the domain name from the command-line arguments. With the domain name and the account ID we're going to make a call to the client to determine if the domain is available. We're going to take the response from that call for now and just print it out to the console.
As you can see running this now with a domain name passed in for a domain that is already registered in Sandbox shows that it is not available. However running the same command for a domain that is available in Sandbox shows that the available flag is set to true. With the knowledge now whether the domain is available or not we can continue with the process and register it if it is available. So we check to see that that flag is set if it's available then we will go ahead and call the client again and register the domain. If it's not available then we'll just print a message out saying that it's not available. Calling the client is pretty straightforward you have to pass the account ID and the domain name as well as attributes for the request. The only required attribute is the registrant ID. This is your contact ID from DINSimple. This usually is going to either be added beforehand or it's something you can actually add to the API. I'm not going to demonstrate that today but there are calls for adding and managing contacts through the API. For now we're passing the ID via the command-line so we now have the domain name and the registrant ID.
2. Setting up DNS records and registering domains
Keep in mind we're still in sandbox here so we can verify that the code works as expected. Once the domain is registered, we'll see details about it. The next step is to set up the DNS records. I'll try with a different domain and register it in sandbox to ensure it works. Then, I'll do the same in production. If you'd like to learn more about our other clients and what you can do with the DNSimple API, visit dnsimple.com/API.
Keep in mind we're still in sandbox here so we can register domain names that aren't actually going to be really registered but we can verify that the code works as expected in a somewhat live environment.
Once the domain is registered we'll see a few details about it including whether auto renewals enabled, who is privacies on, as well as when it was created.
The next step now that we have a registered domain name is to set up the DNS records for it. So I'm going to set up an alias record pointing to a webflow site that I set up earlier. I'm also going to add an email forwarding entry to forward Anthony at my domain to a another email address which is my dnsimple.com email address and finally I'm going to list the records so that we can see they were all created.
Here now I'm going to try with a different domain and I'm going to go ahead and again register this in sandbox so we'll be able to see that it works as expected. Once the domain is registered you'll see the DNS records that were just created as well.
And now we're going to go on and do this in production so I'm going to remove the base URL I've updated my token and I'm going to run this same script against our production environment with the domain that I want to register flammable app.com. I'm going to use the new registrant ID for the registrant that's in production and as you can see same thing happens once the domain is registered we'll see the DNS information about it.
And now if I go in and I open the domain you can see it's actually registered inside of dnsimple.com and I can open the domain in a browser and go straight to the website that I created earlier in webflow and you can see that the custom domain is working as expected.
I hope that you've enjoyed this talk about the DNSimple API. If you'd like to learn more about our other clients as well as what you can do with the DNSimple API visit dnsimple.com slash API.
Comments