Analysis Tasks (Preview)

The analysis API persists your authorized data scope as an asynchronous analysis run. It suits analysis platforms that reuse Whale data and vector capabilities. A run executes only when you create it; for periodic analysis, your system creates runs on its own schedule.

This is a Preview API. knn_graph (neighbor graph), clustering and deduplication (similar-content groups) runs execute.

Use Keyword & Semantic Search, Read Content & History and Synchronize Data Changes for indexed and atomic data access. The analysis API does not replace them.

Prerequisites

Call these APIs with a Consumer API Key, not an internal admin token. Your application needs entitlement for the requested platforms, languages, and regions. Analysis is on by default; only an application whose access policy sets "analysis_enabled": false cannot use it.

Vector-related runs also need a registered active embedding_profile_id. Current production search embeddings are text-chunk vectors. With parameters.subject_level set to document, Whale represents a document by the mean direction of its chunk vectors.

Create a Run

Bash
run_response="$(curl -sS --fail-with-body -X POST "$WHALE_BASE_URL/v1/analysis/runs" \
  -H "Authorization: Bearer $WHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "analysis_type": "knn_graph",
    "embedding_profile_id": "search_chunk_bge_m3_v1",
    "input_scope": {
      "source_platforms": ["xianyu"],
      "subject_types": ["chunk"],
      "published_from": "2026-10-01T00:00:00Z"
    },
    "parameters": {"k": 30, "min_similarity": 0.72},
    "retention_days": 14
  }')"
printf '%s' "$run_response" | jq .
RUN_ID="$(printf '%s' "$run_response" | jq -er '.run_id')"
FieldRequiredDescription
analysis_typeYesknn_graph, clustering or deduplication
input_scope.source_platformsYesAt least one authorized platform
input_scope.languages / regions / content_types / subject_typesNoCan only narrow your existing grants
input_scope.topicsNoMatch a document’s primary topic (its first topic); for Reddit, the subreddit
input_scope.quality_statusesNoKeep documents with these quality statuses, for example ["normal"]; omitted keeps every status, including documents not assessed yet
input_scope.published_from / published_to / created_from / created_toNoRFC 3339 bounds on publication or ingest time
embedding_profile_idConditionalRequired for vector-related types; must be an active profile
parameters.subject_levelNochunk or document; knn_graph defaults to chunk, clustering accepts only document
parameters.kNoNeighbors per node, 1–100; default 30 for knn_graph, 20 for clustering
parameters.min_similarityNoMinimum cosine similarity, -1 to 1; no filter for knn_graph, 0 for clustering by default
input_cutoff_atNoInput cutoff; defaults to creation time, so later ingest is excluded from this run
retention_daysNoRetention for the run and its artifacts, 1–365, default 30

A run takes at most 50,000 subjects (chunks or documents). Larger inputs end the run as failed; narrow input_scope. The calculation is exact cosine Top-K: about 20 minutes for 50,000 subjects and 3 minutes for 20,000.

Vectors are readable only for recently published content: the vector store keeps loaded only the partitions of about the last 30 days of publication. Subjects in scope that were published earlier have no readable vector; they are left out of the result but still count toward the limit. Without published_from, most chunks of long-tail platforms such as short video are left out. Set published_from within 30 days; also giving created_from makes the run start much faster.

A successful request returns 202 with the run in queued:

JSON
{
  "run_id": "arun_01K...",
  "analysis_type": "knn_graph",
  "embedding_profile_id": "search_chunk_bge_m3_v1",
  "input_scope": {"source_platforms": ["xianyu"], "subject_types": ["chunk"]},
  "input_cutoff_at": "2026-10-14T08:00:00Z",
  "status": "queued",
  "created_at": "2026-10-14T08:00:00Z",
  "expires_at": "2026-10-28T08:00:00Z"
}

Track the Run and Read Results

Bash
curl -sS --fail-with-body "$WHALE_BASE_URL/v1/analysis/runs/$RUN_ID" \
  -H "Authorization: Bearer $WHALE_API_KEY" | jq '{status, error, started_at, completed_at}'

status moves through queued, validating and running, and ends as succeeded, failed, cancelled or expired. On failed, error explains why. Poll starting at five-second intervals and back off.

After success, list and download artifacts:

Bash
curl -sS --fail-with-body "$WHALE_BASE_URL/v1/analysis/runs/$RUN_ID/artifacts" \
  -H "Authorization: Bearer $WHALE_API_KEY" | jq .
 
curl -sS --fail-with-body -o knn-graph.parquet \
  "$WHALE_BASE_URL/v1/analysis/runs/$RUN_ID/artifacts/$ARTIFACT_ID/file" \
  -H "Authorization: Bearer $WHALE_API_KEY"

