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_live and metric_growth are 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 dimensionMeaningTypical sources
published_atWhen the source platform published the contentmetrics_latest, sentiment, affect_labels, content_live
stored_atWhen Whale first stored the documentnew_documents
metric_time / windowMetric collection time or collection windowmetric_history, metric_growth
dayUTC date of automatic analysisentities

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 sourceContentRequired field
new_documentsNew documents, by publication time (published_at) or storage time (stored_at)identity
metrics_latestLatest collected metrics of each documentmetrics
metric_historyEvery collected metric snapshot, by snapshot time (metric_time), from 2026-07-01metrics
entitiesEntity 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
sentimentLatest sentiment result of each documentaffect
affect_labelsLatest emotion labels (kind=emotion) and intent labels (kind=intent) of each documentaffect for emotions, intents for intents
content_liveOne 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 daysidentity, see below
metric_growth (coming soon)Metric change of each document within a window, by collection time (window); dateRange at most 7 daysmetrics

content_live needs more fields depending on the members used:

MembersAlso needs
Metrics (view_count_*, like_count_*, score_* and so on)metrics
sentiment, sentiment_score_avg, emotionaffect
intentintents
author_id, author_name, author_followersauthor
channelmetadata

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, entities and content_live, which have a language dimension.
  • Limited to publication times: not metric_history, entities or metric_growth, which have no publication time.

List measures and dimensions

Bash
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:

JSON
{
  "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

Bash
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
  }'
FieldDescription
measures1–10 measures, required
dimensionsUp to 5 grouping dimensions
timeDimensionsRequired, 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
filtersEach filter has member, operator and values; common operators: equals, notEquals, contains, gt, gte, lt, lte, set, notSet
orderSort, for example {"sentiment.documents": "desc"}
limit / offsetRows 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:

JSON
{
  "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:

JSON
{
  "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:

JSON
{
  "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:

Bash
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"]}]
    }
  }'
FieldDescription
search.queryKeywords, as in the keyword retrieval of Search; the top max_documents by relevance are used
search.source_platforms / languagesOptional, narrow the search
search.published_from / published_toOptional, RFC 3339 times
search.max_documentsDocuments analyzed, default and maximum 1,000
queryA content_live query, same rules as above

The response adds documents_matched, the number of documents the search matched and the query analyzed.

Response

JSON
{
  "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_at is when the summaries were last refreshed. metric_history and new_documents by storage time refresh their last two days every hour; entities refreshes its last two days every 6 hours; the others every 6 hours. The newest data lags accordingly. content_live and metric_growth are computed on request and have no refreshed_at.

Metric semantics

  • metrics_latest covers 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.
  • *_avg is the average of a metric, *_sum the total and *_documents the number of documents that have it, *_max the largest value; *_p50, *_p90 and *_p99 are approximate medians and percentiles, on content_live only.
  • score is the Reddit score (upvotes minus downvotes), not a like count.
  • Each metric_history row is one collection, and a document is collected many times: snapshots counts snapshots, *_avg averages them and *_max is the largest value. Use metrics_latest to count documents.
  • new_documents counts each document once, when it was first stored.
  • entities counts entity mentions in the automatic extraction of every version, with the same types as the entity statistics; entity is the normalized name. Metrics count once per document, entity and mention sentiment, so a document mentioning an entity with two sentiments counts twice.
  • sentiment, emotion and intent on content_live come from the document’s latest analysis; emotion and intent are the top-scoring label. channel is currently the Reddit subreddit only.
  • Growth on metric_growth can 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

HTTPCodeMeaningAdvice
400invalid_queryQuery shape, limits or member names are invalid, or the range is too long for a source computed on requestFix the request; do not retry automatically
401unauthorizedAPI key missing, invalid or revokedUse a valid key
403entitlement_deniedThe application lacks the field the data source needsCheck subscriptions and entitlements
422analytics_not_answerableThe combination cannot be answered from the summaries, for example hourly granularityChange dimensions or granularity; see /v1/analytics/meta
429rate_limit_exceededRate or concurrency limit reachedBack off per Retry-After
503analytics_unavailableTemporarily unavailable, summaries are being prepared, or a computation on request timed outRetry with bounded exponential backoff; on timeouts shorten the range or add filters

See the public API reference for the full request and schemas.