Skip to main content

Megacall (Batch Operations)

Run multiple analysis types in a single API call for efficiency.

Why Use Megacall?

A single request is faster than multiple requests for each kind of analysis. It is also more cost effective, as you are charged for fewer API calls than the individual features in the megacall.

Selecting Which Checks to Run

Each analysis type is optional. Only request what you need to minimize latency and cost.

Pass an options object with boolean flags to select analyses:

ParameterAnalysis
includeSpam: trueSpam detection
includeRelevance: trueOn-topic and banned topics check
includeCommentScore: trueFull quality analysis
includeDogwhistle: trueCoded language detection

Results are null for any analysis not requested.

Basic Usage

const result = await client.megacall({
comment: "This is a test comment",
articleId: articleId,
includeSpam: true,
includeRelevance: true,
includeCommentScore: true,
includeDogwhistle: true,
});

// Access results (null if not requested)
if (result.spam_check) {
console.log(`Is spam: ${result.spam_check.is_spam}`);
}

if (result.relevance_check) {
console.log(`On topic: ${result.relevance_check.on_topic.on_topic}`);
}

if (result.comment_score) {
console.log(`Overall score: ${result.comment_score.overall_score}`);
}

if (result.dogwhistle_check) {
console.log(`Dogwhistles detected: ${result.dogwhistle_check.detection.dogwhistles_detected}`);
}

With Additional Parameters

const result = await client.megacall({
comment: "Comment text here",
articleId: articleId,
includeSpam: true,
includeRelevance: true,
includeDogwhistle: true,
bannedTopics: ["politics", "religion"],
sensitiveTopics: ["controversial topic"],
dogwhistleExamples: ["known coded phrase"],
});