Grafana Queries API

The Queries API from Grafana — 6 operation(s) for queries.

Operations 3

GET /query-history Grafana Search Queries #
POST /query-history/star/{query_history_uid} Grafana Star Query #
DELETE /query-history/star/{query_history_uid} Grafana Unstar Query #

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/grafana-queries-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

grafana-queries-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  title: Grafana Queries API
  description: 'Grafana is an open-source analytics and visualization platform that helps you monitor and analyze data from various sources. It lets you create customizable dashboards with charts, graphs, and alerts to visualize metrics and logs in real-time. Commonly used for monitoring infrastructure, applications, and business metrics, Grafana connects to dozens of data sources like Prometheus, Elasticsearch, and cloud platforms, making it easier to understand system performance, troubleshoot issues, and track key indicators all in one place. '
  contact:
    name: Grafana Labs
    url: https://grafana.com
    email: hello@grafana.com
  version: 0.0.1
servers:
- url: http://{defaultHost}
  variables:
    defaultHost:
      default: www.example.com/api
- url: https://{defaultHost}
  variables:
    defaultHost:
      default: www.example.com/api
security:
- basic: []
- api_key: []
tags:
- name: Queries
paths:
  /query-history:
    parameters: []
    get:
      tags:
      - Queries
      summary: Grafana Search Queries
      description: Retrieves a paginated list of query history entries from Grafana based on specified search criteria. This endpoint allows users to filter and search through their saved query history, returning matching queries along with relevant metadata such as query text, timestamp, data source information, and user details. The operation supports various filtering parameters to narrow down results and includes pagination controls to manage large result sets efficiently.
      operationId: searchQueries
      parameters:
      - name: datasourceUid
        in: query
        description: List of data source UIDs to search for
        style: form
        explode: true
        schema:
          type: array
          items:
            type: string
      - name: searchString
        in: query
        description: Text inside query or comments that is searched for
        style: form
        explode: true
        schema:
          type: string
      - name: onlyStarred
        in: query
        description: Flag indicating if only starred queries should be returned
        style: form
        explode: true
        schema:
          type: boolean
      - name: sort
        in: query
        description: Sort method
        style: form
        explode: true
        schema:
          allOf:
          - $ref: '#/components/schemas/sort'
          - description: Sort method
      - name: page
        in: query
        description: Use this parameter to access hits beyond limit. Numbering starts at 1. limit param acts as page size.
        style: form
        explode: true
        schema:
          type: integer
          contentEncoding: int64
      - name: limit
        in: query
        description: Limit the number of returned results
        style: form
        explode: true
        schema:
          type: integer
          contentEncoding: int64
      - name: from
        in: query
        description: From range for the query history search
        style: form
        explode: true
        schema:
          type: integer
          contentEncoding: int64
      - name: to
        in: query
        description: To range for the query history search
        style: form
        explode: true
        schema:
          type: integer
          contentEncoding: int64
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryHistorySearchResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
  /query-history/star/{query_history_uid}:
    parameters: []
    post:
      tags:
      - Queries
      summary: Grafana Star Query
      description: This API operation allows users to mark a specific query in Grafana's query history as a favorite by starring it. By sending a POST request to the endpoint with a unique query history identifier (query_history_uid), users can flag important or frequently used queries for easier access and reference later. The starred status helps organize and prioritize queries within the query history, making it simpler to locate and reuse commonly executed queries without having to search through the entire history or recreate them from scratch.
      operationId: starQuery
      parameters:
      - name: query_history_uid
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryHistoryResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
    delete:
      tags:
      - Queries
      summary: Grafana Unstar Query
      description: The Grafana unstar query operation is accessed via a DELETE request to the endpoint /query-history/star/{query_history_uid}, where the query_history_uid parameter represents the unique identifier of a previously executed query in the query history. This operation removes the star or favorite marking from a specific query, effectively unmarking it as a saved or bookmarked item in the user's query history. When invoked, it allows users to unmark queries they no longer wish to highlight or quickly access, helping maintain a cleaner and more relevant collection of starred queries within their Grafana workspace.
      operationId: unstarQuery
      parameters:
      - name: query_history_uid
        in: path
        description: ''
        required: true
        schema:
          type: string
      responses:
        '200':
          description: (empty)
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryHistoryResponse'
        '401':
          description: UnauthorizedError is returned when the request is not authenticated.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '500':
          description: InternalServerError is a general error indicating something went wrong internally.
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      deprecated: false
      x-api-evangelist-processing:
        SplitPascalCaseOperationSummaries: true
        CaselCaseOperationIds: true
        WriteDescription: true
        ChooseTags: true
components:
  schemas:
    QueryHistoryDTO:
      title: QueryHistoryDTO
      type: object
      properties:
        comment:
          type: string
        createdAt:
          type: integer
          contentEncoding: int64
        createdBy:
          type: integer
          contentEncoding: int64
        datasourceUid:
          type: string
        queries:
          type: object
        starred:
          type: boolean
        uid:
          type: string
    QueryHistoryResponse:
      title: QueryHistoryResponse
      type: object
      properties:
        result:
          $ref: '#/components/schemas/QueryHistoryDTO'
      description: QueryHistoryResponse is a response struct for QueryHistoryDTO
    sort:
      title: sort
      enum:
      - time-desc
      - time-asc
      type: string
    QueryHistorySearchResult:
      title: QueryHistorySearchResult
      type: object
      properties:
        page:
          type: integer
          contentEncoding: int64
        perPage:
          type: integer
          contentEncoding: int64
        queryHistory:
          type: array
          items:
            $ref: '#/components/schemas/QueryHistoryDTO'
          description: ''
        totalCount:
          type: integer
          contentEncoding: int64
    ErrorResponseBody:
      title: ErrorResponseBody
      required:
      - message
      type: object
      properties:
        error:
          type: string
          description: Error An optional detailed description of the actual error. Only included if running in developer mode.
        message:
          type: string
          description: a human readable version of the error
        status:
          type: string
          description: 'Status An optional status to denote the cause of the error.


            For example, a 412 Precondition Failed error may include additional information of why that error happened.'
    QueryHistorySearchResponse:
      title: QueryHistorySearchResponse
      type: object
      properties:
        result:
          $ref: '#/components/schemas/QueryHistorySearchResult'
  securitySchemes:
    api_key:
      type: apiKey
      name: Authorization
      in: header
    basic:
      type: http
      scheme: basic