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 thesite
parameter. This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified byapi_site_parameter
on the site object.
For example, these calls all yield the same results:
- api.stackexchange.com/2.2/questions?site=gaming
- api.stackexchange.com/2.2/questions?site=gaming.stackexchange
- api.stackexchange.com/2.2/questions?site=gaming.stackexchange.com
- api.stackexchange.com/2.2/questions?site=arqade.com
- api.stackexchange.com/2.2/questions?site=thearqade.com
(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.