Take the 2-minute tour ×
Stack Apps is a question and answer site for apps, scripts, and development with the Stack Exchange API. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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 in as the value for site, and 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
    );
    
share|improve this answer
    
Really? I could pass space.stackexchange.com for site and it would get me results for Space Exploration? –  Undo Aug 3 '13 at 18:32
    
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 Aug 3 '13 at 18:36
    
Awesome! So get the URL and rip out http(s)://. Simple! –  Undo Aug 3 '13 at 18:42
add comment

You must log in to answer this question.

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