Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

You already know the site, it has to be built in to every /questions query. But, if you are querying separate sites with concurrent AJAX queries, merely encapsulate the site name in your AJAX callback. See this Stack Overflow question for an example of doing that in javascript.See this Stack Overflow question for an example of doing that in javascript.

Alternatively, you can parse the link property of the question response to determine the site.

EG: The question response returns a link for each question like this:

"link": "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-en"

So, just extract the domain:

var qLink   = "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-energistics-to-increase-item-count-to-an-exact-value-wh";
var qDomain = qLink.match (/^https?:\/\/([^\/]+)/i)[1];
// Yields: "gaming.stackexchange.com"

You can then use the domain for the site for subsequent calls:

Per-Site Methods
Each of these methods operates on a single site at a time, identified by the site parameter. This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified by api_site_parameter on the site object.

For example, these calls all yield the same results:

(The last 2 domains are aliases for the Gaming site.)


If you really want the English name, EG "Arqade", then look up the domain, as determined above, in a table that your app cached after calling /sites once per app session or once per day.

You already know the site, it has to be built in to every /questions query. But, if you are querying separate sites with concurrent AJAX queries, merely encapsulate the site name in your AJAX callback. See this Stack Overflow question for an example of doing that in javascript.

Alternatively, you can parse the link property of the question response to determine the site.

EG: The question response returns a link for each question like this:

"link": "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-en"

So, just extract the domain:

var qLink   = "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-energistics-to-increase-item-count-to-an-exact-value-wh";
var qDomain = qLink.match (/^https?:\/\/([^\/]+)/i)[1];
// Yields: "gaming.stackexchange.com"

You can then use the domain for the site for subsequent calls:

Per-Site Methods
Each of these methods operates on a single site at a time, identified by the site parameter. This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified by api_site_parameter on the site object.

For example, these calls all yield the same results:

(The last 2 domains are aliases for the Gaming site.)


If you really want the English name, EG "Arqade", then look up the domain, as determined above, in a table that your app cached after calling /sites once per app session or once per day.

You already know the site, it has to be built in to every /questions query. But, if you are querying separate sites with concurrent AJAX queries, merely encapsulate the site name in your AJAX callback. See this Stack Overflow question for an example of doing that in javascript.

Alternatively, you can parse the link property of the question response to determine the site.

EG: The question response returns a link for each question like this:

"link": "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-en"

So, just extract the domain:

var qLink   = "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-energistics-to-increase-item-count-to-an-exact-value-wh";
var qDomain = qLink.match (/^https?:\/\/([^\/]+)/i)[1];
// Yields: "gaming.stackexchange.com"

You can then use the domain for the site for subsequent calls:

Per-Site Methods
Each of these methods operates on a single site at a time, identified by the site parameter. This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified by api_site_parameter on the site object.

For example, these calls all yield the same results:

(The last 2 domains are aliases for the Gaming site.)


If you really want the English name, EG "Arqade", then look up the domain, as determined above, in a table that your app cached after calling /sites once per app session or once per day.

Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

You already know the site, it has to be built in to every /questions query. But, if you are querying separate sites with concurrent AJAX queries, merely encapsulate the site name in your AJAX callback. See this Stack Overflow question for an example of doing that in javascript.

Alternatively, you can parse the link property of the question response to determine the site.

EG: The question response returns a link for each question like this:

"link": "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-en"

So, just extract the domain:

var qLink   = "http://gaming.stackexchange.com/questions/176660/how-to-configure-applied-energistics-to-increase-item-count-to-an-exact-value-wh";
var qDomain = qLink.match (/^https?:\/\/([^\/]+)/i)[1];
// Yields: "gaming.stackexchange.com"

You can then use the domain for the site for subsequent calls:

Per-Site Methods
Each of these methods operates on a single site at a time, identified by the site parameter. This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified by api_site_parameter on the site object.

For example, these calls all yield the same results:

(The last 2 domains are aliases for the Gaming site.)


If you really want the English name, EG "Arqade", then look up the domain, as determined above, in a table that your app cached after calling /sites once per app session or once per day.