API VERSION 1.1

Age Prediction API Documentation

Integrate apparent-age estimation, a 478-point face mesh, or both through a versioned JSON API.

Overview

The API accepts JSON requests and analyzes the primary face in an image. Every successful response includes api_version; every failure uses the same structured error envelope.

Base URL: https://api.rate-my-photo.com. Contact sales before production use to discuss access and pricing.

MethodPathPurpose
POST/ageEstimate age; optionally return a boundary box, face crop, and face mesh.
POST/facemeshReturn facial keypoints; optionally return frontalized keypoints and pose.

Quickstart

Send a JSON request with exactly one image source. This example uses raw base64 data and relies on the default age response fields.

curl -X POST https://api.rate-my-photo.com/age \
  -H 'Content-Type: application/json' \
  -H 'X-API-Version: 1.1' \
  -d '{
    "face_image": "<base64-encoded-image>"
  }'

Example response

{
  "api_version": "1.1",
  "age": 25.42,
  "boundary_box": {
    "x": 113,
    "y": 89,
    "width": 142,
    "height": 180
  }
}

Image input

Both endpoints require exactly one of the following request fields:

FieldTypeDescription
face_imagestringRaw base64 or a data:image/...;base64, data URI.
face_image_urlstringA public HTTP or HTTPS image URL. Private, loopback, link-local, and unreachable targets are refused.

Limits and preprocessing

  • Decoded image size must not exceed 15 MB.
  • Neither image dimension may exceed 4500 px.
  • If the longest side is above 1000 px, the image is downscaled to a maximum side of 1000 px with aspect ratio preserved.
  • For a combined request, age and face mesh analysis run on that same processed image.

Versioning

Set the optional X-API-Version request header. If the header is omitted, the API defaults to version 1.1. The effective version is echoed in the response header and JSON body.

X-API-Version: 1.1

An unsupported value returns HTTP 400 with error code UNSUPPORTED_VERSION.

Age estimation

POST /age

Estimates the apparent age of the primary face.

ParameterTypeDefaultEffect
return_boundary_boxbooleantrueInclude x, y, width, and height.
return_face_base64booleanfalseInclude a base64-encoded crop of the detected face.
return_facemeshbooleanfalseAlso run face mesh analysis and enable its output parameters.

The age field is numeric. The boundary box and face crop appear only when requested and available.

Face mesh

POST /facemesh

Returns 478 normalized three-dimensional landmarks for the primary face.

ParameterTypeDefaultEffect
return_keypointsbooleantrueInclude the 478 x, y, and z keypoints.
return_frontalized_keypointsbooleanfalseInclude 478 frontalized keypoints.
return_posebooleanfalseInclude head-pose measurements such as yaw, pitch, and roll.

Example request

{
  "face_image_url": "https://example.com/portrait.jpg",
  "return_frontalized_keypoints": true,
  "return_pose": true
}

Abbreviated response

{
  "api_version": "1.1",
  "keypoints": [
    { "x": 0.47999, "y": 0.58708, "z": -0.04268 }
  ],
  "frontalized_keypoints": [
    { "x": 0.48012, "y": 0.58191, "z": -0.03924 }
  ],
  "pose": {
    "yaw": 1.2,
    "pitch": -2.4,
    "roll": 0.8,
    "off_frontal_deg": 2.8,
    "frontal_deviation": 0.03
  }
}

The arrays shown above are abbreviated. A full keypoint response contains 478 entries. The face mesh endpoint does not expose a boundary box.

Age + face mesh

There is no separate /both route. Use POST /age, set return_facemesh to true, and add any face mesh output flags you need.

{
  "face_image": "<base64-encoded-image>",
  "return_boundary_box": true,
  "return_facemesh": true,
  "return_frontalized_keypoints": true,
  "return_pose": true
}

Face mesh fields are nested under facemesh in the age response:

{
  "api_version": "1.1",
  "age": 25.42,
  "boundary_box": { "x": 113, "y": 89, "width": 142, "height": 180 },
  "facemesh": {
    "keypoints": [ ... ],
    "frontalized_keypoints": [ ... ],
    "pose": { ... }
  }
}

Error handling

Errors use an HTTP status appropriate to the failure and a stable machine-readable code.

{
  "api_version": "1.1",
  "error": {
    "code": "NO_FACE_DETECTED",
    "message": "No face was detected in the supplied image."
  }
}
StatusCodeMeaning
400VALIDATION_ERRORMissing or conflicting image sources, invalid fields, or an invalid URL.
400UNSUPPORTED_VERSIONThe requested API version is not supported.
413IMAGE_TOO_LARGEThe decoded image exceeds 15 MB.
413IMAGE_DIMENSIONS_TOO_LARGEAn image side exceeds 4500 px.
422INVALID_IMAGEThe image or base64 data cannot be decoded.
422NO_FACE_DETECTEDNo usable face was found.
422IMAGE_URL_UNREACHABLEThe URL failed or resolved to a refused address.
502UPSTREAM_ERRORAn analysis service returned an unexpected response.
504UPSTREAM_TIMEOUTAn analysis service did not respond in time.
500INTERNAL_ERRORAn unexpected server error occurred.

Planning a production integration?

Tell us about your use case, expected traffic, and required response fields.

Contact sales