Skip to main content
GET
Get Spans
Retrieve spans from the data warehouse with flexible filtering and pagination options. This endpoint returns spans from the environment associated with your API key. You can filter by time ranges, workflows, attributes, and more.

Request Parameters

from_timestamp_sec
int64
required
Start time in Unix seconds timestamp.
to_timestamp_sec
int64
End time in Unix seconds timestamp.
workflow
string
Filter spans by workflow name.
span_name
string
Filter spans by span name.
attributes
map[string]string
Simple key-value attribute filtering. Any query parameter not matching a known field is treated as an attribute filter.Example: ?llm.vendor=openai&llm.request.model=gpt-4
sort_order
string
Sort order for results. Accepted values: ASC or DESC. Defaults to ASC.
sort_by
string
Field to sort by. Supported values:
  • timestamp - Span creation time
  • duration_ms - Span duration in milliseconds
  • span_name - Name of the span
  • trace_id - Trace identifier
  • total_tokens - Total token count
  • traceloop_workflow_name - Workflow name
  • traceloop_entity_name - Entity name
  • llm_usage_total_tokens - LLM token usage
  • llm_response_model - LLM model used
cursor
string
Pagination cursor for fetching the next set of results. Use the next_cursor value from the previous response.
limit
int
Maximum number of spans to return per page.
filters
FilterCondition[]
Array of filter conditions to apply to the query. Each filter should have id, value, and operator fields. Filters must be URL-encoded JSON.Filter structure:
Supported operators:Example - Filter by LLM vendor:

Response

Returns a paginated response containing span objects:
spans
object

Span Object

environment
string
The environment where the span was captured.
timestamp
int64
The timestamp when the span was created (Unix milliseconds).
trace_id
string
The unique trace identifier.
span_id
string
The unique span identifier.
parent_span_id
string
The parent span identifier.
trace_state
string
The trace state information.
span_name
string
The name of the span.
span_kind
string
The kind of span (e.g., SPAN_KIND_CLIENT, SPAN_KIND_INTERNAL).
service_name
string
The name of the service that generated the span.
resource_attributes
map
Key-value pairs of resource attributes.
scope_name
string
The instrumentation scope name.
scope_version
string
The instrumentation scope version.
span_attributes
map
Key-value pairs of span attributes (e.g., llm.vendor, llm.request.model).
duration
int64
The duration of the span in milliseconds.
status_code
string
The status code of the span (e.g., STATUS_CODE_UNSET, STATUS_CODE_ERROR).
status_message
string
The status message providing additional context.
prompts
map
Prompt data associated with the span (for LLM calls).
completions
map
Completion data associated with the span (for LLM calls).
input
string
Input data for the span.
output
string
Output data for the span.

Example Response

Pagination

To paginate through results:
  1. Make an initial request without a cursor
  2. Use the next_cursor value from the response in subsequent requests
  3. Continue until next_cursor is empty or you’ve retrieved all needed data