Each artifact has artifact_id, artifact_type, format (parquet), rows, bytes, checksum and expires_at, plus subject_level, input_subjects (subjects in scope), unavailable_subjects (those left out because their vector was not readable) and placeholder_subjects (those left out as placeholder text, see below). When unavailable_subjects is close to input_subjects, the scope is mostly older content; narrow the publication window. A knn_graph artifact is a ZSTD-compressed Parquet edge table:

ColumnDescription
source_subject_id / target_subject_idSource and neighbor chunk IDs
source_document_id / target_document_idOwning document IDs, readable via Read Content & History
source_version_id / target_version_idDocument versions used in the calculation
rankNeighbor rank starting at 1
similarityCosine similarity

The calculation selects currently indexed subjects as of input_cutoff_at and computes exact cosine Top-K, not approximate search. Artifacts contain no source text or raw vectors.

When at least five subjects share one exact vector, the vector comes from placeholder text (for example, Reddit posts whose body a moderator removed all read [removed]). Those subjects are left out and counted in placeholder_subjects.

Clustering

clustering builds a document neighbor graph over the scope, groups similar documents into clusters and describes each cluster’s size, trend, engagement and sentiment. It is a general capability: Reddit demand insight can cluster posts of chosen subreddits to find pain points, and Xianyu can cluster listings of a category to see niches.

Bash
curl -sS --fail-with-body -X POST "$WHALE_BASE_URL/v1/analysis/runs" \
  -H "Authorization: Bearer $WHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "analysis_type": "clustering",
    "embedding_profile_id": "search_chunk_bge_m3_v1",
    "input_scope": {
      "source_platforms": ["reddit"],
      "content_types": ["post"],
      "topics": ["SaaS", "smallbusiness", "startups"],
      "quality_statuses": ["normal"],
      "published_from": "2026-10-13T00:00:00Z",
      "published_to": "2026-10-27T00:00:00Z"
    },
    "parameters": {"subject_level": "document", "resolution": 2, "min_cluster_size": 5}
  }'
ParameterDefaultMeaning
resolution10.05–10; higher gives more, smaller clusters. For a few thousand topic-filtered documents, about 2 usually gives clusters with a clear subject
min_cluster_size52–1000; smaller groups after deduplication are noise
dedup_similarity0.970.8–1; documents of one author at least this similar count once
edge_weightsnnsnn links documents by the share of neighbors they have in common; similarity uses the cosine itself
centertrueSubtract the scope’s mean vector before comparing, so documents on one broad theme separate better
metricsthe platform’s reliable metricsUp to 10 metric names from /v1/metrics/registry
include_graphfalseAlso publish a knn_graph artifact
previous_run_idnoneOne of your earlier succeeded clustering runs on the same embedding_profile_id; this run’s clusters are matched against its clusters, see Cluster Lineage

The same input with the same parameters gives exactly the same clusters. A successful run has two artifacts.

cluster_membership, one row per subject:

ColumnMeaning
cluster_idCluster ID, numbered from the largest; empty for noise
subject_id / document_id / version_idThe subject and its document version
membership_rolerepresentative (the 10 best connected in the cluster), core, boundary or duplicate
membership_confidenceShare of the subject’s link weight that goes to its own cluster
is_noiseWhether it belongs to a group smaller than min_cluster_size
duplicate_ofFor a merged duplicate, the document that represents it

cluster_summary, one row per cluster:

ColumnMeaning
size / unique_subjects / authorsDocuments, documents after deduplication, authors
first_published_at / last_published_atEarliest and latest publication in the cluster
last_7_days / previous_7_daysPublications in the window’s last 7 days and the 7 before, for growth
sentiment_coverage / negative_share / mean_sentimentDocuments with sentiment, the negative share, the mean sentiment score
top_topics_jsonTop 10 topics with counts
daily_counts_jsonPublications per day in the window
metrics_jsonPer metric: observations, median and P90 of each document’s latest observed value
representatives_jsonIDs and titles of the representative documents
top_terms_jsonThe cluster’s distinctive title terms, top 20

cluster_summary also has centroid, the cluster’s mean direction after centering, and lineage_id, the cluster number described below.

Cluster Lineage

Every clustering run numbers its clusters (lineage_id, such as L000015). Name an earlier clustering run in parameters.previous_run_id and this run’s clusters are matched against its clusters: a cluster that keeps a number continues the same subject, and the run also publishes a cluster_lineage artifact. The related cluster_summary columns:

