How to Register a Domain Using Node and the DNSimple API in 5 min

Rate this content
Bookmark

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.

6 min
17 Feb, 2022

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

Short description:

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

Short description:

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.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
React Advanced Conference 2021React Advanced Conference 2021
19 min
Automating All the Code & Testing Things with GitHub Actions
Code tasks like linting and testing are critical pieces of a developer’s workflow that help keep us sane like preventing syntax or style issues and hardening our core business logic. We’ll talk about how we can use GitHub Actions to automate these tasks and help keep our projects running smoothly.
DevOps.js Conf 2022DevOps.js Conf 2022
33 min
Fine-tuning DevOps for People over Perfection
Demand for DevOps has increased in recent years as more organizations adopt cloud native technologies. Complexity has also increased and a "zero to hero" mentality leaves many people chasing perfection and FOMO. This session focusses instead on why maybe we shouldn't adopt a technology practice and how sometimes teams can achieve the same results prioritizing people over ops automation & controls. Let's look at amounts of and fine-tuning everything as code, pull requests, DevSecOps, Monitoring and more to prioritize developer well-being over optimization perfection. It can be a valid decision to deploy less and sleep better. And finally we'll examine how manual practice and discipline can be the key to superb products and experiences.
Node Congress 2022Node Congress 2022
34 min
Out of the Box Node.js Diagnostics
In the early years of Node.js, diagnostics and debugging were considerable pain points. Modern versions of Node have improved considerably in these areas. Features like async stack traces, heap snapshots, and CPU profiling no longer require third party modules or modifications to application source code. This talk explores the various diagnostic features that have recently been built into Node.
You can check the slides for Colin's talk here. 

Workshops on related topic

Node Congress 2023Node Congress 2023
109 min
Node.js Masterclass
Workshop
Have you ever struggled with designing and structuring your Node.js applications? Building applications that are well organised, testable and extendable is not always easy. It can often turn out to be a lot more complicated than you expect it to be. In this live event Matteo will show you how he builds Node.js applications from scratch. You’ll learn how he approaches application design, and the philosophies that he applies to create modular, maintainable and effective applications.

Level: intermediate
Node Congress 2023Node Congress 2023
63 min
0 to Auth in an Hour Using NodeJS SDK
WorkshopFree
Passwordless authentication may seem complex, but it is simple to add it to any app using the right tool.
We will enhance a full-stack JS application (Node.JS backend + React frontend) to authenticate users with OAuth (social login) and One Time Passwords (email), including:- User authentication - Managing user interactions, returning session / refresh JWTs- Session management and validation - Storing the session for subsequent client requests, validating / refreshing sessions
At the end of the workshop, we will also touch on another approach to code authentication using frontend Descope Flows (drag-and-drop workflows), while keeping only session validation in the backend. With this, we will also show how easy it is to enable biometrics and other passwordless authentication methods.
Table of contents- A quick intro to core authentication concepts- Coding- Why passwordless matters
Prerequisites- IDE for your choice- Node 18 or higher
JSNation 2023JSNation 2023
104 min
Build and Deploy a Backend With Fastify & Platformatic
WorkshopFree
Platformatic allows you to rapidly develop GraphQL and REST APIs with minimal effort. The best part is that it also allows you to unleash the full potential of Node.js and Fastify whenever you need to. You can fully customise a Platformatic application by writing your own additional features and plugins. In the workshop, we’ll cover both our Open Source modules and our Cloud offering:- Platformatic OSS (open-source software) — Tools and libraries for rapidly building robust applications with Node.js (https://oss.platformatic.dev/).- Platformatic Cloud (currently in beta) — Our hosting platform that includes features such as preview apps, built-in metrics and integration with your Git flow (https://platformatic.dev/). 
In this workshop you'll learn how to develop APIs with Fastify and deploy them to the Platformatic Cloud.
JSNation Live 2021JSNation Live 2021
156 min
Building a Hyper Fast Web Server with Deno
WorkshopFree
Deno 1.9 introduced a new web server API that takes advantage of Hyper, a fast and correct HTTP implementation for Rust. Using this API instead of the std/http implementation increases performance and provides support for HTTP2. In this workshop, learn how to create a web server utilizing Hyper under the hood and boost the performance for your web apps.
React Summit 2022React Summit 2022
164 min
GraphQL - From Zero to Hero in 3 hours
Workshop
How to build a fullstack GraphQL application (Postgres + NestJs + React) in the shortest time possible.
All beginnings are hard. Even harder than choosing the technology is often developing a suitable architecture. Especially when it comes to GraphQL.
In this workshop, you will get a variety of best practices that you would normally have to work through over a number of projects - all in just three hours.
If you've always wanted to participate in a hackathon to get something up and running in the shortest amount of time - then take an active part in this workshop, and participate in the thought processes of the trainer.