- Every query is JSON. There is no query language as text: a saved view or an alert keeps the JSON.
- The server, the Node package and the Python package take the same JSON. The examples here use the server and
curl. The library calls have their own page. - The examples come from
testdata/query-examples.json. The server, Node and Python tests run every example in that file and check each answer. The answers in these pages were made again on 2026-12-04 by the commands on the pages.
The sample data
The sample has 3 traces with 7 spans, and 15 scores. Times are small numbers (milliseconds after 1970), so the answers are easy to read.
The texts:
r1 “please refund my order” / “refund policy applies”; m1 “what is the refund policy” / “the refund policy is thirty days”; m2 “policy refund”; r3 “refund”; tl3 “refund lookup”; r2 “hello world”; tl1 “lookup order” and a JSON text with Thai in it.
Load it into a new store and start a server on it. You need jq here, and magpie-server on your PATH (see the quickstart):
Routes
The full reference of every route and field: the server reference, “Query API”.
Where to go next
Find text
Words, phrases, pieces of words, prefixes and error text.
Filter spans
Fields, attributes, time ranges, and AND, OR, NOT.
Whole traces and pages
Questions about whole traces, previews, and cursors.
Add up numbers
Exact sums, top N, time series and percentiles.
Sessions and scores
Conversations, evals and feedback.
Read and export
Read one trace, one span, or export spans as JSON Lines.
The same queries in the library
The Node and Python calls for each route.
When a query is wrong
A query with an unknown field, or a value of the wrong type, gets400. It is never read as “match everything”. The message gives the place and what was expected. It never quotes the request (a prompt can be private), so the server cuts the value out and gives a short hash and a length: