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

# Understanding the Stemfard API JSON response structure

> Reference for the JSON object every Stemfard endpoint returns — all top-level fields, their types, and which api_level exposes each field.

Every Stemfard API response returns a consistent JSON object regardless of which endpoint you call. The fields present in a given response depend on the `api_level` you request and which optional parameters you enable. Understanding this structure helps you write resilient parsing logic and lets you display only the data your application actually needs.

## Top-level fields

<ResponseField name="metadata" type="object" required>
  Request metadata returned with every response. Includes the `result_name` used to key the answer in `result`, the `operation` name, and other contextual identifiers.

  <Expandable title="properties">
    <ResponseField name="result_name" type="string">
      The name used as the key for the computed answer in the `result` object. Defaults to `"ans"`. You can override this with the `result_name` request parameter.
    </ResponseField>

    <ResponseField name="operation" type="string">
      The mathematical operation performed (e.g., `"add"`, `"matmul"`, `"row-mean"`).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="taxonomy" type="object" required>
  Topic classification for the operation. Present in `lite`, `standard`, and `detailed` responses.

  <Expandable title="properties">
    <ResponseField name="topic" type="string">
      High-level mathematical domain (e.g., `"Linear Algebra"`).
    </ResponseField>

    <ResponseField name="subtopic" type="string">
      Narrower classification within the topic (e.g., `"Matrix Arithmetic"`, `"Matrix Statistics"`).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="result" type="object" required>
  The computed answer. The key inside this object matches the `result_name` from `metadata` (default `"ans"`). Present in all API levels.
</ResponseField>

<ResponseField name="problem" type="object">
  A human-readable statement of the problem. Present only in `detailed` responses.

  <Expandable title="properties">
    <ResponseField name="statement" type="string">
      Full problem statement as a string (e.g., `"Find the sum of matrices A and B"`).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="request_normalized" type="object">
  The normalized version of your input parameters as interpreted by the API. Returned when you set `request_params: true` in the request. Available in `detailed` mode only.
</ResponseField>

<ResponseField name="intermediate" type="object">
  Intermediate calculation data generated during computation. Present in `detailed` responses. Useful for debugging or displaying partial results.
</ResponseField>

<ResponseField name="steps" type="array">
  An ordered array of step-by-step solution objects. Present in `standard` and `detailed` responses. Each element describes one step in the solution process. The format of step content (HTML, LaTeX, or speech) is controlled by the `steps_output_formats` request parameter.

  <Expandable title="step object properties">
    <ResponseField name="step" type="integer">
      Step number, starting from 1.
    </ResponseField>

    <ResponseField name="description" type="string">
      Plain-text explanation of what this step does.
    </ResponseField>

    <ResponseField name="expression" type="string">
      The mathematical expression at this step, in the requested output format.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="related" type="array">
  Links to related Stemfard API endpoints. Only included in `detailed` responses when you set `related: true` in the request.

  <Expandable title="item properties">
    <ResponseField name="label" type="string">
      Human-readable label describing the related operation.
    </ResponseField>

    <ResponseField name="href" type="string">
      Full URL to the related endpoint.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="learning_pathways" type="array">
  Curated links to educational resources and pathway endpoints relevant to the operation. Only included in `detailed` responses when you set `learning_pathways: true` in the request.

  <Expandable title="item properties">
    <ResponseField name="label" type="string">
      Label for the learning pathway.
    </ResponseField>

    <ResponseField name="href" type="string">
      URL to the pathway resource.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="syntax" type="object">
  Usage hints and syntax guidance for the called endpoint. Present in `detailed` responses.

  <Expandable title="properties">
    <ResponseField name="hint" type="string">
      A short string showing the expected call signature (e.g., `"derivative(expression, variable)"`).
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="properties" type="object">
  Computed properties of the result object (e.g., degree, domain, whether the result is a polynomial). Returned when you set `properties: true` in the request. Available in `detailed` mode only.
</ResponseField>

## Field availability by level

| Field                | `lite` | `standard` |  `detailed`  |
| -------------------- | :----: | :--------: | :----------: |
| `metadata`           |   Yes  |     Yes    |      Yes     |
| `taxonomy`           |   Yes  |     Yes    |      Yes     |
| `result`             |   Yes  |     Yes    |      Yes     |
| `steps`              |    —   |     Yes    |      Yes     |
| `problem`            |    —   |      —     |      Yes     |
| `request_normalized` |    —   |      —     | Yes (opt-in) |
| `intermediate`       |    —   |      —     |      Yes     |
| `related`            |    —   |      —     | Yes (opt-in) |
| `learning_pathways`  |    —   |      —     | Yes (opt-in) |
| `syntax`             |    —   |      —     |      Yes     |
| `properties`         |    —   |      —     | Yes (opt-in) |

## Sample detailed response

The following example shows a complete `detailed` response with all optional fields enabled.

```json detailed response theme={null}
{
  "metadata": {
    "result_name": "product",
    "operation": "matmul"
  },
  "taxonomy": {
    "topic": "Linear Algebra",
    "subtopic": "Matrix Arithmetic"
  },
  "problem": {
    "statement": "Compute the matrix product of A and B"
  },
  "request_normalized": {
    "a": [[2, 7], [4, -1]],
    "b": [[1, 0], [0, 1]],
    "operation": "matmul"
  },
  "result": {
    "product": [[2, 7], [4, -1]]
  },
  "intermediate": {
    "steps_count": 4
  },
  "steps": [
    {
      "step": 1,
      "description": "Multiply row 1 of A by column 1 of B",
      "expression": "(2×1) + (7×0) = 2"
    },
    {
      "step": 2,
      "description": "Multiply row 1 of A by column 2 of B",
      "expression": "(2×0) + (7×1) = 7"
    },
    {
      "step": 3,
      "description": "Multiply row 2 of A by column 1 of B",
      "expression": "(4×1) + (-1×0) = 4"
    },
    {
      "step": 4,
      "description": "Multiply row 2 of A by column 2 of B",
      "expression": "(4×0) + (-1×1) = -1"
    }
  ],
  "related": [
    {
      "label": "Matrix addition",
      "href": "/api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/add"
    },
    {
      "label": "Matrix statistics",
      "href": "/api/v1/mathematics/linear-algebra/matrix-operations/matrix-statistics"
    }
  ],
  "learning_pathways": [
    {
      "label": "Matrix determinants",
      "href": "/api/v1/mathematics/linear-algebra/matrix-determinant"
    }
  ],
  "syntax": {
    "hint": "POST /api/v1/mathematics/linear-algebra/matrix-operations/matrix-arithmetic/matmul"
  },
  "properties": {
    "dimensions": [2, 2],
    "is_square": true
  }
}
```

<Info>
  The `result` object uses the value of `result_name` as its key. If you pass `result_name: "f_prime"` in the request, the answer appears as `result.f_prime` rather than `result.ans`.
</Info>
