A list of top level domains (TLDs) in CSV-format
Go to file
Doug Bird 300cc523e0 version 2
- refactor js files to be proper module exportrs with an index.js
- fix inconsistent naming of TLD format files containing simple array of each TLD; now all named using the "list" suffix instead of some using "enum"
 - formats/js/tld-enum/list.js
 - formats/json/tld-list.json
 - formats/php/TldEnum/TldList.php
- new "desc" (description) format file; hashmap of each TLD with corresponding description
 - formats/js/tld-enum/desc.js
 - formats/json/tld-desc.json
 - formats/php/TldEnum/TldDesc.php
- new "type" format file; hashmap of each TLD with corresponding TLD type
 - formats/js/tld-enum/type.js
 - formats/json/tld-type.json
 - formats/php/TldEnum/TldType.php
- new "info" format file; array of each TLD with hashmap containing the "domain", "description", and "type" properties
 - formats/js/tld-enum/info.js
 - formats/json/tld-info.json
 - formats/php/TldEnum/TldInfo.php
- examples for new format files
 - examples/js-desc-demo.js
 - examples/js-info-demo.js
 - examples/js-type-demo.js
 - examples/php-TldDesc-demo.php
 - examples/php-TldInfo-demo.php
 - examples/php-TldType-demo.php
- fixes to bin/update-formats.sh
 - can now skip downloading data from IANA
 - creates new format files with newly created helpers
- created new helpers for new format files
 - bin/helpers/generate-js-tld-desc.js
 - bin/helpers/generate-js-tld-info.js
 - bin/helpers/generate-js-tld-type.js
 - bin/helpers/generate-json-tld-desc.js
 - bin/helpers/generate-json-tld-info.js
 - bin/helpers/generate-json-tld-type.js
 - bin/helpers/generate-php-tld-desc.php
 - bin/helpers/generate-php-tld-info.php
 - bin/helpers/generate-php-tld-type.php
2018-06-12 22:51:12 -07:00
assets automated format generation 2017-12-13 20:49:59 -08:00
bin version 2 2018-06-12 22:51:12 -07:00
examples version 2 2018-06-12 22:51:12 -07:00
formats version 2 2018-06-12 22:51:12 -07:00
.gitignore version 2 2018-06-12 22:51:12 -07:00
GPLv3 Update GPLv3 2018-06-12 14:20:37 -07:00
LICENSE Update LICENSE 2018-06-12 14:21:09 -07:00
README.md Update README.md 2018-06-12 17:29:31 -07:00
composer.json bin 2018-06-12 17:10:48 -07:00
package.json version 2 2018-06-12 22:51:12 -07:00
tlds-idn.txt Adding a list IDN TLDs 2012-10-30 20:56:17 +01:00
tlds.csv update TLDs 2018-06-12 14:09:57 -07:00

README.md

TLD Enumerations

Lists of every IANA TLD in various formats. The lists may be continuously updated using the included utility that pulls the latest data from IANA.

Usage

Because the lists are provided in universial CSV and JSON formats, they can be easily utilitized in most programming environments. Additionally, for convenience, some native programming language formats have also been provided.

Node Usage

  • use npm to add the tld-enum package to your project

    $ npm install tld-enum --save
    
  • add the module to your source

    const tldEnum = require('tld-enum');
    
  • access the list by using the tldEnum.tldList array

    const tldEnum = require('tld-enum');
    tldEnum.tldList; //an array with every IANA TLD
    

    The following example...

    const tldEnum = require('tld-enum');
    
    console.log("There are " + tldEnum.tldList.length + " IANA TLDs");
    
    let tldCheck;
    
    tldCheck = "com";
    console.log("Is '" + tldCheck + "' a real TLD?");
    if (tldEnum.tldList.indexOf(tldCheck.toLowerCase()) != -1) {
        console.log("  yes");
    } else {
        console.log("  no");
    }
    
    tldCheck = "somethingWeird";
    console.log("Is '" + tldCheck + "' a real TLD?");
    if (tldEnum.tldList.indexOf(tldCheck.toLowerCase()) != -1) {
        console.log("  yes");
    } else {
        console.log("  no");
    }
    

    Should produce the following output...

    There are 1573 IANA TLDs
    Is 'com' a real TLD?
       yes
    Is 'somethingWeird' a real TLD?
       no
    

