I am afraid the query history resides in your browser, not the couchbase cluster, so the only thing you can do is export it through the UI, there 's no REST endpoint because the cluster doesn’t have any visibility of the history at all. @eben anything you can add?
As @Marco_Greco notes, the query history is stored in the browser’s local storage, so a REST API to retrieve it is not possible. There is an option to export query history as JSON, with or without the query results. See the EXPORT button in the upper right of the screen:
That brings up a dialog that lets you select what you want to export.