Yes, you can check a domain’s expiry date in Google Sheets using a combination of Google Apps Script and a WHOIS API. Here’s how you can do it:
Step 1: Get a WHOIS API Key
- Sign up for a WHOIS API service. Some popular options include:
- Once you have signed up, get your API key from the service.
Step 2: Set Up Google Apps Script
- Open your Google Sheets document.
- Go to
Extensions>Apps Script. - Delete any code in the script editor and paste the following code. Replace
YOUR_API_KEYwith your actual WHOIS API key:
function getDomainExpiry(domain) {
var apiKey = 'YOUR_API_KEY';
var url = 'https://www.whoisxmlapi.com/whoisserver/WhoisService?apiKey=' + apiKey + '&domainName=' + domain + '&outputFormat=JSON';
var response = UrlFetchApp.fetch(url);
var data = JSON.parse(response.getContentText());
if (data.records && data.records.length > 0 && data.records[0].expiresDateISO8601) {
return data.records[0].expiresDateISO8601;
} else {
return 'Expiry date not found';
}
}
function DOMAIN_EXPIRY(domain) {
return getDomainExpiry(domain);
}
- Save the script with a name like
DomainExpiry.
Step 3: Use the Function in Google Sheets
- In a cell where you want to display the domain expiry date, use the custom function like this:
=DOMAIN_EXPIRY("example.com")
Replace example.com with the actual domain you want to check.
Explanation
- The
getDomainExpiryfunction fetches the domain expiry date using the WHOIS API. - The
DOMAIN_EXPIRYfunction is a custom function that can be used directly in Google Sheets.
Notes
- Be mindful of the rate limits and usage quotas of the WHOIS API service you choose.
- Some WHOIS API services might require different URL formats or additional parameters, so adjust the script accordingly.
This setup will allow you to check domain expiry dates directly within your Google Sheets.