# What Are Stack Data Queries?

Stack data query opcodes differ from other Bitcoin Script operations because they **provide information** **rather than transform data**. Instead of modifying stack contents, they measure and report on stack characteristics.

Think of stack queries as diagnostic tools. Just as a doctor checks vital signs before treatment, scripts use stack queries to assess conditions before proceeding with validation or computation.

**Two fundamental queries:**

| Word      | Input | Output           | Description                                  |
| --------- | ----- | ---------------- | -------------------------------------------- |
| OP\_DEPTH | items | items, qty items | Counts stack items and pushes the count      |
| OP\_SIZE  | item  | item, item size  | Measures top item length without removing it |

**Key characteristic:** Both opcodes are **non-destructive**—they leave the original stack contents intact while adding measurement information.

<figure><img src="/files/SOfXLyGr0KGwXARDckD5" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bsv-opcodes/stack-data-queries/what-are-stack-data-queries.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
