I just wrote an app for Chrome extensions and received a request to make it cross-StackExchange compatible. If there's eventually going to be more sites than just the few listed and I don't really know what they'll be called other than by checking here every so often to see what is supported, how do I future-proof my app to work with every SE site? Or am I doomed to hardcode everything?

3 Answers 3


http://stackauth.com/1.0/sites will get you information about all the sites.

  • 3
    ++ for digging and providing a correct and current answer for future askers. Sep 13, 2010 at 4:15

I wrote a Chrome extension myself (details here) that works against all of the Stack sites, and an approach that I found pretty useful was to maintain a simple javascript object that stores anything about the sites that I may need to access. Here's the snippet I'm currently using:

var siteDetails = [
                        siteName: "MetaStackOverflow",
                        siteUrlMatch: /.*meta.stackoverflow.com.*/,
                        iconUrl: "http://sstatic.net/mso/favicon.ico",
                        apiRoot: "http://api.meta.stackoverflow.com/0.8/"
                        siteName: "StackOverflow",
                        siteUrlMatch: /.*stackoverflow.com.*/,
                        iconUrl: "http://sstatic.net/so/favicon.ico",
                        apiRoot: "http://api.stackoverflow.com/0.8/"
                        siteName: "SuperUser",
                        siteUrlMatch: /.*superuser.com.*/,
                        iconUrl: "http://sstatic.net/su/favicon.ico",
                        apiRoot: "http://api.superuser.com/0.8/"
                        siteName: "ServerFault",
                        siteUrlMatch: /.*serverfault.com.*/,
                        iconUrl: "http://sstatic.net/sf/favicon.ico",
                        apiRoot: "http://api.serverfault.com/0.8/"

Extending this to include future StackExchange sites or even user submitted sites would be pretty trivial with a helper method.

I'm personally choosing which API I'm using by investigating the URL of the page the user is visiting, but if the user is selecting which sites to use or activate, including a simple boolean flag with the site structure would suffice.

  • yeah i saw your extension just a few seconds ago :) also, i had this idea (or something similar) on my bike ride to work this morning. it sucks we have to do something like this, but i feel like this may be the best solution right now
    – Jason
    Jun 3, 2010 at 17:08
  • Right now I'm working on encapsulating all that functionality into a centralized JS script, with the hopes that if / when a discovery API is implemented, I can change everything in one place and it will be implemented across my extension. Once that happens, I'll be sure to remember you and drop you a comment. Jun 3, 2010 at 17:33

I think it varies by application, and I'm not sure how you'd want to do it for yours, but for many it'd probably be sufficient to allow the user to add a site in the "stackoverflow.com" format, from which you can derive the API URL.

  • i was looking for a way to maybe centrally detect support? maybe a call to the main stackoverflow stats method gives you a list of all the supported sites? i think that would be kind of cool.
    – Jason
    Jun 3, 2010 at 16:48
  • 1
    Could you maybe try hitting the API URL of the site the user is trying to add, and if you get an error or an unexpected response, you can assume that the site either isn't a StackExchange site or the API hasn't been activated on it yet. Jun 3, 2010 at 16:49
  • @Jason There's already been talk of something like that, but it won't be going in the per-site API. See: stackapps.com/questions/30/should-there-be-a-discovery-api
    – ColinD
    Jun 3, 2010 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .