Text Analysis API Usage, Sentiment & Content Moderation
Analyze text for sentiment, toxicity, spam, and more using Voyant AI. Supports both single and batch requests with secure signature-based authentication.
Try Text Analysis Demo →Endpoints:
• /v1/text/analyze (single)
• /v1/text/analyze/batch (max 10 texts)
Authentication
All requests must be signed using your apiSecret . Send the generated signature in request body as signature .
Required fields in request body:
- • projectId
- • apiKey
- • nonce (random alphanumeric exactly 10 characters)
- • timestamp
- • signature
- • text (for single request)
- • texts (for batch request)
⚠️ All fields (including text/texts) must be included while generating the signature.
Request Flow (Pseudo)
1. payload = { apiKey, projectId, nonce, timestamp, text OR texts }
nonce → random 10 char string
timestamp → milliseconds (Date.now())
⚠️ include "text" (single) OR "texts" (batch)
2. stable = JSON.stringify(sorted(payload))
⚠️ keys MUST be sorted alphabetically
3. signature = HMAC_SHA256(stable, apiSecret)
4. body (x-www-form-urlencoded):
add apiKey, projectId, nonce, timestamp, signature
single → text=...
batch → texts=text1, texts=text2
5. POST → /v1/text/analyze or /batch
headers:
Content-Type: application/x-www-form-urlencoded
Official SDKs & Libraries
Use official SDKs for faster integration across platforms.
Signature Generation
1. Send a POST request with application/x-www-form-urlencoded body
2. Include required fields + text (single) or texts (batch)
3. Create payload including ALL fields
4. Sort keys before stringify
5. Generate HMAC-SHA256 using apiSecret
6. Send signature in request body
import crypto from "node:crypto";
const payload = {
nonce,
projectId,
apiKey,
timestamp,
...(texts ? { texts } : { text })
};
const stable = JSON.stringify(
Object.keys(payload)
.sort()
.reduce((a, k) => {
a[k] = payload[k];
return a;
}, {})
);
const signature = crypto
.createHmac("sha256", apiSecret)
.update(stable)
.digest("hex");
⚠️ text/texts MUST be included in signature calculation, otherwise request will fail.
Single Text
Analyze a single text input. Max length: 500 characters .
POST /v1/text/analyze Content-Type: application/x-www-form-urlencoded text=I loved the service!& projectId=...& apiKey=...& nonce=...& timestamp=123456& signature=...
Batch (Max 10 Texts)
Send multiple texts. Combined length must be ≤ 500 characters .
POST /v1/text/analyze/batch Content-Type: application/x-www-form-urlencoded texts=["text1","text2"]& projectId=...& apiKey=...& nonce=...& timestamp=123456& signature=...
Response Format
Each request returns probability scores (0 → 1) for different content signals. Higher value = stronger confidence.
{
"success": true,
"data": {
"toxic": 0.0087,
"obsceneContent": 0.0217,
"threateningContent": 0.0182,
"insultingLanguage": 0.0755,
"identityAttack": 0.1063,
"sexuallyExplicit": 0.0349,
"spam": 1,
"phishing": 0,
"sentiment": 0.3579
}
}
• Max 10 texts in batch
• Invalid signature → request fails
• Rate limits apply
• Content-Type must be application/x-www-form-urlencoded
• Signature must be sent in body (not header)