Backend API to get query result

Is there a backend API to execute the queries and get the queries results? The use case is, I want to add e2e test for some self-defined dashboards. Basically, given some existing data in the datasource, I want to verify the query results are expected.

By browsing the HTTP API | Grafana documentation, I don’t see there’s such an API. Any help would be much appreciated.

1 Like

Dear Anlan,

Your use case resonates with us.


The Grafana frontend is making requests to its backend server, that definitively qualifies as an API. You can inspect the requests using your favorite Browser’s developer tools.

However, while the HTTP endpoints are standardized, the payloads are not. The queries sent to the corresponding datasource endpoints will differ based on the type of database you are talking to. That is probably why the corresponding endpoints, for example, are not part of the official HTTP API reference.

A check program from our pen

We don’t do sophisticated e2e tests, but we are running a check program on our Icinga instance which verifies given data sources through the HTTP API against becoming stale and alerts us when they do, taking configurable freshness time thresholds into account.

You might want to use it as a starting point for inspiration.


At the usage-by-example documentation, you can inspect the options to use for the program. Those options are necessary to direct it to the right data source:

--database testdrive
--table temperature

At, you can see that the program is sending a query that is specifically suited for InfluxDB 1.x. With other datasource types, you would need to send a different query. In order to make the program more universal, it could be improved so that the query expression would also be obtained as command line option.


With kind regards,

Thanks for the detailed explanation, Andreas. It is very helpful!

A quick question on the api/ds/query. Isn’t it used to execute and retrieve query result?