Voyant Networks Docs

NSFW Detection API Usage & Content Analysis

Analyze images for NSFW content using Voyant’s AI models. Supports single and batch image processing via secure signed requests.

Try NSFW Demo β†’
Base URL: https://api.voyantnetworks.com
Endpoints:
β€’ /v1/nsfw/analyze (single)
β€’ /v1/nsfw/analyze/batch (max 5 images)

Authentication

All requests must be signed using your apiSecret . Send signature in header x-signature .

Required fields (must come BEFORE file):

  • β€’ projectId
  • β€’ apiKey
  • β€’ nonce (random alphanumeric exactly 10 characters)
  • β€’ timestamp

Signature Generation

Follow these steps to generate the request signature:

1. Send a POST request using multipart/form-data .
2. Include required fields: projectId , apiKey , nonce , timestamp .
3. Create a payload object using only these fields.
4. Sort the payload keys in ascending order before converting to string.
5. Generate HMAC-SHA256 hash using your apiSecret .
6. Send the generated hash in header x-signature .

import crypto from "node:crypto";

const payload = { nonce, projectId, apiKey, timestamp };

const stableStringify = (obj) =>
  JSON.stringify(Object.keys(obj).sort().reduce((a,k)=>{a[k]=obj[k];return a;},{}));

const signature = crypto
  .createHmac("sha256", apiSecret)
  .update(stableStringify(payload))
  .digest("hex");

⚠️ Always sort keys before hashing.

Reduce Image Size (Client Side)

Max allowed size is 200KB . Compress images before upload to avoid errors.

Resize + reduce quality for best results.

async function compressImage(file) {
  const img = await createImageBitmap(file);

  const canvas = document.createElement("canvas");
  const scale = Math.min(800 / img.width, 1);

  canvas.width = img.width * scale;
  canvas.height = img.height * scale;

  const ctx = canvas.getContext("2d");
  ctx.drawImage(img, 0, 0, canvas.width, canvas.height);

  return new Promise((resolve) => {
    canvas.toBlob(resolve, "image/jpeg", 0.7);
  });
}

⚑ Resize + quality 60–80 β†’ best balance between size & accuracy

Single Image

Upload one image using multipart form-data. Field name must be image .

curl -X POST https://api.voyantnetworks.com/v1/nsfw/analyze \
  -H "x-signature: SIGNATURE" \
  -F "projectId=YOUR_PROJECT_ID" \
  -F "apiKey=YOUR_API_KEY" \
  -F "nonce=123456" \
  -F "timestamp=TIMESTAMP" \
  -F "image=@file.jpg"

Batch (Max 5 Images)

Upload multiple images using field name images . Max 5 files per request.

curl -X POST https://api.voyantnetworks.com/v1/nsfw/analyze/batch \
  -H "x-signature: SIGNATURE" \
  -F "projectId=YOUR_PROJECT_ID" \
  -F "apiKey=YOUR_API_KEY" \
  -F "nonce=123456" \
  -F "timestamp=TIMESTAMP" \
  -F "images=@1.jpg" \
  -F "images=@2.jpg"

Response Format

Returns whether the image is classified as NSFW.

{
  "success": true,
  "nsfw": false
}
success β†’ request processed successfully
nsfw β†’ true = unsafe / adult content detected
β€’ Max file size: 200KB per image
β€’ Auth fields must come before file upload
β€’ Rate limits apply based on your plan
β€’ Invalid signature or replay will fail request