4

I recently wrote an answer to this question;

Which question on SFF has the highest number of downvotes?

However, within a few days it was out of date. No doubt if I check it again in a few days, it'll be out of date again.


Is there any way to use the results of a Data Explorer search to update an answer in realtime?

||||||
  • Have you checked meta.meta? – AncientSwordRage Aug 10 '16 at 10:29
  • I did and found this – AncientSwordRage Aug 10 '16 at 10:32
  • What do you mean exactly? Do you want a change in the data to automatically edit your answer every time? I'm afraid for that you need an external process to mess with the SE API using your account login (if that even is allowed or possible). Or do you want some kind of embedded SEDE result onebox inside your answer? I'm afraid this isn't possible at all. – TARS says Reinstate Monica Aug 10 '16 at 13:06
  • Either or both would be fine. I just can't be bothered to keep updating my answer. – Valorum Aug 10 '16 at 13:45
  • 1
    JavaScript/CSS/HTML snippets don't appear to be available on this site but they would provide a way to do this. If you really want this you could open a feature request to add them to this site and then if it is approved write something to query the stack exchange api in a way similar to the PPCG leaderboard snippet, for example. That said, you could also write a script that uses the edit feature of the API to update your answer, as Cahir suggested. – FryAmTheEggman Aug 10 '16 at 14:33
  • So 'no' then :-( – Valorum Aug 10 '16 at 16:31
5

Yes, but

As has been mentioned in the comments on your question (e.g., by AncientSwordRage's Meta.SE link), it's not possibly to dynamically query the data explorer.

It's also not possible to embed runnable code in answers; in principle it looks as though Stack Snippets can be used to query the API, but of course we don't have Stack Snippets enabled, nor do we really need it to be.

Your last recourse, if you're technically-minded, would be an external application that hits the StackExchange API. In principle it wouldn't be difficult to write an application that polls the API for changes, and edits an answer if it finds any1; no manual intervention required. This would actually have the advantage of bring significantly more up-to-date than the Data Explorer, which only updates weekly (while the API is more-or-less realtime, I believe).

There are some complications around doing this for this specific use-case, though; because /answers doesn't allow sorting by downvote_count, you'd have to get all answers on the site and sort them in the application, which may run into rate limiting problems2.

However, it might be easier to simply link to the query in your answer, and add an accuracy disclaimer.


1 Credit where it's due; this was suggested in comments on the question by Cahir Mawr Dyffryn æp Ceallach and FryAmTheEggman

2 The reason for this is that the API paginates large results; you can only get up to 100 results at a time, so you'd have to make something on the order of 700 requests to get all of the answers. This isn't insurmountable - with an access token, which you'd need in order to edit an answer, you're limited to 10,000 requests per day - it's an extra layer of complication

||||||

You must log in to answer this question.

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