Domain Backordering using Node.js & Firebase Functions

Saaduddin M.
4 min readFeb 16, 2021

--

Have you ever spent countless hours, if not days, stalking a domain in its pendingDelete state? I have too.

You may ask why don’t I simply use one of the existing professional backorder services. Let me tell you why not.

Pricing

Here’s a quick non-exhaustive list of current players with their general backordering pricing in the market:

  • Park.io — $99
  • Pool — $60
  • NameJet — $79
  • SnapNames — $79
  • DropCatch — $59

And that’s not even it! Most providers don’t even let you have your backordered domain when they catch it. As soon as they are able to register the domain that you backordered, they list it on their own little public auction. And of course the bidders’ details are kept private so no guarantees about so called fair play there!

Delays & Misses

Surely you’d expect some sort of assurance or guarantee that they’d get your domain, but sadly, no provider has an impeccable record of success.

Zero Transparency

It might not be fair of me to list this one as a reason for not going with the traditional providers but for the compulsives like me who’d want to know and get a glance of the mechanics of what’s going on under the hood, you’d be out of luck.

All right, so hopefully that makes enough sense for us to want to take matters into our own hands, so let’s do it, let’s build our very own domain backordering service!

Costs

First things first. What would you think it would cost us to do this? The answer: $0.

That’s right! We’ll be using Google’s Cloud Functions and its generous free tier providing free invocations of 2M/month.

So that means even if you setup your script to run every minute of the day for the entire month, you’ll still have about 1.95M invocations left.

As for the domain search and registration, you can choose to get an API access of your favorite registrar and load enough funds to register your domain. Most registrars’ APIs are not explicitly rate-limited but it is good practice to keep a reasonable period of time between each call. Also make sure your registrar’s API has the option to disable IP-restricted access.

For the purpose of this topic, I’ll use Dynadot to register my domains. If you’re following along with me, get your API enabled here: https://www.dynadot.com/account/domain/setting/api.html

When that’s done, copy your Key as you’ll need to store it in our code later.

Code

Assuming you have Node.js installed and setup, create an index.js file with the following content:

const functions = require("firebase-functions");const fetch = require("node-fetch");

The “firebase-functions” package provides an SDK for defining Cloud Functions for Firebase.

“node-fetch” is a light-weight module that brings window.fetch to Node.js

const params = {key: "7w73858Q7W8v7w6q7iD8Tki6k64gN8i6m8O7U7pC7u",domain: "domainyouwant.com",duration: 1,currency: "USD"};

These are simply the self-explanatory constants that you want to work with.

const backorderFunction = () => fetch(`https://api.dynadot.com/api2.html?key=${params.key}&command=register&domain=${params.domain}&duration=${params.duration}&currency=${params.currency}`).then(res => res.text()).then(text => console.log(text));

These 8 lines are the core of our function. You can use your registrar’s API URL here and replace the variables accordingly. This function, in essence, attempts to register the given domain, if and when it is available, returns a simple error if the domain hasn’t dropped yet, and continues to run every every 5 minutes.

exports.domainBackorder = functions.runWith({ timeoutSeconds: 300, memory: "256MB" }).pubsub.schedule("every 5 minutes").onRun(async (context) => {backorderFunction();});

This part is used for deployment of the function and change runtime options.

Don’t forget to install the Firebase CLI used to deploy the function:

npm install -g firebase-tools
npm install firebase-admin

To deploy:

firebase login
firebase deploy --project name-of-your-existing-project

If you do not have a pre-existing Project in your Firebase console, you may create one here: https://console.firebase.google.com/

And voilà!

Feel free to Clone all of this here: https://github.com/saaduddin/node-backorder

--

--

Saaduddin M.
0 Followers

I’m Saad, a CS Engineer/Developer/Designer. I strive to deliver coherent and robust code & infrastructure that helps people and organizations meet their goals.