5

Many of the API endpoints return urls, such as /questions/{id} (which returns urls for question_timeline_url, question_comments_url, etc). However, the URL returned is a relative URL, like /questions/{id}/timeline.

However, this URL is not relative to the API url. It's relative to a URL that we (potentially) don't know. Theoretically we could compute the base URL by removing the "api." subdomain, but I'm hesitant to hard-code this assumption into my framework.

So my question is:

Can I always assume that removing the "api." subdomain will result in the base url of the site? I understand that this is currently true for stackoverflow.com, meta.stackoverflow.com, etc, but will this always be true for every future StackExchange site?

edit S.Mark has pointed out that the API subdomain can't be relied upon. In which case:

Can we get the absolute URL instead?

edit #2 Kevin's comment reminded me that the URLs returned with the results aren't necessarily user-visible. They're API URLs. Doh!

1
  • 1
    The returned urls are relative to the API url. They're effectively pointers to related methods. Commented Jun 8, 2010 at 8:07

1 Answer 1

3

Regarding the following question,

Can I always assume that removing the "api." subdomain will result in the base url of the site?

No, According to Kevin here

3
  • +1 thanks for reminding me of that question (which I've even up-voted!). In this case, my feature-request stands. :) Commented Jun 8, 2010 at 3:20
  • @Dave Delong, How about base_url in stats page, instead of everything as Absolute URL?
    – YOU
    Commented Jun 8, 2010 at 3:26
  • Mark that could work, I suppose. It'd be nice to have it as part of the response, since I can't guarantee that the stats endpoint will have been invoked yet. I could invoke it myself automatically, I suppose... I'll have to think about that and see if any official response comes. Commented Jun 8, 2010 at 4:26

You must log in to answer this question.

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