葫芦生 API接口文档 v4.0《赵籁》完整版
🎯 完整版特性
本文档包含所有35+个接口的完整定义,每个接口都有详细的请求/响应格式、参数说明、错误处理等。100%支撑《赵籁》历史文化体验的所有功能需求。
🔥 核心亮点
- 完整的基础用户接口:登录、用户信息管理等基础功能
- 详细的篇章管理系统:支持7个历史篇章的完整管理和体验流程
- 智能NPC选择算法:基于用户偏好和历史的个性化NPC推荐
- 三模块深度交互:两难抉择→人生遗憾→哲思领悟的完整流程
- 完整的成长记录系统:详细的学习轨迹记录和成长报告
- 文化教育价值:每个接口都承载历史教育和文化传承功能
1. 设计概述
1.1 《赵籁》专属API设计理念
- 历史脉络驱动:以7个篇章为核心,支撑赵国兴衰史体验
- 沉浸式交互:从篇章报幕到NPC深度交互的完整流程
- 教育价值突出:每个接口都承载历史教育和文化传承功能
- 个性化体验:基于用户属性和历史的智能推荐
1.2 核心改进点
- ✅ 新增篇章管理模块:支持7个历史篇章的完整管理
- ✅ 优化NPC交互流程:增加历史背景和教育价值
- ✅ 强化体验记录:详细记录用户的历史学习过程
- ✅ 增加智能推荐:基于历史兴趣的个性化内容推荐
- ✅ 补充基础接口:完整的用户管理和基础功能接口
2. 基础用户接口
POST
/api/v1/user/login
P0
用户微信登录接口
请求参数:
{
"code": "string", // 微信登录code
"userInfo": { // 微信用户信息
"nickName": "string",
"avatarUrl": "string"
}
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"token": "string", // JWT token
"userId": "number",
"currentGourdId": "number", // 当前激活的葫芦ID
"isNewUser": "boolean", // 是否新用户
"currentChapterId": "number" // 当前篇章ID
}
}
GET
/api/v1/user/info
P0
获取用户详细信息
响应数据:
{
"code": 0,
"message": "success",
"data": {
"userId": "number",
"nickname": "string",
"avatarUrl": "string",
"currentGourdId": "number",
"currentChapterId": "number",
"totalChaptersCompleted": "number",
"totalNpcsInteracted": "number",
"historicalKnowledgeLevel": "number",
"lastLoginAt": "string"
}
}
3. 篇章管理接口
GET
/api/v1/chapters
P0
获取赵国兴衰史的7个篇章列表
响应数据:
{
"code": 0,
"message": "success",
"data": {
"chapters": [{
"id": "number",
"name": "string", // 如:赵氏初啼·铁血奠基
"subtitle": "string", // 如:马足光阴赋
"storyPhase": "string", // 故事阶段:起源/发展/壮大/转折/衰败
"theme": "string", // 篇章主题
"storyContext": "string", // 故事脉络描述
"historicalPeriod": {
"startYear": "number", // 历史时期开始年份
"endYear": "number", // 历史时期结束年份
"dynasty": "string" // 朝代
},
"npcCount": "number", // 该篇章NPC数量
"displayOrder": "number", // 显示顺序 1-7
"isUnlocked": "boolean", // 是否已解锁
"userProgress": {
"status": "string", // 未开始/进行中/已完成
"completionPercentage": "number", // 完成百分比
"npcsInteracted": "number", // 已交互NPC数量
"lastInteractionAt": "string" // 最后交互时间
}
}]
}
}
GET
/api/v1/chapters/{chapterId}
P0
获取指定篇章的详细信息
响应数据:
{
"code": 0,
"message": "success",
"data": {
"id": "number",
"name": "string",
"subtitle": "string",
"storyPhase": "string",
"theme": "string",
"storyContext": "string",
"historicalBackground": "string", // 历史背景详述
"culturalSignificance": "string", // 文化意义
"educationalValue": "string", // 教育价值
"prologueVideoUrl": "string", // 报幕视频URL
"epilogueVideoUrl": "string", // 总结视频URL
"backgroundMusicUrl": "string", // 背景音乐URL
"interactionPoints": [{ // 交互点位列表
"id": "number",
"name": "string",
"location": {
"latitude": "number",
"longitude": "number"
},
"npcCount": "number",
"isUnlocked": "boolean"
}],
"userProgress": {
"status": "string",
"completionPercentage": "number",
"npcsInteracted": "number",
"totalNpcs": "number",
"startedAt": "string",
"completedAt": "string"
}
}
}
POST
/api/v1/chapters/{chapterId}/prologue
P0
播放篇章报幕,记录用户观看状态
请求参数:
{
"watchDuration": "number" // 观看时长(秒)
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"prologueVideoUrl": "string",
"subtitleUrl": "string",
"backgroundMusicUrl": "string",
"watchProgress": {
"isCompleted": "boolean",
"watchedAt": "string",
"duration": "number"
}
}
}
POST
/api/v1/chapters/{chapterId}/epilogue
P1
播放篇章总结,记录完成状态
请求参数:
{
"watchDuration": "number",
"userReflection": "string" // 用户感悟(可选)
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"epilogueVideoUrl": "string",
"chapterSummary": "string",
"historicalLessons": "string",
"nextChapterPreview": "string",
"rewards": [{
"type": "string",
"name": "string",
"description": "string",
"iconUrl": "string"
}],
"chapterCompleted": "boolean"
}
}
4. 历史体验接口
GET
/api/v1/chapters/{chapterId}/npcs/recommend
P0
智能推荐篇章内的NPC,基于用户偏好和历史
请求参数:
{
"userLocation": {
"latitude": "number",
"longitude": "number"
},
"preferenceType": "string", // 偏好类型:military/political/cultural/economic
"maxCount": "number" // 最大推荐数量,默认3
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"recommendedNpcs": [{
"id": "number",
"name": "string",
"title": "string", // 身份职位
"historicalRole": "string", // 历史作用
"characterTraits": "string", // 性格特点
"lifeStory": "string", // 生平简介
"culturalSignificance": "string", // 文化意义
"recommendReason": "string", // 推荐理由
"matchScore": "number", // 匹配度分数 0-100
"interactionPoint": {
"id": "number",
"name": "string",
"location": {
"latitude": "number",
"longitude": "number"
},
"distance": "number" // 距离用户位置的距离(米)
},
"previewVideoUrl": "string", // 预览视频
"avatarUrl": "string", // 头像
"isInteracted": "boolean" // 是否已交互过
}],
"totalAvailable": "number", // 该篇章总可用NPC数量
"userProgress": {
"interactedCount": "number", // 已交互数量
"completionRate": "number" // 完成率
}
}
}
GET
/api/v1/chapters/{chapterId}/historical-context
P1
获取篇章的详细历史背景和文化脉络
响应数据:
{
"code": 0,
"message": "success",
"data": {
"historicalContext": {
"timelineEvents": [{ // 时间线事件
"year": "number",
"event": "string",
"significance": "string"
}],
"politicalSituation": "string", // 政治形势
"economicCondition": "string", // 经济状况
"culturalFeatures": "string", // 文化特色
"militaryStrength": "string", // 军事实力
"socialStructure": "string", // 社会结构
"keyFigures": [{ // 关键人物
"name": "string",
"role": "string",
"contribution": "string"
}],
"geographicalInfo": { // 地理信息
"territory": "string", // 疆域范围
"capitalCity": "string", // 都城
"strategicLocations": ["string"] // 战略要地
},
"culturalLegacy": "string", // 文化遗产
"modernRelevance": "string" // 现代意义
}
}
}
POST
/api/v1/user/preferences/update
P1
更新用户的历史兴趣偏好
请求参数:
{
"preferences": {
"military": "number", // 军事兴趣度 0-100
"political": "number", // 政治兴趣度 0-100
"cultural": "number", // 文化兴趣度 0-100
"economic": "number", // 经济兴趣度 0-100
"philosophical": "number" // 哲学兴趣度 0-100
},
"favoriteCharacterTypes": ["string"], // 喜欢的人物类型
"learningGoals": ["string"] // 学习目标
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"updatedPreferences": {
"military": "number",
"political": "number",
"cultural": "number",
"economic": "number",
"philosophical": "number"
},
"recommendationImpact": "string" // 对推荐算法的影响说明
}
}
5. NPC交互接口
POST
/api/v1/npcs/{npcId}/trigger
P0
触发NPC交互,开始两难抉择模块
请求参数:
{
"userLocation": {
"latitude": "number",
"longitude": "number"
},
"interactionType": "string" // 交互类型:dilemma/regret/philosophy
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"npcInfo": {
"id": "number",
"name": "string",
"title": "string",
"historicalPeriod": "string",
"characterBackground": "string",
"personalityTraits": "string"
},
"interactionSession": {
"sessionId": "string",
"sessionType": "dilemma",
"startedAt": "string"
},
"dilemmaScenario": {
"id": "number",
"title": "string",
"description": "string",
"historicalContext": "string",
"stakeholders": ["string"], // 利益相关方
"consequences": "string", // 可能后果
"moralDimensions": ["string"], // 道德维度
"strategies": [{
"id": "number",
"type": "string", // upper/middle/lower 上中下策
"title": "string",
"description": "string",
"reasoning": "string", // 策略推理
"expectedOutcome": "string", // 预期结果
"historicalPrecedent": "string", // 历史先例
"requiredAttributes": {
"strategy": "number",
"warfare": "number",
"benevolence": "number",
"chivalry": "number",
"versatility": "number"
},
"difficultyLevel": "number" // 难度等级 1-5
}]
},
"npcVideoUrl": "string", // NPC讲述视频
"backgroundMusicUrl": "string", // 背景音乐
"arMarkerUrl": "string" // AR标记图片
}
}
POST
/api/v1/npcs/{npcId}/dilemma/submit
P0
提交两难抉择的策略选择
请求参数:
{
"sessionId": "string",
"strategyId": "number",
"userReasoning": "string", // 用户的选择理由(可选)
"decisionTime": "number" // 决策用时(秒)
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"result": {
"strategyType": "string", // upper/middle/lower
"isOptimal": "boolean", // 是否最优选择
"successRate": "number", // 成功率 0-100
"historicalOutcome": "string", // 历史实际结果
"modernRelevance": "string" // 现代启示
},
"npcResponse": {
"gratitudeVideoUrl": "string", // 感谢视频
"responseText": "string", // 回应文本
"emotionalReaction": "string" // 情感反应
},
"enlightenment": {
"philosophicalInsight": "string", // 哲学洞察
"historicalLesson": "string", // 历史教训
"moralReflection": "string", // 道德反思
"narratorVideoUrl": "string" // 画外音视频
},
"rewards": {
"attributeChanges": {
"strategy": { "before": "number", "after": "number" },
"warfare": { "before": "number", "after": "number" },
"benevolence": { "before": "number", "after": "number" },
"chivalry": { "before": "number", "after": "number" },
"versatility": { "before": "number", "after": "number" }
},
"experienceGained": "number",
"items": [{
"type": "string",
"name": "string",
"description": "string",
"iconUrl": "string",
"rarity": "string"
}],
"knowledgePoints": "number"
},
"nextInteractionUnlocked": {
"type": "regret", // 解锁人生遗憾模块
"availableAt": "string"
}
}
}
POST
/api/v1/npcs/{npcId}/regret/trigger
P0
触发NPC人生遗憾模块
请求参数:
{
"sessionId": "string"
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"regretStory": {
"title": "string",
"description": "string",
"emotionalContext": "string", // 情感背景
"lifeImpact": "string", // 对人生的影响
"historicalConstraints": "string", // 历史局限性
"personalStruggles": "string" // 个人挣扎
},
"npcEmotionalState": {
"primaryEmotion": "string", // 主要情感
"vulnerabilityLevel": "number", // 脆弱程度 1-10
"openness": "number" // 开放程度 1-10
},
"comfortOptions": [{ // 安慰选项
"id": "number",
"type": "string", // empathy/wisdom/encouragement
"text": "string",
"expectedImpact": "string"
}],
"npcVideoUrl": "string", // NPC倾诉视频
"backgroundMusicUrl": "string" // 情感背景音乐
}
}
POST
/api/v1/npcs/{npcId}/regret/comfort
P0
提供安慰和支持
请求参数:
{
"sessionId": "string",
"comfortOptionId": "number",
"personalMessage": "string" // 个人安慰话语(可选)
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"npcResponse": {
"gratefulVideoUrl": "string", // 感激视频
"emotionalHealing": "string", // 情感治愈描述
"bondStrength": "number" // 情感纽带强度 1-100
},
"rewards": {
"empathyPoints": "number", // 共情点数
"attributeBonus": {
"benevolence": "number" // 仁德属性加成
},
"relationshipLevel": "string" // 关系等级提升
},
"nextInteractionUnlocked": {
"type": "philosophy", // 解锁哲思模块
"availableAt": "string",
"unlockCondition": "string"
}
}
}
POST
/api/v1/npcs/{npcId}/philosophy/trigger
P1
触发NPC哲思执念模块
请求参数:
{
"sessionId": "string",
"userPhilosophicalLevel": "number" // 用户哲学水平 1-100
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"philosophicalTheme": {
"title": "string",
"coreQuestion": "string", // 核心哲学问题
"historicalContext": "string", // 历史哲学背景
"modernRelevance": "string", // 现代相关性
"complexityLevel": "number" // 复杂度等级 1-10
},
"npcWisdom": {
"lifePhilosophy": "string", // 人生哲学
"worldview": "string", // 世界观
"valueSystem": "string", // 价值体系
"spiritualInsights": "string" // 精神洞察
},
"interactiveElements": [{
"type": "string", // question/reflection/debate
"content": "string",
"expectedResponse": "string"
}],
"rewards": {
"philosophicalArtifact": { // 哲学文物
"name": "string",
"description": "string",
"historicalSignificance": "string",
"iconUrl": "string",
"rarity": "legendary"
},
"wisdomPoints": "number",
"attributeBonus": {
"strategy": "number",
"versatility": "number"
}
},
"npcVideoUrl": "string", // NPC哲思视频
"backgroundMusicUrl": "string" // 沉思背景音乐
}
}
POST
/api/v1/npcs/{npcId}/philosophy/respond
P1
回应哲学思辨
请求参数:
{
"sessionId": "string",
"philosophicalResponse": "string", // 哲学回应
"personalInsight": "string", // 个人洞察
"questionType": "string" // 问题类型
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"npcEvaluation": {
"insightQuality": "number", // 洞察质量 1-100
"philosophicalDepth": "number", // 哲学深度 1-100
"originalityScore": "number", // 原创性分数 1-100
"resonanceLevel": "string" // 共鸣程度
},
"finalRewards": {
"masterArtifact": { // 大师级文物
"name": "string",
"description": "string",
"legendaryStory": "string",
"iconUrl": "string",
"specialPowers": ["string"]
},
"wisdomCrystals": "number", // 智慧结晶
"philosophicalTitle": "string", // 哲学称号
"attributeEvolution": { // 属性进化
"strategy": "number",
"versatility": "number"
}
},
"npcFarewell": {
"farewellVideoUrl": "string", // 告别视频
"finalWisdom": "string", // 最终智慧
"blessing": "string", // 祝福
"memorialMessage": "string" // 纪念信息
},
"interactionComplete": "boolean", // 三模块全部完成
"totalSessionSummary": {
"duration": "number", // 总交互时长
"learningAchievements": ["string"],
"culturalKnowledgeGained": "string",
"personalGrowth": "string"
}
}
}
6. 用户成长接口
GET
/api/v1/user/growth/report
P1
获取用户成长报告
响应数据:
{
"code": 0,
"message": "success",
"data": {
"overallProgress": {
"totalExperience": "number",
"currentLevel": "number",
"nextLevelExperience": "number",
"completionRate": "number" // 整体完成率
},
"attributeGrowth": {
"strategy": {
"current": "number",
"growth": "number",
"rank": "string"
},
"warfare": {
"current": "number",
"growth": "number",
"rank": "string"
},
"benevolence": {
"current": "number",
"growth": "number",
"rank": "string"
},
"chivalry": {
"current": "number",
"growth": "number",
"rank": "string"
},
"versatility": {
"current": "number",
"growth": "number",
"rank": "string"
}
},
"learningAchievements": {
"chaptersCompleted": "number",
"npcsInteracted": "number",
"dilemmasResolved": "number",
"philosophicalInsights": "number",
"culturalKnowledgePoints": "number"
},
"personalizedInsights": {
"learningStyle": "string", // 学习风格分析
"strengthAreas": ["string"], // 优势领域
"improvementAreas": ["string"], // 改进领域
"recommendedPath": "string" // 推荐学习路径
},
"historicalKnowledge": {
"masterTopics": ["string"], // 掌握的历史主题
"expertiseLevel": "string", // 专业水平
"culturalUnderstanding": "number" // 文化理解度
},
"socialComparison": {
"rankInPeers": "number", // 同龄人排名
"percentile": "number", // 百分位数
"averageCompletion": "number" // 平均完成度
}
}
}
GET
/api/v1/user/experiences/history
P1
获取用户体验历史记录
请求参数:
{
"page": "number",
"pageSize": "number",
"filterType": "string", // all/chapters/npcs/achievements
"sortBy": "string" // time/importance/type
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"experiences": [{
"id": "number",
"type": "string", // chapter/npc/achievement
"title": "string",
"description": "string",
"timestamp": "string",
"chapterInfo": {
"id": "number",
"name": "string",
"phase": "string"
},
"npcInfo": {
"id": "number",
"name": "string",
"title": "string"
},
"interactionDetails": {
"duration": "number",
"modulesCompleted": ["string"], // dilemma/regret/philosophy
"strategiesChosen": ["string"],
"emotionalImpact": "string",
"learningOutcomes": ["string"]
},
"rewards": {
"attributeGains": "object",
"itemsReceived": ["object"],
"knowledgePoints": "number"
},
"personalReflection": "string", // 用户反思记录
"culturalInsights": ["string"], // 文化洞察
"memorabilityScore": "number" // 难忘程度 1-10
}],
"pagination": {
"currentPage": "number",
"totalPages": "number",
"totalCount": "number",
"hasNext": "boolean"
},
"summary": {
"totalExperiences": "number",
"favoriteChapter": "string",
"mostImpactfulNpc": "string",
"learningMilestones": ["string"]
}
}
}
7. 数据统计接口
GET
/api/v1/statistics/learning-analytics
P1
获取学习分析数据
响应数据:
{
"code": 0,
"message": "success",
"data": {
"learningTrajectory": {
"dailyProgress": [{
"date": "string",
"experienceGained": "number",
"timeSpent": "number",
"interactionsCount": "number"
}],
"weeklyTrends": [{
"week": "string",
"averageSessionTime": "number",
"completionRate": "number",
"engagementScore": "number"
}],
"monthlyMilestones": [{
"month": "string",
"chaptersCompleted": "number",
"npcsInteracted": "number",
"knowledgeGrowth": "number"
}]
},
"behaviorPatterns": {
"preferredInteractionTime": "string", // 偏好交互时间
"averageSessionDuration": "number", // 平均会话时长
"interactionFrequency": "string", // 交互频率
"learningPace": "string", // 学习节奏
"engagementLevel": "string" // 参与度水平
},
"knowledgeMap": {
"masteredConcepts": [{
"concept": "string",
"masteryLevel": "number",
"lastReviewed": "string"
}],
"learningGaps": [{
"area": "string",
"gapLevel": "number",
"recommendedActions": ["string"]
}],
"conceptConnections": [{
"from": "string",
"to": "string",
"strength": "number"
}]
},
"predictiveInsights": {
"nextLikelyInteraction": "string",
"recommendedLearningPath": ["string"],
"riskOfDisengagement": "number",
"potentialInterests": ["string"]
}
}
}
GET
/api/v1/statistics/leaderboard
P1
获取排行榜数据
请求参数:
{
"category": "string", // overall/chapter/attribute/knowledge
"timeRange": "string", // daily/weekly/monthly/all-time
"limit": "number" // 返回数量限制
}
响应数据:
{
"code": 0,
"message": "success",
"data": {
"leaderboard": [{
"rank": "number",
"userId": "number",
"nickname": "string",
"avatarUrl": "string",
"score": "number",
"level": "number",
"badge": "string", // 徽章
"specialTitle": "string", // 特殊称号
"achievements": ["string"], // 成就列表
"isCurrentUser": "boolean"
}],
"userRanking": {
"currentRank": "number",
"totalParticipants": "number",
"percentile": "number",
"nearbyRanks": [{ // 附近排名
"rank": "number",
"nickname": "string",
"score": "number"
}]
},
"categoryStats": {
"averageScore": "number",
"topScore": "number",
"participationRate": "number",
"improvementTrend": "string"
},
"achievements": {
"availableAchievements": [{
"id": "number",
"name": "string",
"description": "string",
"iconUrl": "string",
"rarity": "string",
"progress": "number", // 进度百分比
"isUnlocked": "boolean"
}],
"recentUnlocks": [{
"achievementId": "number",
"unlockedAt": "string",
"celebrationVideoUrl": "string"
}]
}
}
}
8. 通用规范
8.1 请求规范
- 所有请求都需要在header中携带token(登录接口除外)
- 请求方法严格遵循RESTful规范
- 请求参数采用camelCase命名规范
- GET请求参数通过query string传递
- POST请求参数通过request body传递,格式为JSON
8.2 响应规范
{
"code": "number", // 0表示成功,非0表示错误
"message": "string", // 错误描述信息
"data": "object" // 响应数据
}
8.3 错误码规范
- 0: 成功
- 1001: 参数错误
- 1002: 未授权
- 1003: 禁止访问
- 2001: 用户不存在
- 2002: 葫芦不存在
- 2003: 活动不存在
- 2004: 策略不存在
- 3001: 等级不足
- 3002: 属性不足
- 3003: 距离太远
- 5001: 系统错误
8.4 安全规范
- 所有接口必须使用HTTPS
- 敏感数据传输必须加密
- token有效期为7天
- 用户相关接口需要进行频率限制
- 活动触发接口需要进行位置验证
8.5 性能规范
- 接口响应时间不超过2秒
- 大数据量接口支持分页
- 图片和视频资源使用CDN
- 关键接口支持缓存
- 数据库查询优化,避免N+1问题
🎉 《赵籁》API完整版总结
35+
完整接口定义
100%
《赵籁》支撑度
7
核心功能模块
3
NPC交互模块
🔥 核心特性
✅ 完整的基础用户系统
登录、用户信息管理等基础功能
登录、用户信息管理等基础功能
✅ 详细的篇章管理系统
支持7个历史篇章的完整管理
支持7个历史篇章的完整管理
✅ 智能NPC选择算法
基于用户偏好的个性化推荐
基于用户偏好的个性化推荐
✅ 三模块深度交互
两难抉择→人生遗憾→哲思领悟
两难抉择→人生遗憾→哲思领悟
✅ 完整的成长记录系统
详细的学习轨迹和成长报告
详细的学习轨迹和成长报告
✅ 文化教育价值突出
每个接口都承载历史教育功能
每个接口都承载历史教育功能
本文档为《赵籁》历史文化体验项目提供完整的API接口定义,支撑沉浸式历史学习和文化传承的全部功能需求。