Analytics Queries (Preview)
Analytics queries are for applications that aggregate data inside their own product: combine measures, grouping dimensions, filters and a time granularity, and get the aggregated result directly instead of pulling records and computing locally.
Preview. Most data sources come from summaries refreshed on a schedule;
content_liveandmetric_growthare computed on request for rankings, medians and percentiles, and growth, over shorter time ranges.
For records, use Read Content & History, Bulk Data Exports or Synchronize Data Changes.
Release and Data Scope
GET /v1/analytics/meta is the only accurate source for the data sources, measures, and dimensions an application can query now: it is filtered by both deployed capabilities and the application’s entitlement. The tables on this page describe the contract and field requirements; only sources and members actually returned by meta can be used with POST /v1/analytics/query.
Analytics returns aggregate rows, not bodies, raw payloads, or a complete set of documents for per-record retrieval. Use browse, document reads, snapshots, or Change Feed for atomic data; search results are not a complete export either.
Different sources use different time dimensions:
| Time dimension | Meaning | Typical sources |
|---|---|---|
published_at | When the source platform published the content | metrics_latest, sentiment, affect_labels, content_live |
stored_at | When Whale first stored the document | new_documents |
metric_time / window | Metric collection time or collection window | metric_history, metric_growth |
day | UTC date of automatic analysis | entities |
metric_growth and POST /v1/analytics/search-query are still in acceptance. Do not make them a customer production dependency until this page no longer labels them as coming soon; use sources returned by meta instead.
Requirements
Call with a Consumer API Key, as for other endpoints. The fields in the application’s entitlement decide which data sources it can query:
| Data source | Content | Required field |
|---|---|---|
new_documents | New documents, by publication time (published_at) or storage time (stored_at) | identity |
metrics_latest | Latest collected metrics of each document | metrics |
metric_history | Every collected metric snapshot, by snapshot time (metric_time), from 2026-07-01 | metrics |
entities | Entity mentions by analysis day (day), from 2026-10-29, optionally with the latest metrics of the mentioning documents (metrics coming soon) | entities; metrics also need metrics |
sentiment | Latest sentiment result of each document | affect |
affect_labels | Latest emotion labels (kind=emotion) and intent labels (kind=intent) of each document | affect for emotions, intents for intents |
content_live | One row per document with its latest metrics, channel, sentiment, top emotion and intent, document ID and author, for cross analysis (sentiment × likes, channel × score); computed on request for rankings, medians and percentiles; dateRange at most 31 days | identity, see below |
metric_growth (coming soon) | Metric change of each document within a window, by collection time (window); dateRange at most 7 days | metrics |
content_live needs more fields depending on the members used:
| 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 |
Results only cover the platforms, languages and publication times the entitlement allows. Client filters can narrow that scope, never widen it. These grants cannot be used for some sources:
- Limited to regions: no source.
- Limited to languages: only
sentiment,affect_labels,entitiesandcontent_live, which have a language dimension. - Limited to publication times: not
metric_history,entitiesormetric_growth, which have no publication time.
List measures and dimensions
curl "$MARSYOO_BASE_URL/v1/analytics/meta" \
--header "Authorization: Bearer $MARSYOO_API_KEY"Returns the data sources open to the application with their measures and dimensions, for example:
{
"sources": [
{
"name": "sentiment",
"description": "Latest sentiment result of each 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"}
]
}
]
}Titles and descriptions are currently returned in Chinese.
Query
curl -X POST "$MARSYOO_BASE_URL/v1/analytics/query" \
--header "Authorization: Bearer $MARSYOO_API_KEY" \
--header "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
}'| Field | Description |
|---|---|
measures | 1–10 measures, required |
dimensions | Up to 5 grouping dimensions |
timeDimensions | Required, exactly one: the source’s time dimension, an optional granularity (day, week, month, quarter, year) and dateRange |
dateRange | ["YYYY-MM-DD", "YYYY-MM-DD"], both days included, UTC, at most 92 days (31 for content_live, 7 for metric_growth); relative ranges such as “last 7 days” are not accepted |
filters | Each filter has member, operator and values; common operators: equals, notEquals, contains, gt, gte, lt, lte, set, notSet |
order | Sort, for example {"sentiment.documents": "desc"} |
limit / offset | Rows default to 1,000, at most 10,000; offset at most 100,000 |
All measures, dimensions and filters of one query must come from the same data source.
Common questions
Rankings: use content_live, grouped and sorted by document_id. For example the 10 most liked documents of the last week:
{
"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, group by content_live.author_name or content_live.channel and use documents or *_sum.
Distributions: *_p50, *_p90 and *_p99 on content_live are the median and percentiles (approximate); compare them with the average, which a few viral posts can skew:
{
"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"]}]
}Cross analysis: content_live has one row per document, so one query can combine metrics with sentiment, emotion, intent and channel. For example average likes by sentiment: measure content_live.like_count_avg, dimension content_live.sentiment. One query covers at most 31 days; split longer periods into monthly queries.
Entities × metrics (coming soon): *_avg and *_sum on entities are the latest metrics of the documents mentioning the entity, for example filter entities.entity to one entity and group entities.like_count_avg by entities.entity_sentiment.
Growth (coming soon): metric_growth takes the last minus the first collected value of each document within the window, counting only documents collected at least twice in it. Group by document_id and sort by like_count_gain_max for the fastest-growing documents:
{
"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
}Analyze search results (coming soon)
This endpoint is in acceptance testing; this note goes when it is live.
Select documents with a keyword search, then run a content_live query over them, for example the sentiment split and median likes of content mentioning iPhone:
curl -X POST "$MARSYOO_BASE_URL/v1/analytics/search-query" \
--header "Authorization: Bearer $MARSYOO_API_KEY" \
--header "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 | Description |
|---|---|
search.query | Keywords, as in the keyword retrieval of Search; the top max_documents by relevance are used |
search.source_platforms / languages | Optional, narrow the search |
search.published_from / published_to | Optional, RFC 3339 times |
search.max_documents | Documents analyzed, default and maximum 1,000 |
query | A content_live query, same rules as above |
The response adds documents_matched, the number of documents the search matched and the query analyzed.
Response
{
"data": [
{
"sentiment.source_platform": "reddit",
"sentiment.label": "negative",
"sentiment.published_at": "2026-10-06T00:00:00.000",
"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 in JSON.
refreshed_atis when the summaries were last refreshed.metric_historyandnew_documentsby storage time refresh their last two days every hour;entitiesrefreshes its last two days every 6 hours; the others every 6 hours. The newest data lags accordingly.content_liveandmetric_growthare computed on request and have norefreshed_at.
Metric semantics
metrics_latestcovers every document with a metric snapshot, each with its most recently collected metrics.- A metric a platform does not provide is null there and is left out of that metric’s average and document count. See Platform Coverage for which metrics each platform provides and how reliable they are.
*_avgis the average of a metric,*_sumthe total and*_documentsthe number of documents that have it,*_maxthe largest value;*_p50,*_p90and*_p99are approximate medians and percentiles, oncontent_liveonly.scoreis the Reddit score (upvotes minus downvotes), not a like count.- Each
metric_historyrow is one collection, and a document is collected many times:snapshotscounts snapshots,*_avgaverages them and*_maxis the largest value. Usemetrics_latestto count documents. new_documentscounts each document once, when it was first stored.entitiescounts entity mentions in the automatic extraction of every version, with the same types as the entity statistics;entityis the normalized name. Metrics count once per document, entity and mention sentiment, so a document mentioning an entity with two sentiments counts twice.sentiment,emotionandintentoncontent_livecome from the document’s latest analysis;emotionandintentare the top-scoring label.channelis currently the Reddit subreddit only.- Growth on
metric_growthcan be negative (for example withdrawn likes); the window is by collection time, not publication time. - Sentiment, emotions and intents come from automatic analysis, using each document’s latest result. Emotions and intents below their threshold are labelled
none.
Errors
| HTTP | Code | Meaning | Advice |
|---|---|---|---|
400 | invalid_query | Query shape, limits or member names are invalid, or the range is too long for a source computed on request | Fix the request; do not retry automatically |
401 | unauthorized | API key missing, invalid or revoked | Use a valid key |
403 | entitlement_denied | The application lacks the field the data source needs | Check subscriptions and entitlements |
422 | analytics_not_answerable | The combination cannot be answered from the summaries, for example hourly granularity | Change dimensions or granularity; see /v1/analytics/meta |
429 | rate_limit_exceeded | Rate or concurrency limit reached | Back off per Retry-After |
503 | analytics_unavailable | Temporarily unavailable, summaries are being prepared, or a computation on request timed out | Retry with bounded exponential backoff; on timeouts shorten the range or add filters |
See the public API reference for the full request and schemas.