Analytics Queries (Preview)
By the end of this page you can combine measures, groupings and filters freely and get trends, rankings and distributions directly.
Results are aggregated rows, with no bodies; they can’t be used as a list of documents. For raw records, use browse, bulk exports or the change feed.
Note: This is a Preview feature. Sources and endpoints marked “coming soon” are still being validated; don’t depend on them in production.
Step 1: See what you can query
curl -sS "$WHALE_BASE_URL/v1/analytics/meta" \
-H "Authorization: Bearer $WHALE_API_KEY"Returns the sources your application can query, with each source’s measures and dimensions:
{
"sources": [
{
"name": "sentiment",
"description": "Latest sentiment analysis per document",
"measures": [
{"name": "sentiment.documents", "title": "Documents", "type": "number"},
{"name": "sentiment.score_avg", "title": "Average sentiment score", "type": "number"}
],
"dimensions": [
{"name": "sentiment.source_platform", "title": "Platform", "type": "string"},
{"name": "sentiment.label", "title": "Sentiment (negative / neutral / positive)", "type": "string"},
{"name": "sentiment.published_at", "title": "Published at", "type": "time"}
]
}
]
}This endpoint is authoritative: only the sources and members it lists can be queried.
Step 2: Run a query
Weekly English document counts and average sentiment in October, by platform and sentiment:
curl -sS "$WHALE_BASE_URL/v1/analytics/query" \
-H "Authorization: Bearer $WHALE_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"measures": ["sentiment.documents", "sentiment.score_avg"],
"dimensions": ["sentiment.source_platform", "sentiment.label"],
"timeDimensions": [{
"dimension": "sentiment.published_at",
"granularity": "week",
"dateRange": ["2026-10-01", "2026-10-31"]
}],
"filters": [{"member": "sentiment.language", "operator": "equals", "values": ["en"]}],
"order": {"sentiment.documents": "desc"},
"limit": 100
}'{
"data": [
{
"sentiment.source_platform": "reddit",
"sentiment.label": "negative",
"sentiment.published_at.week": "2026-10-06T00:00:00.000",
"sentiment.documents": "1840211",
"sentiment.score_avg": "-0.7461"
}
],
"refreshed_at": "2026-11-03T12:05:21Z"
}Numbers are returned as strings so large integers keep their precision.
| Field | Meaning |
|---|---|
measures | Required, 1 to 10 measures |
dimensions | Up to 5 grouping dimensions |
timeDimensions | Required, exactly one: the time dimension, optional granularity (day, week, month, quarter, year) and dateRange |
dateRange | ["YYYY-MM-DD", "YYYY-MM-DD"], both days inclusive, UTC. Up to 92 days (content_live 31, metric_growth 7). Relative ranges like “last 7 days” aren’t supported |
filters | Each has member, operator and values. Operators: equals, notEquals, contains, gt, gte, lt, lte, set, notSet |
order | Sorting, such as {"sentiment.documents": "desc"} |
limit, offset | Default 1000 rows, up to 10000; offset up to 100000 |
All measures, dimensions and filters in one query must come from the same source.
Choose a source
| Source | One row is | Time dimension | Field access needed |
|---|---|---|---|
new_documents | A newly ingested document | published_at or stored_at (ingest time) | identity |
metrics_latest | A document’s latest metrics | published_at | metrics |
metric_history | One collection’s metrics, since 2026-07-01 | metric_time (collection time) | metrics |
sentiment | A document’s latest sentiment | published_at | affect |
affect_labels | A document’s latest emotion (kind=emotion) and intent (kind=intent) labels | published_at | Emotions need affect, intents need intents |
entities | Entity mentions, since 2026-10-29 | day (analysis date) | entities |
content_live | One row per document with metrics, channel, sentiment, emotion, intent and author, for cross-analysis and rankings | published_at | identity, plus the table below |
metric_growth (coming soon) | Each document’s metric change within a window | window (collection time) | metrics |
content_live also needs access for the members you use:
| Members | Also needs |
|---|---|
Metrics (view_count_*, like_count_*, score_* and so on) | metrics |
sentiment, sentiment_score_avg, emotion | affect |
intent | intents |
author_id, author_name, author_followers | author |
channel | metadata |
Access limits:
- Access limited by region: no source can be used.
- Access limited by language: only
sentiment,affect_labels,entitiesandcontent_live. - Access limited by publish time: not
metric_history,entitiesormetric_growth.
Common questions
Top 10 by likes
Use content_live, grouped by document_id and sorted:
{
"measures": ["content_live.like_count_max"],
"dimensions": ["content_live.document_id", "content_live.author_name", "content_live.source_platform"],
"timeDimensions": [{"dimension": "content_live.published_at", "dateRange": ["2026-10-28", "2026-11-03"]}],
"order": {"content_live.like_count_max": "desc"},
"limit": 10
}To rank authors or channels, switch the dimension to content_live.author_name or content_live.channel and use documents or *_sum.
Look at distributions, not just averages
*_p50, *_p90 and *_p99 are approximate medians and percentiles, available only in content_live. Compare them with the average so a few viral posts don’t skew the picture:
{
"measures": ["content_live.like_count_p50", "content_live.like_count_p90", "content_live.like_count_avg"],
"dimensions": ["content_live.source_platform"],
"timeDimensions": [{"dimension": "content_live.published_at", "dateRange": ["2026-10-01", "2026-10-31"]}]
}Sentiment versus likes
In content_live, metrics sit in the same row as sentiment, emotion, intent and channel. For example, average likes by sentiment: measure content_live.like_count_avg, dimension content_live.sentiment. Up to 31 days per query; query longer periods month by month.
Fastest-growing documents (coming soon)
metric_growth takes each document’s last minus first collected value within the window, counting only documents collected at least twice:
{
"measures": ["metric_growth.like_count_gain_max"],
"dimensions": ["metric_growth.document_id", "metric_growth.source_platform"],
"timeDimensions": [{"dimension": "metric_growth.window", "dateRange": ["2026-11-01", "2026-11-03"]}],
"order": {"metric_growth.like_count_gain_max": "desc"},
"limit": 20
}Growth can be negative, for example when likes are withdrawn.
Entities versus metrics (coming soon)
In entities, *_avg and *_sum are the latest metrics of documents mentioning the entity. For example, filter entities.entity to one entity and group by entities.entity_sentiment to see entities.like_count_avg.
Analyze only search results (coming soon)
Narrow documents with a keyword first, then run a content_live query on them. For example, “sentiment and median likes for documents mentioning iPhone”:
curl -sS "$WHALE_BASE_URL/v1/analytics/search-query" \
-H "Authorization: Bearer $WHALE_API_KEY" \
-H "Content-Type: application/json" \
--data '{
"search": {"query": "iphone", "source_platforms": ["reddit"], "max_documents": 1000},
"query": {
"measures": ["content_live.documents", "content_live.like_count_p50"],
"dimensions": ["content_live.sentiment"],
"timeDimensions": [{"dimension": "content_live.published_at", "dateRange": ["2026-10-05", "2026-11-03"]}]
}
}'| Field | Meaning |
|---|---|
search.query | Keyword, same rules as keyword search; takes the top max_documents by relevance |
search.source_platforms, search.languages | Optional; narrow the search |
search.published_from, search.published_to | Optional, RFC 3339 times |
search.max_documents | Documents included; default and maximum 1000 |
query | A content_live query, same rules as above |
The response adds documents_matched: the number of documents found and analyzed.
How fresh the data is
refreshed_at is when the rollup last refreshed:
| Source | Refresh |
|---|---|
metric_history, new_documents by ingest time | Hourly, last two days |
entities | Every 6 hours, last two days |
| Other rollups | Every 6 hours |
content_live, metric_growth | Computed at query time; no refreshed_at |
How measures are computed
*_avgaverage,*_sumtotal,*_maxmaximum,*_documentsdocuments that have the metric.- Metrics a platform doesn’t provide are empty and excluded from averages and counts. See the field reference for each platform’s metrics.
scoreis the Reddit score (upvotes minus downvotes), not likes.metrics_latesttakes each document’s most recent collection.- In
metric_history, one row is one collection, so a document appears several times;snapshotsis the snapshot count. Usemetrics_latestto count per document. new_documentscounts each document once, at first ingest.entitiescounts mentions extracted from each version;entityis the normalized name. When one document mentions the same entity with different attitudes, each counts once. Entity types are in sentiment, entities & intents.- In
content_live,sentiment,emotionandintentcome from the latest analysis;emotionandintenttake the top-scoring one.channelcurrently covers Reddit subreddits only. - When emotion or intent isn’t clear, the label is
none.
When something fails
422 analytics_not_answerable: this combination can’t be answered from the rollups, for example hourly totals. Change dimensions or granularity.503 analytics_unavailable: temporarily unavailable, or a direct computation timed out. Shorten the range or add filters, then retry.
Other errors: Error codes.