Skip to main content

๐Ÿ˜Š Emotion Recognition

The /emotion endpoint analyzes faces in an image and detects the dominant emotions expressed by each individual. It is ideal for building apps that react to user sentiment, conduct surveys, or monitor engagement.


๐Ÿ“ฅ Endpoint : POST /emotionโ€‹

Base URL: https://api.visionary.ai/v1/emotion


๐Ÿ” Headersโ€‹

KeyValueRequired
AuthorizationBearer YOUR_API_KEYโœ…
Content-Typeapplication/json or multipart/form-dataโœ…

๐Ÿ“ธ Request Bodyโ€‹

Option 1 โ€“ JSON (Base64)โ€‹

{
"image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUg..."
}

Use image as the field name when uploading.


๐Ÿงช Example (curl โ€“ multipart)โ€‹

curl -X POST https://api.visionary.ai/v1/emotion \
-H "Authorization: Bearer demo-api-key" \
-F "image=@/path/to/image.jpg"

โœ… Responseโ€‹

{
"faces": [
{
"bounding_box": {
"x": 120,
"y": 80,
"width": 140,
"height": 140
},
"emotions": [
{
"label": "happy",
"confidence": 0.92
},
{
"label": "neutral",
"confidence": 0.07
}
]
}
]
}

๐Ÿง  Fieldsโ€‹

FieldTypeDescription
bounding_boxobjectLocation of detected face (x, y, width, height)
emotionsarrayList of probable emotions and their confidence
labelstringDetected emotion (e.g. happy, sad, angry)
confidencefloatValue between 0 and 1

๐Ÿ˜Š Possible Emotionsโ€‹

  • happy

  • sad

  • angry

  • surprised

  • fearful

  • disgusted

  • neutral


๐Ÿšซ Error Responsesโ€‹

CodeMessageCause
400"No face detected"No recognizable face in image
401"Unauthorized"Missing or invalid API key
422"Unprocessable Entity"Bad image format or corrupted

๐Ÿ“Œ Notesโ€‹

  • Works best with frontal or slightly angled faces.

  • Can detect multiple faces in the same image.

  • Results are approximate and may vary based on image quality.


๐Ÿ”— Next endpointโ€‹

โžก๏ธ Try the /nsfw-filter endpoint to moderate inappropriate content.