How to detect expiring domains
In this guide we will use Skybear.NET to check the expiration date for multiple domains and ensure we get notified if any expires in less than 60 days.
Nobody likes their domain expiring, so let’s get to work.
Domain expiration check script
We are going to use the whois-api6 API to get domain information, but feel free to use your favourite Whois API.
The RAPIDAPI_WHOISAPI6_KEY
below is the secret API key for the whois-api6
API stored as a secret and automatically available as a Hurl variable.
### DOMAINS Expiration checker #####################################
POST https://whois-api6.p.rapidapi.com/whois/api/v1/getDataX-Rapidapi-Key: {{ RAPIDAPI_WHOISAPI6_KEY }}Content-Type: application/json{"query":"lambrospetrou.com"}HTTP 200[Asserts]jsonpath "$.result.expiration_date" toDate "%Y-%m-%d %H:%M:%S" daysAfterNow > 60jsonpath "$.result.domain_name" == "LAMBROSPETROU.COM"
POST https://whois-api6.p.rapidapi.com/whois/api/v1/getDataX-Rapidapi-Key: {{ RAPIDAPI_WHOISAPI6_KEY }}Content-Type: application/json{"query":"skybear.net"}HTTP 200[Asserts]jsonpath "$.result.expiration_date" toDate "%Y-%m-%d %H:%M:%S" daysAfterNow > 60jsonpath "$.result.domain_name" == "SKYBEAR.NET"
# ... continue with the rest of your domains
The expiration_date
property is what we care about and the assertion ensures that we have at least 60 days before the domain expires.
We use the daysAfterNow
filter (see docs) that compares a given date in the future with the present.
We also assert the domain_name
as sanity check that we got the information for the correct domain.
When the script runs and notices that the certificate expires in less than 60 days, it will fail with an error similar to below:
error: Assert failure --> ./s_nDgctVsjHnsfz6QtqB61RZN-lbBvX5VXX52f.hurl:12:0 | | POST https://whois-api6.p.rapidapi.com/whois/api/v1/getData | ... 12 | jsonpath "$.result.expiration_date" toDate "%Y-%m-%d %H:%M:%S" daysAfterNow > 60 | actual: integer <48> | expected: greater than integer <60> |
This error states that we expected at least 60 days, but we actually only have 48 remaining.
Scheduled runs
Now that we have a script to check the domain expiration date, we can create a scheduled cron trigger to make sure it runs continuously every day and sends us an email when the assertion above fails.
After you create the Skybear.NET script with the above content, navigate to its Settings tab, and configure a Scheduled Cron trigger with the cron expression 0 1 * * *
so that it runs every day at 01:00.