> ## Documentation Index
> Fetch the complete documentation index at: https://agent-observability-docs.splunk.com/llms.txt
> Use this file to discover all available pages before exploring further.

# query_result

## Module

Query result wrapper for easy data access and pagination.

## QueryResult

A list-like wrapper for query results that provides easy access to records and pagination.

This class makes it simple to work with query results by:

* Providing list-like indexing and iteration (e.g., result\[0], for record in result)
* Flattening nested record structures into simple dictionaries
* Exposing pagination metadata (limit, next\_starting\_token, paginated)
* Offering a next\_page() method to easily fetch subsequent pages

**Examples**

# Basic iteration

agent\_stream = LogStream.get(name="Production Logs", project\_name="My AI Project")
result = log\_stream.get\_spans(limit=10)

for record in result:
print(record\["id"], record\["input"])

# Index access

first\_record = result\[0]
print(first\_record\["created\_at"])

# Pagination (in-place - extends the current result)

if result.has\_next\_page:
result.next\_page()
print(f"Now have \{len(result)} records after fetching next page")

# Pagination (with assignment - same object returned)

result = log\_stream.get\_spans(limit=10)
if result.has\_next\_page:
result = result.next\_page()
for record in result:
print(record\["id"])

# Check pagination status

print(f"Total records in this page: \{len(result)}")
print(f"Has next page: \{result.has\_next\_page}")

### has\_next\_page

```python theme={null}
def has_next_page(self) -> bool
```

Whether there is a next page available.

### last\_row\_id

```python theme={null}
def last_row_id(self) -> str | None
```

The ID of the last row in this result set.

### limit

```python theme={null}
def limit(self) -> int
```

The maximum number of records per page.

### next\_page

```python theme={null}
def next_page(self) -> QueryResult
```

Fetch the next page and extend current results.

**Examples**

# In-place usage (mutates the result)

result = log\_stream.get\_spans(limit=10)
if result.has\_next\_page:
result.next\_page()
print(f"Now have \{len(result)} records")

# Assignment usage (same object, supports chaining)

result = log\_stream.get\_spans(limit=10)
if result.has\_next\_page:
result = result.next\_page()
for record in result:
print(record\["id"])

### next\_starting\_token

```python theme={null}
def next_starting_token(self) -> int | None
```

Token for fetching the next page, or None if this is the last page.

### paginated

```python theme={null}
def paginated(self) -> bool
```

Whether pagination is enabled.

### starting\_token

```python theme={null}
def starting_token(self) -> int
```

The starting token used for this page.

### to\_list

```python theme={null}
def to_list(self) -> list[dict[str, Any]]
```

Convert the result to a plain list of dictionaries.

**Examples**

result = log\_stream.get\_spans()
records\_list = result.to\_list()
