Skip to main 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.
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.

Sample response

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.

Sample response

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.
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.

Tune how many snippets you get

Pass an object instead of true to bound how many snippets come back, and how large each one is: max_snippets, max_snippets_per_result, max_tokens, and max_tokens_per_result. max_snippets and max_tokens bound the total across every document in the response; the _per_result fields bound a single document. See the Search API Reference for each field’s range and default. See Errors for how an out-of-range value is rejected. The example below caps each document at 2 snippets:

Sample response