14

In the /me/associated method, I get back a bunch of JSON - but the api_site_parameter name is nowhere to be found.

Why? It's kind of important. Could we have it?

0

1 Answer 1

8

I don't see any particular reason not to add it, but there are some workarounds you can use in the meantime:

  • Build a cache of all site information with the site URL as the key, and then look up the api_site_parameter value (and associated information) that way.

or

  • Use the fact that the domain name can be passed as a valid value for the site parameter, in all API routes that require it. EG: /2.2/answers?site=unix.stackexchange.com

    Clean up the returned site_url to fit, i.e.:

    var api_site = network_user.site_url.substring(
        network_user.site_url.indexOf("//") + 2,
        network_user.site_url.length - 1
    );
    
4
  • Really? I could pass space.stackexchange.com for site and it would get me results for Space Exploration?
    – user18962
    Commented Aug 3, 2013 at 18:32
  • 1
    Yes, so long as it's just the domain name. This is mentioned in the paragraph about the site parameter in the documentation, specifically "This parameter can be the full domain name (ie. "stackoverflow.com"), or a short form identified by api_site_parameter on the site object." (emphasis mine)
    – Tim Stone
    Commented Aug 3, 2013 at 18:36
  • Awesome! So get the URL and rip out http(s)://. Simple!
    – user18962
    Commented Aug 3, 2013 at 18:42
  • Fwiw, the site_urls don't end with a / (maybe they used to). No big deal but the little substring snippet doesn't work verbatim like this.
    – Jason C
    Commented Mar 18, 2017 at 23:37

You must log in to answer this question.