AmanSehgal
Honored Contributor III

Use the above API with HTTP security scheme type.

http://<db_worksapce>.cloud.databricks.com/api/2.0/sql/history/queries

Create a PAT Token in warehouse and use it for bearer token.

Say you want to generate your report for 13th July +0 UTC and 14th July +0 UTC.

Start time: Jul 13 2022 00:00:00 - start_time_ms: 1657720800000

End time: Jul 14 2022 00:00:00 - end_time_ms: 1657756800000

Your request will look like this:

{
    "filter_by": {
        "query_start_time_range": {
            "end_time_ms": 1657756800000,
            "start_time_ms": 1657720800000
 
    },
    "statuses":["FINISHED","FAILED"],
    "warehouse_ids":
        [
            "<warehouse_id>"
        ]
    },
    "include_metrics": true,
    "max_results": 100
}

In response from the API, the number of entries inside "res" is equal to number of queries run per day on your provided warehouse_id.