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),clusteringanddeduplication(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
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')"| Field | Required | Description |
|---|---|---|
analysis_type | Yes | knn_graph, clustering or deduplication |
input_scope.source_platforms | Yes | At least one authorized platform |
input_scope.languages / regions / content_types / subject_types | No | Can only narrow your existing grants |
input_scope.topics | No | Match a document’s primary topic (its first topic); for Reddit, the subreddit |
input_scope.quality_statuses | No | Keep 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_to | No | RFC 3339 bounds on publication or ingest time |
embedding_profile_id | Conditional | Required for vector-related types; must be an active profile |
parameters.subject_level | No | chunk or document; knn_graph defaults to chunk, clustering accepts only document |
parameters.k | No | Neighbors per node, 1–100; default 30 for knn_graph, 20 for clustering |
parameters.min_similarity | No | Minimum cosine similarity, -1 to 1; no filter for knn_graph, 0 for clustering by default |
input_cutoff_at | No | Input cutoff; defaults to creation time, so later ingest is excluded from this run |
retention_days | No | Retention 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:
{
"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
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:
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:
| Column | Description |
|---|---|
source_subject_id / target_subject_id | Source and neighbor chunk IDs |
source_document_id / target_document_id | Owning document IDs, readable via Read Content & History |
source_version_id / target_version_id | Document versions used in the calculation |
rank | Neighbor rank starting at 1 |
similarity | Cosine 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.
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}
}'| Parameter | Default | Meaning |
|---|---|---|
resolution | 1 | 0.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_size | 5 | 2–1000; smaller groups after deduplication are noise |
dedup_similarity | 0.97 | 0.8–1; documents of one author at least this similar count once |
edge_weight | snn | snn links documents by the share of neighbors they have in common; similarity uses the cosine itself |
center | true | Subtract the scope’s mean vector before comparing, so documents on one broad theme separate better |
metrics | the platform’s reliable metrics | Up to 10 metric names from /v1/metrics/registry |
include_graph | false | Also publish a knn_graph artifact |
previous_run_id | none | One 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:
| Column | Meaning |
|---|---|
cluster_id | Cluster ID, numbered from the largest; empty for noise |
subject_id / document_id / version_id | The subject and its document version |
membership_role | representative (the 10 best connected in the cluster), core, boundary or duplicate |
membership_confidence | Share of the subject’s link weight that goes to its own cluster |
is_noise | Whether it belongs to a group smaller than min_cluster_size |
duplicate_of | For a merged duplicate, the document that represents it |
cluster_summary, one row per cluster:
| Column | Meaning |
|---|---|
size / unique_subjects / authors | Documents, documents after deduplication, authors |
first_published_at / last_published_at | Earliest and latest publication in the cluster |
last_7_days / previous_7_days | Publications in the window’s last 7 days and the 7 before, for growth |
sentiment_coverage / negative_share / mean_sentiment | Documents with sentiment, the negative share, the mean sentiment score |
top_topics_json | Top 10 topics with counts |
daily_counts_json | Publications per day in the window |
metrics_json | Per metric: observations, median and P90 of each document’s latest observed value |
representatives_json | IDs and titles of the representative documents |
top_terms_json | The 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:
| Column | Meaning |
|---|---|
lineage_id | The cluster number; with previous_run_id, a continuing cluster keeps the previous number |
lineage_relation | continued, split (broken off a previous cluster), merged (from several previous clusters) or new |
previous_cluster_id / previous_size | When 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:
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:
| Case | Parameters |
|---|---|
| A seller listing the same item many times | "author": "same" |
| Deduplication, so repeated content does not inflate counts | default ("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 |
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"}
}'| Parameter | Default | Meaning |
|---|---|---|
min_similarity | 0.95 | 0.8–1. Above 0.95 is nearly the same content; about 0.9 is a rewrite or paraphrase |
author | any | same links only one author’s documents, different only different authors’, any either |
cross_platform | true | When false, groups stay within one platform |
min_group_size | 2 | 2–1000; smaller groups are not published |
metrics | the platform’s reliable metrics | Up 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
| HTTP | code | Meaning and action |
|---|---|---|
| 400 | invalid_analysis_request | Missing or invalid body fields; fix per message |
| 400 | analysis_request_failed | Business validation failed, for example the profile is missing or not active, or previous_run_id is not your succeeded clustering run |
| 401 | unauthorized | The Consumer API Key is invalid |
| 403 | analysis_forbidden | analysis_enabled is turned off for your application, or input_scope exceeds your grants |
| 404 | analysis_not_found / analysis_artifact_not_found | The run or artifact does not exist or is not owned by your application |
| 429 | rate_limit_exceeded | Rate limited; back off per Retry-After |
| 429 | analysis_too_many_runs | An 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.