Skip to main content
2 of 4
added 88 characters in body; edited tags
Dave DeLong
  • 5.3k
  • 1
  • 17
  • 12

Will URLs always follow this pattern?

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?

Dave DeLong
  • 5.3k
  • 1
  • 17
  • 12