Personality Prediction API
Pass the URL of a frontal photo plus gender to get this person’s predicted answers on MBTI / 16PF questionnaires. Two ways to use it:Use our hosted service(billed per call), orintegrate it into your own system(a REST API you can wire up in minutes).
Endpoint
POST https://www.faceabc.com/api/v1/predict
Requests must include X-API-Key: <你的 Key>
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
photo_url | string | Required* | Publicly reachable URL of the photo, starting with http/https. Or photo pick one of the two; this is recommended |
photo | file | Required* | Upload the file directly, ≤ 10 MB, jpg/png/webp (auto-converted to JPG) |
gender | int | Required | 0 = male,1 = female. Gender affects the prediction and is required |
test | string | Optional | mbti(default) / 16pf / all |
scope | string | Optional | preview(default, summary only) / full(includes every item and the reasoning) |
Photo requirements (important)
· Format: JPG / JPEG / PNG / WebP / GIF / BMP all work — the system converts to JPG automatically(send JPG directly to skip the conversion)
· Size: ≤ 10 MB
· Content: frontal, clear features, no glare,forehead visible(the hairline must be detectable)
· Lighting: even light; avoid backlight and heavy shadows
· No hats, masks or sunglasses covering the face
· Images are resized below 3000 px and converted to JPG; a 1 MB PNG usually ends up around 200 KB
· Format: JPG / JPEG / PNG / WebP / GIF / BMP all work — the system converts to JPG automatically(send JPG directly to skip the conversion)
· Size: ≤ 10 MB
· Content: frontal, clear features, no glare,forehead visible(the hairline must be detectable)
· Lighting: even light; avoid backlight and heavy shadows
· No hats, masks or sunglasses covering the face
· Images are resized below 3000 px and converted to JPG; a 1 MB PNG usually ends up around 200 KB
Example call
cURL
curl -X POST "https://www.faceabc.com/api/v1/predict" \ -H "X-API-Key: fk_你的key" \ -d "photo_url=https://你的域名/photo.jpg" \ -d "gender=1" \ -d "test=mbti" \ -d "scope=preview"
Python
import requests
r = requests.post(
"https://www.faceabc.com/api/v1/predict",
headers={"X-API-Key": "fk_你的key"},
data={
"photo_url": "https://你的域名/photo.jpg",
"gender": 1, # 0=男 1=女
"test": "mbti",
"scope": "preview",
},
timeout=60,
)
print(r.json())
PHP
$ch = curl_init('https://www.faceabc.com/api/v1/predict');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['X-API-Key: fk_你的key'],
CURLOPT_POSTFIELDS => http_build_query([
'photo_url' => 'https://你的域名/photo.jpg',
'gender' => 1,
'test' => 'mbti',
'scope' => 'preview',
]),
CURLOPT_TIMEOUT => 60,
]);
$res = json_decode(curl_exec($ch), true);
Response
{
"success": true,
"request_id": "req_2c68a4d955ee",
"user_id": 1934364196,
"gender": "female",
"coverage": 1,
"mbti": {
"type": "ENTP",
"dimensions": {
"EI": { "letter": "E" },
"SN": { "letter": "N" },
"TF": { "letter": "T" },
"JP": { "letter": "P" }
}
}
}
With scope=full you also get:the predicted answer, confidence and plain-language reasoning for every item (
reason)。
Error codes
| HTTP | error | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Invalid or missing API Key |
| 400 | NO_PHOTO | Neither photo_url nor photo was provided |
| 400 | BAD_PHOTO_URL | URL does not start with http/https |
| 400 | BAD_GENDER | gender is not 0 or 1 |
| 400 | BAD_TEST | test is outside the allowed values |
| 400 | BAD_FILE | Image could not be read or exceeds 10 MB |
| 422 | FACE_REJECTED | Photo failed validation (unclear face, not frontal, etc.) |
| 422 | INSUFFICIENT_FEATURES | Not enough features to make a prediction |
| 500 | FACE_FAILED | Recognition service error |