ColumnMeaning
lineage_idThe cluster number; with previous_run_id, a continuing cluster keeps the previous number
lineage_relationcontinued, split (broken off a previous cluster), merged (from several previous clusters) or new
previous_cluster_id / previous_sizeWhen the ID is kept, the previous cluster and its size

How an ID is kept: when more than half of a previous cluster’s members still in this run’s scope land in one current cluster, that cluster keeps its ID. When no cluster holds half, two clusters that are each other’s largest source and largest successor and share at least 40% keep it too. When almost all members have left the window, centroids at least 0.9 alike also continue it.

Each cluster_lineage row is one link between this run and the previous one: previous_cluster_id, current_cluster_id, lineage_id, relation_type (also retired: in the previous run but not this one), member_overlap (shared members), previous_surviving (the previous cluster’s members still in this run’s scope) and semantic_similarity (centroid cosine).

For new needs, look at clusters whose lineage_relation is new; for growing ones, compare size and last_7_days across runs by lineage_id. To follow clusters over time, pass the last succeeded run’s ID as previous_run_id each time you create a run, and the numbers carry on. The more the publication ranges of two runs overlap (for example a weekly run over the last 14 days), the more reliable lineage is.

Whale gives base features only. It does not name clusters or judge which cluster is a “need” or a “pain point”; interpret them for your use case.

Cancel an unfinished run:

Bash
curl -sS --fail-with-body -X POST "$WHALE_BASE_URL/v1/analysis/runs/$RUN_ID/cancel" \
  -H "Authorization: Bearer $WHALE_API_KEY"

Similar-Content Groups

deduplication links documents at least as similar as a threshold that meet author and platform conditions into groups, marks each group’s earliest published document as its origin and describes how the group spread. One capability serves several cases through parameters:

CaseParameters
A seller listing the same item many times"author": "same"
Deduplication, so repeated content does not inflate countsdefault ("author": "any")
Reposts and spread: who posted first, who copied, across which platforms"author": "different", "min_similarity": 0.9
Coordinated posting of one message"author": "different", then look at group size and authors
Bash
curl -sS --fail-with-body -X POST "$WHALE_BASE_URL/v1/analysis/runs" \
  -H "Authorization: Bearer $WHALE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "analysis_type": "deduplication",
    "embedding_profile_id": "search_chunk_bge_m3_v1",
    "input_scope": {
      "source_platforms": ["xianyu"],
      "content_types": ["product_listing"],
      "published_from": "2026-10-27T00:00:00Z"
    },
    "parameters": {"subject_level": "document", "author": "same"}
  }'
ParameterDefaultMeaning
min_similarity0.950.8–1. Above 0.95 is nearly the same content; about 0.9 is a rewrite or paraphrase
authoranysame links only one author’s documents, different only different authors’, any either
cross_platformtrueWhen false, groups stay within one platform
min_group_size22–1000; smaller groups are not published
metricsthe platform’s reliable metricsUp to 10 metric names, summed and maximized per group

Similarity uses the vectors as they are, without centering. Groups are transitive: when A links to B and B to C, all three share a group even if A and C are not linked directly. A successful run has two artifacts.

duplicate_membership, one row per grouped subject: duplicate_group_id, subject_id / document_id / version_id, role (origin for the group’s earliest publication, otherwise member), source_platform, author_id, published_at and similarity_to_origin.

duplicate_summary, one row per group: size, authors, platforms_json, first_published_at / last_published_at, spread_hours, the origin’s origin_document_id / origin_author_id / origin_platform / origin_title, and metrics_json (per metric: observations, sum and maximum). Groups are numbered from g000001, largest first.

Errors

HTTPcodeMeaning and action
400invalid_analysis_requestMissing or invalid body fields; fix per message
400analysis_request_failedBusiness validation failed, for example the profile is missing or not active, or previous_run_id is not your succeeded clustering run
401unauthorizedThe Consumer API Key is invalid
403analysis_forbiddenanalysis_enabled is turned off for your application, or input_scope exceeds your grants
404analysis_not_found / analysis_artifact_not_foundThe run or artifact does not exist or is not owned by your application
429rate_limit_exceededRate limited; back off per Retry-After
429analysis_too_many_runsAn application may have at most 3 queued or running runs; submit again after one finishes

Retention and Data Boundary

Runs default to 30 days and accept retention_days from 1 to 365. A run used as previous_run_id must not have expired.

Expiry cleanup applies only to analysis runs and derived artifacts. It never deletes documents, content, facts, metric snapshots or embeddings. Source deletion, unavailability and delisting are not handled yet: results describe inputs observed and authorized at input_cutoff_at.

See the public API reference for every field.

Next Steps

Use Synchronize Data Changes for continuous atomic data, and Keyword & Semantic Search plus Read Content & History to verify scope and content first.