Query this REST API with any email address and it will extract and return the top level domain (TLD) against Mozilla TLDs official listing. It supports a range of scenarios with domains and subdomains, including .edu, .co.uk, and others. It also supports parsing unknown tlds.
The code is based on the tld-extract library, which in turn is a port of a yks/PHP library. The docs are simple: the API accepts only 1 query parameter - emailaddress - and returns JSON with the extracted TLD, and the email queried back.
For example: https://www.sevenj.com/rosterapi/v1/tld-extract?emailaddress=tom.jones@mail.company.com, will return the following:
{
"tld": "company.com",
"emailaddress": "tom.jones@mail.company.com"
}
Test it yourself:
https://www.sevenj.com/rosterapi/v1/tld-extract?albert@mail.school.edu
https://www.sevenj.com/rosterapi/v1/tld-extract?emailaddress=john@mycompany.co.uk
https://www.sevenj.com/rosterapi/v1/tld-extract?emailaddress=eve@sub1.sub2.sub3.place.br
https://www.sevenj.com/rosterapi/v1/tld-extract?emailaddress=john.doe@company.unknowntld
https://www.sevenj.com/rosterapi/v1/tld-extract?emailaddress=jane.doe@msubdomain1.ycompany.co.uk
Copyright © 2022 Balcells.com - All rights reserved