4

I'm using WhoisClient (org.apache.commons.net.whois.WhoisClient) to retrieve my website domain expiry date. It is working for the domain with .com extension. When I try to check the expiry date for one of my .org domain the result says No match for domain.org. How do I find out the expiry date of a .org and .in extension domain?

I'm using the following code for getting the expiry date of the domain

String domainName =  mydomain.replaceFirst("^(http[s]?://www\\.|http[s]?://|www\\.)","");
WhoisClient whois = new WhoisClient();
whois.connect(WhoisClient.DEFAULT_HOST);
String whoisData1 = whois.query("=" + domainName);
whois.disconnect();
Sonu
  • 179
  • 1
  • 11
  • There is a site you can use to test: http://whois.domaintools.com/ if I check the fsf.org: http://whois.domaintools.com/fsf.org I got the infos you're looking for. – Mario Santini Aug 28 '19 at 07:15

2 Answers2

10

Do not bother with the whois protocol.

Now (since August 26th, 2019) per ICANN requirements, all gTLDs need to have an RDAP server. RDAP is like the successor of whois: kind of the same content exchanged but this time on top of HTTPS with some fixed JSON format. Hence, trivial to parse.

The expiry date will be in the "events" array with an action called "expiration".

You can go to https://data.iana.org/rdap/dns.json to find out the .ORG RDAP server, it is at URL https://rdap.publicinterestregistry.net/rdap/org/

You need to learn a little more about RDAP to understand how to use it (structure of the query and the reply), you can find some introduction at https://about.rdap.org/

But in short your case, this emulates what you need to do:

$ wget -qO - https://rdap.publicinterestregistry.net/rdap/org/domain/slashdot.org | jq '.events[] | select(.eventAction | contains("expiration")) | .eventDate'
"2019-10-04T04:00:00.000Z"

PS1: if you get no match from a whois query normally it really means that the domain does not exist; it could also be because of rate limiting

PS2: .IN may not have an RDAP server yet, since it is a ccTLD it is not bound by ICANN rules.

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
  • Thank You @Patrick Mevzek, Is there any single API to get all the extensions (.com, .org, .net, .in, .tv, etc..) domain details – Sonu Sep 05 '19 at 14:12
  • 1
    @Sonu no if you want something free and authoritative, you will have to query each respective registry; yes if you shop around various companies provide that but it is neither free nor authoritative (they just cache the data they get themselves when querying registries). – Patrick Mevzek Sep 05 '19 at 14:38
0

WhoisClient.DEFAULT_HOST doesn't really work (at least in 2023).

You'd better pick "whois.iana.org" which has almost all zones. (some zones are missing, you can parse this file https://github.com/rfc1036/whois/blob/next/tld_serv_list)

As for RDAP - it looks dead inborn, for example no RU zone at all.

Oleg Gritsak
  • 548
  • 7
  • 26