list-of-top-level-domains/README.md

275 lines
10 KiB
Markdown
Raw Normal View History

2017-12-14 05:26:09 +00:00
# TLD Enumerations
2018-06-13 07:07:30 +00:00
Lists of every [IANA TLD](http://data.iana.org/TLD/tlds-alpha-by-domain.txt) in various formats. The lists may be continuously updated using the included [update utility](#updating-the-tld-format-files) that pulls the latest data from IANA.
2012-10-27 11:41:50 +00:00
2018-06-13 06:16:56 +00:00
* [CSV Format](./tlds.csv)
* [All Format Files](#tld-list-formats)
* [Updating the Format Files](#updating-the-tld-format-files)
2018-06-13 00:10:09 +00:00
* [Node Usage](#node-usage)
* [PHP Usage](#php-usage)
2018-06-13 00:20:10 +00:00
2017-12-14 06:34:39 +00:00
## Usage
2018-06-13 00:25:40 +00:00
Because the lists are provided in universial CSV and JSON formats, they can be easily utilitized in most programming environments.
2018-06-13 00:21:52 +00:00
Additionally, for convenience, some native programming language formats have also been provided.
2018-06-13 00:20:10 +00:00
* [Node Usage](#node-usage)
2018-06-13 06:21:27 +00:00
* [More Node Examples](#more-node-examples)
2018-06-13 00:20:10 +00:00
* [PHP Usage](#php-usage)
2018-06-13 06:21:27 +00:00
* [More PHP Examples](#more-php-examples)
2017-12-14 06:05:44 +00:00
2018-06-13 00:10:09 +00:00
### Node Usage
2017-12-14 06:38:21 +00:00
* use npm to add the `tld-enum` package to your project
2017-12-14 06:05:44 +00:00
```sh
$ npm install tld-enum --save
```
2017-12-14 06:34:39 +00:00
* add the module to your source
```js
const tldEnum = require('tld-enum');
```
* access the list by using the `tldEnum.tldList` array
```js
const tldEnum = require('tld-enum');
2018-06-13 07:27:30 +00:00
console.log(tldEnum.list); //an array with every IANA TLD
2017-12-14 06:34:39 +00:00
```
The following example...
```js
const tldEnum = require('tld-enum');
2018-06-13 06:16:56 +00:00
console.log("There are " + tldEnum.list.length + " IANA TLDs");
2017-12-14 06:34:39 +00:00
let tldCheck;
tldCheck = "com";
console.log("Is '" + tldCheck + "' a real TLD?");
2018-06-13 06:16:56 +00:00
if (tldEnum.list.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
2017-12-14 06:34:39 +00:00
} else {
console.log(" no");
2017-12-14 06:34:39 +00:00
}
tldCheck = "somethingWeird";
console.log("Is '" + tldCheck + "' a real TLD?");
2018-06-13 06:16:56 +00:00
if (tldEnum.list.indexOf(tldCheck.toLowerCase()) != -1) {
console.log(" yes");
2017-12-14 06:34:39 +00:00
} else {
console.log(" no");
2017-12-14 06:34:39 +00:00
}
```
Should produce the following output...
```txt
2018-06-13 06:16:56 +00:00
There are 1577 IANA TLDs
2017-12-14 06:34:39 +00:00
Is 'com' a real TLD?
yes
Is 'somethingWeird' a real TLD?
no
```
2017-12-14 06:05:44 +00:00
2018-06-13 06:20:09 +00:00
#### More Node Examples
* [js-demo.js](/examples/js-demo.js) Demo using the simple array of every TLD in JavaScript.
* [js-desc-demo.js](/examples/js-desc-demo.js) Demo using the TLD description hashmap in JavaScript.
* [js-type-demo.js](/examples/js-type-demo.js) Demo using the TLD type hashmap in JavaScript.
* [js-info-demo.js](/examples/js-info-demo.js) Demo using the array of TLD info hashmaps in JavaScript.
2018-06-13 00:10:09 +00:00
### PHP Usage
2017-12-14 06:38:21 +00:00
* use composer to add the `katmore/tld-enum` package to your project
2017-12-14 06:05:44 +00:00
```sh
2017-12-14 06:34:39 +00:00
$ composer require katmore/tld-enum
```
2018-06-13 07:14:44 +00:00
* access the list by using the `\TldEnum\TldList::TLD_LIST` class constant array
2017-12-14 06:34:39 +00:00
2017-12-14 06:38:21 +00:00
```php
2017-12-14 06:55:07 +00:00
<?php
2018-06-13 07:14:44 +00:00
print_r(\TldEnum\TldList::TLD_LIST); //an array with every IANA TLD
2017-12-14 06:38:21 +00:00
```
2017-12-14 06:34:39 +00:00
The following example...
```php
<?php
2018-06-13 06:16:56 +00:00
use TldEnum\TldList;
2017-12-14 06:34:39 +00:00
2018-06-13 06:16:56 +00:00
echo "There are " . count(TldList::TLD_LIST) . " IANA TLDs\n";
2017-12-14 06:34:39 +00:00
$tldCheck = "com";
echo "Is '$tldCheck' a real TLD?\n";
2018-06-13 06:16:56 +00:00
if (in_array(strtolower($tldCheck), TldList::TLD_LIST)) {
echo " yes\n";
2017-12-14 06:34:39 +00:00
} else {
echo " no\n";
2017-12-14 06:34:39 +00:00
}
$tldCheck = "somethingWeird";
echo "Is '$tldCheck' a real TLD?\n";
2018-06-13 06:16:56 +00:00
if (in_array(strtolower($tldCheck), TldList::TLD_LIST)) {
echo " yes\n";
2017-12-14 06:34:39 +00:00
} else {
echo " no\n";
2017-12-14 06:34:39 +00:00
}
```
2017-12-14 06:51:08 +00:00
Should produce the following output...
2017-12-14 06:34:39 +00:00
```txt
2018-06-13 06:16:56 +00:00
There are 1577 IANA TLDs
2017-12-14 06:34:39 +00:00
Is 'com' a real TLD?
yes
Is 'somethingWeird' a real TLD?
no
2017-12-14 06:05:44 +00:00
```
2018-06-13 06:20:09 +00:00
#### More PHP Examples
2018-06-13 06:16:56 +00:00
* [php-demo.php](/examples/php-demo.php) Demo using the simple array of every TLD in PHP.
* [php-TldDesc-demo.php](/examples/php-TldDesc-demo.php) Demo using the TLD description hashmap in PHP.
* [php-TldType-demo.php](/examples/php-TldType-demo.php) Demo using the TLD type hashmap in PHP.
* [php-TldInfo-demo.php](/examples/php-TldInfo-demo.php) Demo using the array of TLD info hashmaps in PHP.
2017-12-14 06:51:08 +00:00
2018-06-13 00:10:09 +00:00
## TLD List Formats
* **CSV**: [tlds.csv](/tlds.csv)
2018-06-13 06:17:55 +00:00
A CSV file providing a row for every IANA TLD with the following three columns: *domain* (TLD), *description*, and *type*.
2018-06-13 00:10:09 +00:00
2018-06-13 06:16:56 +00:00
* **PHP**
* [TldList.php](/formats/php/TldEnum/TldList.php)
A PHP source file providing a class constant array comprised of every IANA TLD.
* [TldDesc.php](/formats/php/TldEnum/TldDesc.php)
A PHP source file providing a class constant assoc array with a key for every IANA TLD and the corresponding TLD's "description" as the value.
* [TldType.php](/formats/php/TldEnum/TldType.php)
2017-12-04 22:40:06 +00:00
2018-06-13 06:16:56 +00:00
A PHP source file providing a class constant assoc array with a key for every IANA TLD and the corresponding TLD's "type" as the value.
* [TldInfo.php](/formats/php/TldEnum/TldInfo.php)
A PHP source file providing a class constant array of "info" assoc array elements of every IANA TLD.
2017-12-04 22:40:06 +00:00
2018-06-13 06:16:56 +00:00
* **JSON**
* [tld-list.json](/formats/json/tld-list.json)
A JSON formatted array comprised of every IANA TLD.
* [tld-desc.json](/formats/json/tld-desc.json)
A JSON formatted object with a property for every IANA TLD and the corresponding TLD's "description" as the value.
* [tld-type.json](/formats/json/tld-type.json)
A JSON formatted object with a property for every IANA TLD and the corresponding TLD's "type" as the value.
* [tld-info.json](/formats/json/tld-info.json)
A JSON formatted array of "info" object elements of every IANA TLD.
* **JavaScript**
2018-06-13 06:25:11 +00:00
* [list.js](/formats/js/tld-enum/list.js)
2018-06-13 06:16:56 +00:00
An export module with an array comprised of every IANA TLD.
2018-06-13 06:25:11 +00:00
* [desc.js](/formats/js/tld-enum/desc.js)
2017-12-04 22:40:06 +00:00
2018-06-13 06:16:56 +00:00
An export module with an object containing a property for every IANA TLD and the corresponding TLD's "description" as the value.
2018-06-13 06:25:11 +00:00
* [type.js](/formats/js/tld-enum/type.js)
2017-12-04 22:40:06 +00:00
2018-06-13 06:16:56 +00:00
An export module with an object containing a property for every IANA TLD and the corresponding TLD's "type" as the value.
2018-06-13 06:25:11 +00:00
* [info.js](/formats/js/tld-enum/info.js)
2017-12-04 22:40:06 +00:00
2018-06-13 06:16:56 +00:00
An export module with an array comprised of "info" object elements of every IANA TLD.
2017-12-14 06:05:44 +00:00
2018-06-13 06:16:56 +00:00
## Updating the TLD format files
2018-06-22 01:07:23 +00:00
All [TLD List Formats](#tld-list-formats) can be updated with the latest data from IANA by using the [**TLD Update Utility**](/bin/devel/update-formats.sh).
2018-06-13 00:10:09 +00:00
```sh
2018-06-22 01:07:23 +00:00
$ bin/devel/update-formats.sh
2018-06-13 00:10:09 +00:00
```
### TLD Update Utility Prerequisites
* Node.js version 8.11 or higher.
2018-06-13 06:38:10 +00:00
* (Optional) PHP command-line version 7.2 or higher, to re-generate the [PHP format files](#tld-list-formats).
2018-06-13 08:02:24 +00:00
* The *devDependencies* from [*package.json*](./package.json) must be available.
2018-06-13 08:12:46 +00:00
* If **tld-enum** was installed in an outside project using npm, then the *tld-enum* dev dependencies must be installed manually, as in the following example:
2018-06-13 08:02:24 +00:00
```sh
npm install async-request --save-dev
npm install cheerio --save-dev
npm install commander --save-dev
npm install country-data --save-dev
npm install countryjs --save-dev
npm install csv-parse --save-dev
npm install csv-stringify --save-dev
npm install es6-promisify --save-dev
npm install fs --save-dev
npm install fs-extra --save-dev
npm install md5-file --save-dev
npm install pathinfo --save-dev
npm install request --save-dev
npm install tmp --save-dev
```
2018-06-13 08:14:23 +00:00
* If **tld-enum** was installed in an outside project using npm, then the **TLD Update Utility** can be executed from the *node_module* directory, as in the following example:
2018-06-13 08:02:24 +00:00
```sh
2018-06-22 01:07:23 +00:00
node_modules/tld-enum/bin/devel/update-formats.sh
2018-06-13 08:02:24 +00:00
```
2018-06-13 00:10:09 +00:00
### TLD Update Utility Usage
```txt
usage:
2018-06-13 06:31:49 +00:00
update-formats.sh [-h]|[-q][format file options...]
2018-06-13 00:10:09 +00:00
2018-06-13 06:31:49 +00:00
-h,--help: Print a help message and exit.
-q,--quiet: Print only critical messages.
format file options:
--force-php: Creating the PHP format files is mandatory.
--skip-php: Always skip creating the PHP format files.
--skip-csv: Use existing tlds.csv and do not download new data from IANA.
2018-06-13 00:10:09 +00:00
```
### 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.
2017-12-04 21:56:31 +00:00
## Legal
2017-12-04 22:40:06 +00:00
The source code in this project is based on a fork of certain source code originally from the [incognico/list-of-top-level-domains](https://github.com/incognico/list-of-top-level-domains) project, as retrieved on 2017-12-04, which was published to the public domain.
2017-12-04 21:56:31 +00:00
### Copyright
2017-12-14 05:26:09 +00:00
TLD Enumerations - https://github.com/katmore/tld-enum
2017-12-04 21:56:31 +00:00
The following copyright notice applies to all resources in this project unless specifically noted otherwise:
2018-06-12 21:22:03 +00:00
Copyright (c) 2017-2018 Doug Bird. All Rights Reserved.
2017-12-04 21:56:31 +00:00
### License
2018-06-13 07:06:25 +00:00
All resources in the *TLD Enumerations* project are copyrighted free software unless specifically noted otherwise.
2017-12-04 21:56:31 +00:00
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](/LICENSE) and [GPLv3](/GPLv3).
2018-06-13 07:06:25 +00:00
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"**](/README.md#public-domain-resources) section of the *TLD Enumerations* project's [README](/README.md) document.
2018-06-13 07:04:17 +00:00
### Public Domain Resources
The following resources of this project are hereby released into the public domain:
* [tlds.csv](/tlds.csv)
* [formats/js/tld-enum/list.js](/formats/js/tld-enum/list.js)
* [formats/js/tld-enum/desc.js](/formats/js/tld-enum/desc.js)
* [formats/js/tld-enum/info.js](/formats/js/tld-enum/info.js)
* [formats/js/tld-enum/type.js](/formats/js/tld-enum/type.js)
* [formats/json/tld-list.json](/formats/json/tld-list.json)
* [formats/json/tld-desc.json](/formats/json/tld-desc.json)
* [formats/json/tld-info.json](/formats/json/tld-info.json)
* [formats/json/tld-type.json](/formats/json/tld-type.json)
* [formats/php/TldEnum/TldList.php](/formats/php/TldEnum/TldList.php)
* [formats/php/TldEnum/TldDesc.php](/formats/php/TldEnum/TldDesc.php)
* [formats/php/TldEnum/TldInfo.php](/formats/php/TldEnum/TldInfo.php)
* [formats/php/TldEnum/TldType.php](/formats/php/TldEnum/TldType.php)
* [assets/tld-desc.csv](/assets/tld-desc.csv)