You can get the list of current TLDs in many ways, slightly differently.
For example:
- Going to IANA website at https://www.iana.org/domains/root/db (this is frequently updated after a new TLD got delegated in root zone)
- Or just download the root zone file through the appropriate links: http://www.internic.net/domain/root.zone or ftp://rs.internic.net/domain/root.zone
- You could also just query one of the current root nameservers that allow
AXFR
requests to just download the current root zonefile, such as dig @f.root-servers.net . AXFR
with the added benefit that this is protected by DNSSEC (where the previous HTTP URL has no protection against tampering)
Of course this gives you only "Top Level Domains" not all "suffixes" under which a registry exists to allow the public (in general or part of it) to register domain names.
Having the list of those is currently still an unsolved problems, if you take into account the needs of automated process, freshness, decentralization of updates, etc.
The best solution is to use the Public Suffix List at https://publicsuffix.org/list/public_suffix_list.dat but first make sure to go to main site at https://publicsuffix.org/learn/ to learn in details about what it is, how to use it and its shortcomings.
You will find co.uk
there.
But as for your:
in the .uk part of .co.uk since (AFAIK) individuals cannot register sites without having the .co preceding it.
This is not true anymore, showing that eligibility requirements in TLDs, or even structure, change over time. .UK
is open to direct registrations now, see https://www.nominet.uk/domains/our-domains/uk-domains/
And also, side rant, when you work with domain names/TLDs please do not forget about IDNs, that could happen in any label in the DNS.