---
title: "List query history"
method: GET
path: "/api/{org_id}/query_history"
tags: ["Query History"]
---

# List query history

`GET /api/{org_id}/query_history`

## Request

- Base URL: `https://api.openobserve.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.openobserve.ai/api/{org_id}/query_history`
- Auth: API key in header `Authorization`
- TypeScript: <https://skmtc.dev/openobserve/apis/openobserve-api-http/docs/api/:org_id/query_history/get.ts> (a function with typed inputs; its response is checked against the schema)

Lists the caller's query history, most recently run first. With count_only=true it answers {"count": n} (QueryHistoryCountResponse), the number of entries the filters match. Empty, or a count of 0, when ZO_QUERY_HISTORY_ENABLED is false.

## Path parameters

- `org_id` string, required

## Query parameters

- `source` string
- `status` string
- `stream` string
- `q` string
- `starred` boolean
- `ran_from` integer
- `ran_to` integer
- `limit` integer
- `offset` integer
- `count_only` boolean

## Response `200`

The entries, or with count_only=true the count

- union: The entries, or with `count_only=true` how many entries match.
  - QueryHistoryEntry[]
    - `context` unknown, required
    - `created_at` integer, required: First run, in microseconds since the epoch; the last run on entries recorded by v1.1.x.
    - `id` string, required: Entry id.
    - `query` string, required: The query text.
    - `query_key` string, nullable: Hex sha256 of the merge key; null on entries recorded before keys existed.
    - `run_count` integer, required: How many runs merged into this entry; 1 on entries recorded by v1.1.x.
    - `source` string, required: Page the query ran on.
    - `starred` boolean, required: Starred entries are kept until deleted.
    - `status` string, required: `ok` or `error`, from the latest run; `ok` on entries recorded by v1.1.x.
    - `streams` string[], required: Streams the query ran on.
    - `updated_at` integer, required: Latest run, in microseconds since the epoch.
  - QueryHistoryCountResponse
    - `count` integer, required: Entries matching the filters, ignoring limit and offset.

## Other responses

- `400`: Unknown source or status, or an offset above 9223372036854775807
- `500`: Failure

---

[API](https://skmtc.dev/openobserve/apis/openobserve-api-http.md) - [All operations](https://skmtc.dev/openobserve/apis/openobserve-api-http/llms.txt) - [OpenAPI document](https://skmtc.dev/openobserve/apis/openobserve-api-http/revisions/0529b8a10252?raw)
