Most Stack Exchange sites are subdomains of stackexchange.com
. However, some aren't. What are the list of those that aren't?
Right now I just know stackoverflow.com
, superuser.com
, serverfault.com
, and askubuntu.com
.
Most Stack Exchange sites are subdomains of stackexchange.com
. However, some aren't. What are the list of those that aren't?
Right now I just know stackoverflow.com
, superuser.com
, serverfault.com
, and askubuntu.com
.
You can find that by leveraging the Stack API using the REST /sites endpoint.
From the description:
Returns all sites in the network.
This method allows for discovery of new sites, and changes to existing ones. Be aware that unlike normal API methods, this method should be fetched very infrequently, it is very unusual for these values to change more than once on any given day. It is suggested that you cache its return for at least one day, unless your app encounters evidence that it has changed (such as from the /info method).
It returns a JSON structure like this (filtered on site_url and aliases):
{
"items": [
{
"aliases": [
"http://www.stackoverflow.com",
"http://facebook.stackoverflow.com"
],
"site_url": "http://stackoverflow.com",
"name": "Stack Overflow"
},
{
"site_url": "http://serverfault.com",
"name": "Server Fault"
},
{
"site_url": "http://superuser.com",
"name": "Super User"
},
{
"site_url": "http://meta.stackexchange.com",
"name": "Meta Stack Exchange"
},
{
"aliases": [
"http://nothingtoinstall.com"
],
"site_url": "http://webapps.stackexchange.com",
"name": "Web Applications"
},
{
"site_url": "http://meta.webapps.stackexchange.com",
"name": "Web Applications Meta"
},
{
"site_url": "http://gaming.stackexchange.com",
"name": "Arqade"
},
.... many more
{
"site_url": "http://askubuntu.com",
"name": "Ask Ubuntu"
},
{
"site_url": "http://meta.askubuntu.com",
"name": "Ask Ubuntu Meta"
}
],
"has_more": true,
"quota_max": 10000,
"quota_remaining": 9987
}
For convenience I've created the following stack-snippet that produce an easy to consume HTML table as a result of running the snippet.
function addSiteRow(target, site) {
var i,
siterow,
cell,
ul,
li;
siterow = document.createElement('tr');
cell = document.createElement('td');
cell.textContent = site.name;
siterow.appendChild(cell);
cell = document.createElement('td');
cell.textContent = site.site_url;
siterow.appendChild(cell);
cell = document.createElement('td');
if (site.aliases && site.aliases.length > 0) {
ul = document.createElement('ul');
for(i = 0; i < site.aliases.length; i = i + 1) {
li = document.createElement('li');
li.textContent = site.aliases[i];
ul.appendChild(li);
}
cell.appendChild(ul);
}
siterow.appendChild(cell);
target.appendChild(siterow);
}
var xhr = new XMLHttpRequest();
xhr.open('GET','https://api.stackexchange.com/2.2/sites?pagesize=500&filter=!SmNnfVWqow2tl*.eJo');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
var sites = JSON.parse(xhr.responseText),
result = document.getElementById('result'),
site,
i;
for(i=0; i < sites.items.length; i = i + 1) {
site = sites.items[i];
addSiteRow(result, site);
}
}
};
xhr.send();
ul {
padding:0px;
margin:0px;
}
td {
border-top: solid blue 1px;
}
<table>
<thead>
<tr>
<th>Site</th>
<th>Url</th>
<th>Alias</th>
</tr>
</thead>
<tbody id="result">
</tbody>
</table>