Skip to main content
Clear up explanation and enhance SEO. (This answer was a bit to hard to find a moment ago.)
Source Link
Brock Adams
  • 13k
  • 5
  • 39
  • 64

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
    );
    
    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
    );

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
    );
    

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

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
    );
Source Link
Tim Stone
  • 4.7k
  • 3
  • 22
  • 32

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
    );