Is there any other way to detect CMS from URL? If yes, is there any available API in PHP o any other language? The site http://whatcms.org/ is an example of what i have in mind; how does it do the detection?
You could check the meta tag for generator. Most CMS have their name and version advertised there.
This is the tag you're after.
<meta name="generator" content="Joomla! - Open Source Content Management" />
This code will try and find the tag to extract the content
attribute.
$doc = new DOMDocument();
$doc->loadHTMLFile('http://joomla.org');
$xpath = new DOMXPath($doc);
$generators = $xpath->query('//html/head/meta[@name="generator"]');
echo $generators->item(0)->getAttribute('content');
This code echo's Joomla! - Open Source Content Management
If a common CMS is used (e.g. OpenCart , WordPress , Magento , Joomla , etc), Chrome / Firefox extension, Wappalyzer will be handy.
Nor Wappalyzer nor whatCMS detect the CMS from the URL, they download the code, and check the meta-data. If you put some effort in that, you can do this yourself too using curl to retrieve the page and then parsing out the meta-data, scanning for keywords.
There is now a Detect-CMS PHP library written by Krisseck.
From the README.md:
include("Detect-CMS/Detect-CMS.php");
$domain = "http://google.com";
$cms = new DetectCMS($domain);
if($cms->getResult()) {
echo "Detected CMS: ".$cms->getResult();
} else {
echo "CMS couldn't be detected";
}