openjung-api
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOpenJung API Integration
OpenJung API集成
OpenJung is an open-source personality test based on OEJTS (Open Extended Jungian Type Scales) - a validated 32-question assessment that determines MBTI-compatible personality types.
Base URL:
https://openjung.orgOpenJung是一个基于OEJTS(开放式扩展荣格类型量表)的开源人格测试,这是一份经过验证的32题评估问卷,可得出与MBTI兼容的人格类型。
基础URL:
https://openjung.orgQuick Start
快速开始
Minimal Integration (3 Steps)
最简集成(3步骤)
javascript
// 1. Fetch questions
const { questions } = await fetch('https://openjung.org/api/questions').then(r => r.json());
// 2. Collect user answers (32 questions, values 1-5)
const answers = { "1": 3, "2": 5, /* ... all 32 */ "32": 4 };
// 3. Calculate result
const { result } = await fetch('https://openjung.org/api/calculate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ answers })
}).then(r => r.json());
console.log(result.type); // "ENFP"javascript
// 1. 获取题目
const { questions } = await fetch('https://openjung.org/api/questions').then(r => r.json());
// 2. 收集用户答案(32道题,取值1-5)
const answers = { "1": 3, "2": 5, /* ... 所有32道题 */ "32": 4 };
// 3. 计算结果
const { result } = await fetch('https://openjung.org/api/calculate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ answers })
}).then(r => r.json());
console.log(result.type); // "ENFP"API Endpoints
API端点
GET /api/questions
GET /api/questions
Fetch all 32 test questions.
GET /api/questions?locale=enResponse:
json
{
"totalQuestions": 32,
"questions": [
{
"id": 1,
"dimension": "JP",
"leftTrait": "Makes lists",
"rightTrait": "Relies on memory"
}
]
}获取全部32道测试题目。
GET /api/questions?locale=en响应:
json
{
"totalQuestions": 32,
"questions": [
{
"id": 1,
"dimension": "JP",
"leftTrait": "Makes lists",
"rightTrait": "Relies on memory"
}
]
}POST /api/calculate
POST /api/calculate
Calculate personality type from answers.
javascript
POST /api/calculate
{
"answers": { "1": 3, "2": 5, ... "32": 4 },
"locale": "en", // optional
"save": true // optional - saves to database
}Response:
json
{
"result": {
"type": "ENFP",
"scores": { "EI": 18, "SN": 28, "TF": 22, "JP": 32 },
"percentages": { "E": 75, "I": 25, "S": 12, "N": 88, "T": 31, "F": 69, "J": 0, "P": 100 },
"typeInfo": {
"name": "Campaigner",
"description": "...",
"strengths": ["..."],
"weaknesses": ["..."]
},
"shareUrl": "https://openjung.org/type/enfp?ei=18&sn=28&tf=22&jp=32"
},
"recordId": "uuid"
}根据答案计算人格类型。
javascript
POST /api/calculate
{
"answers": { "1": 3, "2": 5, ... "32": 4 },
"locale": "en", // 可选
"save": true // 可选 - 保存到数据库
}响应:
json
{
"result": {
"type": "ENFP",
"scores": { "EI": 18, "SN": 28, "TF": 22, "JP": 32 },
"percentages": { "E": 75, "I": 25, "S": 12, "N": 88, "T": 31, "F": 69, "J": 0, "P": 100 },
"typeInfo": {
"name": "Campaigner",
"description": "...",
"strengths": ["..."],
"weaknesses": ["..."]
},
"shareUrl": "https://openjung.org/type/enfp?ei=18&sn=28&tf=22&jp=32"
},
"recordId": "uuid"
}POST /api/record
POST /api/record
Record a completed test result (fire-and-forget).
javascript
POST /api/record
{
"answers": { ... },
"result": { "type": "ENFP", "scores": {...}, "percentages": {...} }
}记录已完成的测试结果(即发即弃)。
javascript
POST /api/record
{
"answers": { ... },
"result": { "type": "ENFP", "scores": {...}, "percentages": {...} }
}GET /api/stats
GET /api/stats
Get aggregate test statistics.
json
{
"totalTests": 15234,
"typeDistribution": [{ "type": "INFP", "count": 2341 }],
"localeDistribution": [{ "locale": "en", "count": 8234 }]
}获取测试汇总统计数据。
json
{
"totalTests": 15234,
"typeDistribution": [{ "type": "INFP", "count": 2341 }],
"localeDistribution": [{ "locale": "en", "count": 8234 }]
}Scoring System
评分体系
Scale: 1-5 Likert (1 = strongly left trait, 5 = strongly right trait)
Dimensions (8 questions each):
- EI: Extroversion (E) ↔ Introversion (I)
- SN: Sensing (S) ↔ Intuition (N)
- TF: Thinking (T) ↔ Feeling (F)
- JP: Judging (J) ↔ Perceiving (P)
Score Range: 8-40 per dimension (8 questions × 1-5 scale)
Threshold: 24 (midpoint)
- Score ≤ 24 → left preference (E, S, F, J)
- Score > 24 → right preference (I, N, T, P)
Note: TF dimension is inverted - low score = F (Feeling), high = T (Thinking)
量表:1-5级李克特量表(1 = 非常符合左侧特质,5 = 非常符合右侧特质)
维度(每个维度8道题):
- EI:外向(E)↔ 内向(I)
- SN:实感(S)↔ 直觉(N)
- TF:思考(T)↔ 情感(F)
- JP:判断(J)↔ 感知(P)
分数范围:每个维度8-40分(8道题 × 1-5分)
阈值:24(中点)
- 分数 ≤24 → 偏好左侧特质(E、S、F、J)
- 分数 >24 → 偏好右侧特质(I、N、T、P)
注意:TF维度是反向的——低分=情感(F),高分=思考(T)
Question Mapping
题目映射
| Dimension | Question IDs |
|---|---|
| JP | 1, 5, 9, 13, 17, 21, 25, 29 |
| TF | 2, 6, 10, 14, 18, 22, 26, 30 |
| EI | 3, 7, 11, 15, 19, 23, 27, 31 |
| SN | 4, 8, 12, 16, 20, 24, 28, 32 |
| 维度 | 题目ID |
|---|---|
| JP | 1, 5, 9, 13, 17, 21, 25, 29 |
| TF | 2, 6, 10, 14, 18, 22, 26, 30 |
| EI | 3, 7, 11, 15, 19, 23, 27, 31 |
| SN | 4, 8, 12, 16, 20, 24, 28, 32 |
Localization
本地化
44 languages supported. Pass parameter to endpoints:
locale- (English),
en(Simplified Chinese),zh(Japanese),ja(Korean)ko - (Spanish),
es(French),fr(German),de(Portuguese)pt - And 36 more...
支持44种语言。在端点中传递参数:
locale- (英语)、
en(简体中文)、zh(日语)、ja(韩语)ko - (西班牙语)、
es(法语)、fr(德语)、de(葡萄牙语)pt - 以及其他36种语言...
Error Handling
错误处理
| Error Code | Description |
|---|---|
| Malformed JSON |
| Missing/wrong answers format |
| Not all 32 questions answered |
| Server error |
| 错误代码 | 描述 |
|---|---|
| JSON格式错误 |
| 答案格式缺失/错误 |
| 未完成全部32道题 |
| 服务器错误 |
Resources
资源
For detailed API specifications and TypeScript types, see references/api_reference.md.
如需详细的API规范和TypeScript类型定义,请查看references/api_reference.md。