If you follow and/or curate a tag long enough, you'll probably notice that there's some questions that just get asked over and over. Usually these are confusing aspects of some commonly used feature that newbies keep tripping over.

Having a gold tag badge, after I close these repeated duplicates, I also proceed to edit the duplicate list with more similar Q&As that are relevant to the issue1. For several very common duplicates, I often find myself editing the same duplicate list in every time. This is a repetitive and time-consuming task. I would like to automate it instead.

I would like to make an API call to cast a close vote as duplicate with a list of duplicate targets.

I'm aware of the API /questions/{id}/flags/add which can be used to cast close votes, however it's not clear to me how duplicate closure happens in this case. Where do I set the ID of the dupe target? There are examples in the options page but I don't understand how the available "Duplicate Free Form" and "Duplicate Pre-Filled" relate to my goal. Also testing the API requires an API key, which I don't have.

I also tried inspecting the network activity when closing a dupe from the GUI, though the endpoint used is different: /flags/questions/{id}/close/add. However this does have a closeReasonId: Duplicate and duplicateOfQuestionId: {id} form fields which look closer to my goal.

Can I call the internal endpoints in a userscript, with an array of (comma-separated?) items in duplicateOfQuestionId? Or is there a way to accomplish this with the public API and some flag option?


1: One could argue that if those dupe targets consistently appear together in dupe lists, they are also dupes of each other and therefore should be merged. This may or may not be true, but it's beside the point.

  • The Stack Exchange API doesn't support it, but no doubt you can write a userscript which mimics the browser requests. Perhaps have a look here if you need help.
    – Glorfindel Mod
    May 8 at 13:36
  • @Glorfindel thanks, is there any documentation about the API used by the browser? Ideally I would like to make one API call for this, instead of really mimicking what I do from the GUI — i.e. vote to close + edit dupe list
    – blackgreen
    May 8 at 13:42
  • no, because it's not really meant to be used like that. We still do it :)
    – Glorfindel Mod
    May 8 at 13:43
  • 1
    @blackgreen what's being used by the browser isn't API, it's AJAX calls to internal endpoints, with different code behind them. The API and those endpoints share methods for sure, but still, not same code at all. May 8 at 13:47
  • 2
    Similar concern as this FR but I approached it from another angle: Add keyboard shortcut for editing the list of duplicates
    – VLAZ
    May 8 at 14:18
  • 1
    UserScripters here - backlogged. As a quick FYI, SE API has a default API key when testing on the documentation page with the increased allowance of 10K requests per day. It also allows up to 300 unauthorized requests, but if you already have userscripts that consume the quota that might not be an option for you. May 8 at 15:05
  • ^ scrap the above note about the API, it just dawned on me that you were talking about this specific method that requires auth. May 8 at 15:15
  • What duplicate list? On the closed question? This? May 8 at 21:52
  • @This_is_NOT_a_forum yes, the list of dupe links of questions closed as dupes
    – blackgreen
    May 9 at 6:33
  • 1
    created userscript: stackapps.com/questions/9400/…
    – blackgreen
    May 11 at 9:00


You must log in to answer this question.

Browse other questions tagged .