---
title: Keyword Search
description: Search stored documents by keyword, platform, time range and analysis results, and page through all matches.
type: guide
status: stable
updated: 2026-12-03
url: /en/docs/search
markdown: /en/docs/search.md
---

## Data Access Path

Recommended reading order, not a record of completed steps. Optional steps can be skipped.

1. [Get an API Key](/en/docs/authentication)
2. [Make Your First Query in 5 Minutes](/en/docs/quickstart)
3. [Keyword Search](/en/docs/search) ← current page
4. [Browse by User, Topic, Tag & Category](/en/docs/browse) (optional)
5. [Read Content & Versions](/en/docs/documents)
6. [Download Images & Attachments](/en/docs/attachments) (optional)
7. [Production Checklist](/en/docs/production)

**Before You Start**：Complete your first query and decide between keyword matching and exact author, topic or tag filters.

# Keyword Search

By the end of this page you can find documents by keyword, platform and time range, and page through every result.

To pull everything from a specific user, topic or tag, use [browse by filters](/en/docs/browse) instead.

## Search for a keyword [#basic]


```bash
curl -sS "$WHALE_BASE_URL/v1/search/history" \
  -H "Authorization: Bearer $WHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode": "keyword", "query": "electric vehicle", "limit": 20}'
```


Results are ranked by relevance:


```json
{
  "mode": "keyword",
  "results": [
    {
      "document_id": "doc_01J...",
      "source_platform": "reddit",
      "title": "...",
      "body": "matching snippet",
      "published_at": "2026-12-01T08:00:00Z",
      "score": 0.83
    }
  ],
  "total": 20,
  "cursor": "eyJv..."
}
```


The fields you'll use most:

- `document_id`: use it to [read the full body](/en/docs/documents).
- `body`: the matching snippet, not the full text.
- `score`: relevance for this search; not popularity or credibility.

A document appears at most once per page.

## Filter by platform, language and time [#filters]


```json
{
  "mode": "keyword",
  "query": "electric vehicle",
  "platforms": ["reddit", "x"],
  "languages": ["en"],
  "published_from": "2026-11-01T00:00:00Z",
  "published_to": "2026-12-01T00:00:00Z"
}
```


> Note: Without a time range, only documents published in the last 30 days are searched. To search older content, always pass `published_from`.

Platform values are listed in [platform coverage](/en/docs/platforms). Without `platforms`, every platform in your access is searched.

## Page through all results [#pagination]

If the response has a `cursor`, there's another page. Send it back unchanged in the next request and keep the other parameters the same:


```json
{"mode": "keyword", "query": "electric vehicle", "limit": 100, "cursor": "eyJv..."}
```


No `cursor` means this is the last page.

- Up to 100 documents per page.
- `total` is the count on this page, not the total number of matches.
- To keep syncing new data, use the [change feed](/en/docs/change-feed); to take a lot at once, use [bulk exports](/en/docs/exports).

## Filter by sentiment, entities and intent [#analysis]

You can filter by analysis results alongside the keyword, or drop `query` and filter only by these:


```json
{
  "mode": "keyword",
  "query": "battery",
  "sentiments": ["negative"],
  "entities": ["brand:Xiaomi"],
  "intents": ["complaint"]
}
```


| Parameter | Values | Multiple values |
| --- | --- | --- |
| `sentiments` | `positive`, `negative`, `neutral` | Any of them |
| `emotions` | `anger`, `disgust`, `fear`, `joy`, `sadness`, `surprise`, `neutral` | Any of them |
| `entities` | `type:name` (such as `brand:Xiaomi`) or just a name, up to 10 | All must be mentioned |
| `intents` | See [read intents](/en/docs/analysis-results#intents) | Any of them |
| `quality_statuses` | `normal`, `low`, `spam`, `duplicate`, `empty` | Any of them |

Required field access:

- Sentiment and emotion filters: `affect`
- Entity filters: `entities`
- Intent filters: `intents`

Only documents that have been analyzed can match. No match doesn't mean the document lacks that emotion or entity.

Sentiment buckets: a score above 0.3 is `positive`, below -0.3 is `negative`, otherwise `neutral`. Documents with confidence below 0.4 fall into no bucket.

## Return only what you need [#fields]

| Parameter | Effect |
| --- | --- |
| `fields` | Return only the listed fields, for smaller responses |
| `include_highlights` | Return highlights marked with `<em>` |
| `include_chunks` | Return each matching chunk in `matched_chunks` |
| `include_non_current` | Let older versions match too; results are still one per document |

## Collect fresh data at the same time [#live]

While searching stored data, you can ask the platform to collect a new batch. Use `/v1/search` and add `live`:


```bash
curl -sS "$WHALE_BASE_URL/v1/search" \
  -H "Authorization: Bearer $WHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "mode": "keyword",
    "query": "electric vehicle",
    "platforms": ["youtube"],
    "live": {"enabled": true, "resource_kind": "video", "deadline_seconds": 300}
  }'
```


The response returns stored results immediately, plus a `live_query`:


```json
"live_query": {
  "id": "lq_01J...",
  "status": "pending",
  "runs": [{"platform": "youtube", "status": "pending"}]
}
```


Read the newly collected data separately: use `live_query.id` to [poll and read the live query](/en/docs/live-query).

Requirements:

- An `Idempotency-Key` header is required.
- `platforms` must list 1 to 5 platforms.
- `live.resource_kind`: `content`, `account`, `user`, `channel` or `video`.

> Note: Live collection reserves credits per platform. See [live queries](/en/docs/live-query).

About the deadline:

- Collection can take more than 2 minutes. Set `deadline_seconds: 300` (10 to 900).
- The deadline counts from creation; queuing and retries don't extend it.
- The old `max_wait_seconds` is an alias for the deadline, not a wait time. Passing `10` ends collection after 10 seconds. Don't use it in new code.

## Choose an endpoint [#endpoints]

| Endpoint | Use |
| --- | --- |
| `POST /v1/search/history` | Searches stored data only, never triggers collection. The recommended default |
| `POST /v1/search` | Same, plus `live` collection |

`/v1/contents/search` and `/v1/search/keyword` are legacy; don't use them in new code. `mode=vector` and `mode=hybrid` are retired; see [vector analysis (retired)](/en/docs/analysis).

All parameters: [API reference](/en/public-api-reference).

## When results are incomplete [#degraded]

If part of the search backend times out, you still get `200`, with `degraded: true` and `warnings`:

| `warnings[].code` | Meaning | What to do |
| --- | --- | --- |
| `keyword_search_partial` | Timed out before searching everything; newest content may be missing | Narrow platforms, time range or keywords, then retry |
| `keyword_search_timed_out` | The search timed out; results are empty | Same as above |
| `live_query_unavailable` | Live collection wasn't created; only stored results returned | Retry later, or [create a live query](/en/docs/live-query) directly |

## When something fails [#errors]

See [Error codes](/en/docs/errors).

## Check and Continue

**Completion Check**：Use keyword mode with platform, time and field filters and cursor pagination; distinguish snippets and page counts from full bodies and global totals.

Previous step：[Make Your First Query in 5 Minutes](/en/docs/quickstart)

**Recommended Next Step**：[Browse by User, Topic, Tag & Category](/en/docs/browse) (optional; skip if not needed)

Skip optional steps：[Read Content & Versions](/en/docs/documents)
