Download Markdown

Data Access Path · 3/7

Recommended reading order, not completion status. Optional steps can be skipped.

View all steps

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

Search for a keyword

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

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. Without platforms, every platform in your access is searched.

Page through all results

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; to take a lot at once, use bulk exports.

Filter by sentiment, entities and intent

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"]
}
ParameterValuesMultiple values
sentimentspositive, negative, neutralAny of them
emotionsanger, disgust, fear, joy, sadness, surprise, neutralAny of them
entitiestype:name (such as brand:Xiaomi) or just a name, up to 10All must be mentioned
intentsSee read intentsAny of them
quality_statusesnormal, low, spam, duplicate, emptyAny 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

ParameterEffect
fieldsReturn only the listed fields, for smaller responses
include_highlightsReturn highlights marked with <em>
include_chunksReturn each matching chunk in matched_chunks
include_non_currentLet older versions match too; results are still one per document

Collect fresh data at the same time

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.

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.

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

EndpointUse
POST /v1/search/historySearches stored data only, never triggers collection. The recommended default
POST /v1/searchSame, 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).

All parameters: API reference.

When results are incomplete

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

warnings[].codeMeaningWhat to do
keyword_search_partialTimed out before searching everything; newest content may be missingNarrow platforms, time range or keywords, then retry
keyword_search_timed_outThe search timed out; results are emptySame as above
live_query_unavailableLive collection wasn’t created; only stored results returnedRetry later, or create a live query directly

When something fails

See Error codes.

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.

Not needed? Skip optional steps: Read Content & Versions