PHP Usage

  • use composer to add the katmore/tld-enum package to your project

    $ composer require katmore/tld-enum
    
  • access the list by using the \TldEnum\TldEnum::TLD_ENUM class constant array

    <?php
    require_once __DIR__ . '/vendor/autoload.php';
    \TldEnum\TldEnum::TLD_ENUM; //an array with every IANA TLD
    

    The following example...

    <?php
    use TldEnum\TldEnum;
    
    require __DIR__ . '/vendor/autoload.php';
    
    echo "There are " . count(TldEnum::TLD_ENUM) . " IANA TLDs\n";
    
    $tldCheck = "com";
    echo "Is '$tldCheck' a real TLD?\n";
    if (in_array(strtolower($tldCheck), TldEnum::TLD_ENUM)) {
        echo "  yes\n";
    } else {
        echo "  no\n";
    }
    
    $tldCheck = "somethingWeird";
    echo "Is '$tldCheck' a real TLD?\n";
    if (in_array(strtolower($tldCheck), TldEnum::TLD_ENUM)) {
        echo "  yes\n";
    } else {
        echo "  no\n";
    }
    

    Should produce the following output...

    There are 1573 IANA TLDs
    Is 'com' a real TLD?
       yes
    Is 'somethingWeird' a real TLD?
       no
    

Examples

TLD List Formats

  • CSV: tlds.csv

    A CSV file providing a row for each TLD with the following three columns: domain (TLD), description, and type.

  • PHP: TldEnum.php

    A PHP source file providing a class with a constant having an array value comprised of every IANA TLD.

  • JSON: tld-list.json

    A JSON formatted array comprised of every IANA TLD.

  • JavaScript: tld-enum.js

    An export module with a constant having an array value comprised of every IANA TLD.

Updating the TLD lists

All TLD List Formats can be updated with the latest data from IANA by using the TLD Update Utility.

$ bin/update-formats.sh

TLD Update Utility Prerequisites

  • Node.js version 8.11 or higher.
  • (Optional) PHP command-line version 7.2 or higher, to create the PHP format class file.

TLD Update Utility Usage

usage:
  update-formats.sh [-h] | [-q][--skip-php]

options:
  -h,--help: Print a help message and exit.
  -q,--quiet: Print less messages.
  --force-php: Creating the PHP format file is mandatory.
  --skip-php: Always skip creating the PHP format file

TLD Update Helpers

Internally, the TLD Update Utility uses multiple "helper" scripts to generate the full set of native format lists. These individual "helper" scripts should not be directly executed except for development and troubleshooting purposes.

The source code in this project is based on a fork of certain source code originally from the incognico/list-of-top-level-domains project, as retrieved on 2017-12-04, which was published to the public domain.

TLD Enumerations - https://github.com/katmore/tld-enum

The following copyright notice applies to all resources in this project unless specifically noted otherwise:

Copyright (c) 2017-2018 Doug Bird. All Rights Reserved.

Public Domain Resources

The following resources of this project are hereby released into the public domain:

License

All resources in the 'TLD Enumerations' project are copyrighted free software unless specifically noted otherwise.

You may redistribute and modify it under either the terms and conditions of the "The MIT License (MIT)"; or the terms and conditions of the "GPL v3 License". See LICENSE and GPLv3.

These licensing conditions do not apply to any resources that have been released into the public domain; which are listed in the "Public Domain Resources" section of the 'TLD Enumerations' project's README document.