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.

I'm trying to beautify the reputation audit. If I want to show the post title for a reputation change event, however, I have a problem -- I don't know if the post ID is relative to a question or an answer.

By poking around with the API a bit, it seems that the only way to get a result in my case is:

  1. call /answers/{id};

Is there a better way of doing this?

share|improve this question
    
Another non-write feature wanted... –  Jonathan. Jan 18 '11 at 18:34
add comment

2 Answers

I believe that's a correct approach.

There's a way to optimize it saving one request but it's a little bit unsafe for this bug:

  1. call /questions/{id};

EDIT:
I've just realized that your solution can be optimized easily just removing the /questions/{parent-id}/call;
you don't need it because /answers/{id}; already has the title parameter inside the response.

share|improve this answer
1  
Smart hack - given the current roadmap there are quite some requests to be saved still like so ;) –  Steffen Opel Jan 18 '11 at 10:05
add comment

You should be able to achieve this via the non optional "is_question" field of route /revisions/{id}:

   "is_question": {
        "description": "if the post is a question",
        "values": "boolean",
        "optional": false
      },

See for example the results for:

share|improve this answer
2  
Uhm, /revisions route does return the parent-id in case of answer. This would force badp to call /answers anyway to get the parent-id and then /questions to get the title. –  systempuntoout Jan 18 '11 at 7:37
1  
Also, the call would return a lot of data I don't care about :) –  badp Jan 18 '11 at 7:38
1  
@systempuntoout / @badp - both arguments are absolutely correct of course, I got carried away digging the API about a question/answer discriminator for a given post id and lost track of the mentioned use case, despite it being phrased elaborately (i.e. getting the post title either way) - it has been (too) late for me apparently ;) –  Steffen Opel Jan 18 '11 at 9:46
1  
My comment above is partially correct. The /revision route is not returning the parent-id field but it does not matter because /answers/{id}; returns the title costing just one request. So this is a valid solution too though with a bigger payload. –  systempuntoout Jan 18 '11 at 14:24
add comment

You must log in to answer this question.

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