LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmith_openapi_clientresourcestracesAsyncTracesResourcequery
Method●Since v0.10

query

Copy
query(
  self,
  *,
  cursor: str | Omit = omit
View source on GitHub
,
max_start_time
:
Union
[
str
,
datetime
]
|
Omit
=
omit
,
min_start_time
:
Union
[
str
,
datetime
]
|
Omit
=
omit
,
page_size
:
int
|
Omit
=
omit
,
project_id
:
str
|
Omit
=
omit
,
selects
:
List
[
RunSelectField
]
|
Omit
=
omit
,
trace_filter
:
str
|
Omit
=
omit
,
trace_ids
:
SequenceNotStr
[
str
]
|
Omit
=
omit
,
tree_filter
:
str
|
Omit
=
omit
,
extra_headers
:
Headers
|
None
=
None
,
extra_query
:
Query
|
None
=
None
,
extra_body
:
Body
|
None
=
None
,
timeout
:
float
|
httpx
.
Timeout
|
None
|
NotGiven
=
not_given
)
->
AsyncPaginator
[
Trace
,
AsyncItemsCursorPostPagination
[
Trace
]
]

Parameters

NameTypeDescription
cursorstr | Omit
Default:omit

cursor is the opaque string returned in a previous response's next_cursor.

max_start_timeUnion[str, datetime] | Omit
Default:omit
min_start_timeUnion[str, datetime] | Omit
Default:omit
page_sizeint | Omit
Default:omit
project_idstr | Omit
Default:omit
selectsList[RunSelectField] | Omit
Default:omit
trace_filterstr | Omit
Default:omit
trace_idsSequenceNotStr[str] | Omit
Default:omit
tree_filterstr | Omit
Default:omit
extra_headersHeaders | None
Default:None
extra_queryQuery | None
Default:None
extra_bodyBody | None
Default:None
timeoutfloat | httpx.Timeout | None | NotGiven
Default:not_given

Returns a paginated list of traces (root runs) for a single tracing project. Each item carries the trace's root run plus optional trace-wide aggregates (total_tokens, total_cost, first_token_time) under trace_aggregates, so clients never have to merge by trace_id.

Traces are scanned within a start_time window: min_start_time defaults to 24 hours before the request, max_start_time defaults to the request time. Set either explicitly to widen or narrow the window.

Supports filters (trace_filter, tree_filter), cursor pagination (cursor), and field projection (selects).

max_start_time is the exclusive upper bound for the root-run start time scan (RFC3339). Defaults to the request time when omitted.

min_start_time is the inclusive lower bound for the root-run start time scan (RFC3339). Defaults to 24 hours before the request when omitted.

page_size is the maximum number of traces to return per page. Defaults to 20; must be between 1 and 100 when set.

project_id is the UUID of the tracing project that owns the traces. Required.

selects lists which properties to include on each returned trace. Properties listed here are routed to the appropriate sub-object on each item: total_tokens, total_cost, and first_token_time appear under trace_aggregates; everything else appears under root_run. If omitted, only id is returned on root_run.

trace_filter narrows results to traces whose root run matches this LangSmith filter expression. This filter targets root runs only — is_root = true is implied. See https://docs.langchain.com/langsmith/trace-query-syntax#filter-query-language for syntax.

trace_ids is an optional fast-path restriction to a known set of trace UUIDs. Equivalent in result to including each UUID in a trace_filter, but more efficient at scale.

tree_filter narrows results to traces containing at least one run anywhere in the run tree (root or descendant) that matches this LangSmith filter expression.

Send extra headers

Add additional query parameters to the request

Add additional JSON properties to the request

Override the client-level default timeout for this request, in seconds