3

A while ago I made a little "Recently answered on Stack Overflow" sidebar widget for my homepage. Currently this works by filtering answers out of the user feed however I thought I'd update it to make use of the API instead.

I can successfully retrieve /users/{id}/answers however there doesn't seem to be a field for an answer's URL so is the way to do this just to concatenate

"http://www.stackoverflow.com/questions/" + question_id + "/" + 
  answer_id + "#" + answer_id

This is fine but it doesn't include the URL-friendly version of the question title so if I wanted that in the URL would I have to generate it myself?

Brock Adams
  • 12,901
  • 5
  • 38
  • 64
mikej
  • 185
  • 5

2 Answers2

3

You have to generate any links back to "proper" SO yourself. The most any of the API methods will give you is (relative) links to other API methods.

Kevin Montrose
  • 18,660
  • 6
  • 34
  • 62
  • 1
    Out of curiosity, why isn't this included as part of the api? It seems like a common enough use case (for example, I need to get the url of an answer object that I just got from the api). – Edan Maor Jun 13 '10 at 20:58
3

As of version 2.0 of the API, answers can return a link field in the response, which can be returned in the response by creating a filter that includes it:

enter image description here

Nathan Osman
  • 23,286
  • 11
  • 60
  • 107