Reputation: 53850
There are so many top level domains these days, like .xxx, .club and so on. How do I check if some domain's top-level domain is correct and exists?
For example, mydomain.xyz
. I can cut off mydomain.
and check the rule against xyz
. Should I get a full list somewhere? I suppose it's not 100% guaranteed as the list can grow over time?
Or may be I should use some remote API for this?
I found this one http://data.iana.org/TLD/tlds-alpha-by-domain.txt and it seems to be the one that I hope is updated regularly. Is it a good enough source?
Please advise.
Upvotes: 4
Views: 5005
Reputation:
If you want to check a given string to see if there is a currently existing TLD with that name, you can send an NS
query for the name to the root servers and see if they give you a sensible answer. If they do, the TLD exists. If they do not, it does not exist.
If you want a list of all currently existing TLDs, the URL you give in your question is indeed the correct place to get one. As the first line in the file indicates, it does get updated regularly.
Upvotes: 4