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

# Get snippets

> How to retrieve the highest-scoring passages from a document instead of its full content.

To get the passages of a document most relevant to your query, set `fields.snippets` to `true`. Each result's `snippets` array holds its highest-scoring passages, in the order they appear in the document, so you can work with focused excerpts instead of a document's full `content`.

<Note>
  Snippets are available on the `news` and `wikipedia` scopes. The `companies` and `people` scopes don't produce snippets; `snippets` comes back as an empty array for those scopes even when requested.
</Note>

<CodeGroup>
  ```python Python theme={null}
  from seltz import Seltz

  client = Seltz()

  response = client.search(
      "climate change",
      fields={"snippets": True},
  )

  for document in response.documents:
      print(document.url)
      for snippet in document.snippets:
          print(f"  {snippet.text}")
  ```

  ```typescript TypeScript theme={null}
  import { Seltz } from "seltz";

  const client = new Seltz();

  const result = await client.search({
    query: "climate change",
    fields: { snippets: true },
  });

  for (const doc of result.documents) {
    console.log(doc.url);
    for (const snippet of doc.snippets) {
      console.log(`  ${snippet.text}`);
    }
  }
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.seltz.ai/v1/search \
    -H "x-api-key: $SELTZ_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"query": "climate change", "fields": {"snippets": true}}'
  ```
</CodeGroup>

### Sample response

```json theme={null}
{
  "documents": [
    {
      "url": "https://www.newswire.ca/news-releases/government-of-canada-releases-new-climate-report-supporting-climate-resilience-planning-861430564.html",
      "published_date": "2026-09-03T20:26:00Z",
      "snippets": [
        {
          "text": "The Government of Canada is releasing its five-year scientific report today to inform planning, resilience-building, and emergency preparedness in a changing climate."
        },
        {
          "text": "Underscoring the importance of integrating climate change considerations into existing planning and decision-making processes across all sectors, Canada's Changing Climate Report 2026 contributes to the implementation of the National Adaptation Strategy."
        },
        {
          "text": "The federal government is committed to fighting climate change and reaching net-zero by 2050 by taking a pragmatic and durable approach."
        }
      ]
    }
  ]
}
```

## Get snippets alongside content

`fields` selects each member independently, so request `content` and `snippets` together to get both the full document and its top passages in one response.

<CodeGroup>
  ```python Python theme={null}
  from seltz import Seltz

  client = Seltz()

  response = client.search(
      "climate change",
      fields={"content": True, "snippets": True},
  )

  for document in response.documents:
      print(document.url)
      print(document.content)
      for snippet in document.snippets:
          print(f"  {snippet.text}")
  ```

  ```typescript TypeScript theme={null}
  import { Seltz } from "seltz";

  const client = new Seltz();

  const result = await client.search({
    query: "climate change",
    fields: { content: true, snippets: true },
  });

  for (const doc of result.documents) {
    console.log(doc.url);
    console.log(doc.content);
    for (const snippet of doc.snippets) {
      console.log(`  ${snippet.text}`);
    }
  }
  ```

  ```bash cURL theme={null}
  curl -X POST https://api.seltz.ai/v1/search \
    -H "x-api-key: $SELTZ_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"query": "climate change", "fields": {"content": true, "snippets": true}}'
  ```
</CodeGroup>

### Sample response

```json theme={null}
{
  "documents": [
    {
      "url": "https://www.newswire.ca/news-releases/government-of-canada-releases-new-climate-report-supporting-climate-resilience-planning-861430564.html",
      "content": "# Government of Canada releases new climate report supporting climate resilience planning\n\nThe Government of Canada is releasing its five-year scientific report today to inform planning, resilience-building, and emergency preparedness in a changing climate.\n\nUnderscoring the importance of integrating climate change considerations into existing planning and decision-making processes across all sectors, Canada's Changing Climate Report 2026 contributes to the implementation of the National Adaptation Strategy. The Government of Canada is conducting rigorous science and presenting it in accessible ways so everyone can benefit from this knowledge.\n\n... (3,919 characters total)",
      "published_date": "2026-09-03T20:26:00Z",
      "snippets": [
        {
          "text": "Our government is resolute in our commitment to fighting climate change and reaching net-zero by 2050."
        }
      ]
    }
  ]
}
```

`content` here carries the article's full 3,919 characters; `snippets` picked out a single sentence from a minister's quote near the end of the piece, well past where this truncated `content` preview ends.

<Note>
  `fields.content` defaults to `true`, so omitting `fields` entirely returns `content` but not `snippets`. Once you pass a `fields` object, only the members you set to `true` are populated. Set `content` explicitly if you still want it alongside `snippets`.
</Note>
