api-endpoint-design
БесплатноБез исполняемых скриптовНе проверенAPI endpoint design and testing for vehicle insurance data platform. Use when designing new API endpoints, testing existing ones, validating response formats…
от FDU-INS★ 84 звезды на GitHubОб этом скилле
API Endpoint Design
REST API design specifications for vehicle insurance data analysis platform.
Key Files:
- backend/api_server.py - Flask API server
- frontend/src/services/api.js - Frontend API client
Related Docs:
- See TESTING_TEMPLATE.md for unit test templates
- See COMMON_ISSUES.md for troubleshooting
📚 一、API 端点清单
概览表格
| 端点 | 方法 | 功能 | 优先级 |
|---|---|---|---|
/api/health |
GET | 健康检查 | P0 |
/api/latest-date |
GET | 获取最新日期 | P0 |
/api/refresh |
POST | 刷新数据 | P0 |
/api/filter-options |
GET | 获取筛选选项 | P0 |
/api/kpi-windows |
POST | KPI 三口径数据 | P0 |
/api/week-comparison |
POST | 周对比图表数据 | P0 |
/api/insurance-type-distribution |
POST | 险别组合占比 | P0 |
/api/premium-range-distribution |
POST | 业务员保费区间占比 | P0 |
/api/renewal-type-distribution |
POST | 新转续占比 | P0 |
/api/policy-mapping |
GET | 保单映射信息 | P1 |
/api/staff-performance-distribution |
POST | 业务员业绩分布 | P1 |
1.1 /api/health - 健康检查
请求:
GET /api/health
响应:
{
"status": "healthy",
"message": "API服务运行正常"
}
测试示例:
curl http://localhost:5001/api/health
1.2 /api/latest-date - 获取最新日期
响应:
{
"success": true,
"latest_date": "2025-11-08"
}
错误响应:
{
"success": false,
"message": "获取最新日期失败: 未找到数据文件"
}
测试示例:
curl http://localhost:5001/api/latest-date
1.3 /api/refresh - 刷新数据
请求: POST /api/refresh
响应:
{
"success": true,
"message": "数据刷新成功",
"latest_date": "2025-11-08"
}
注意事项:
- ⚠️ 此操作较耗时(大文件可能 10-30 秒)
- ⚠️ 前端应显示加载状态
- ⚠️ 建议设置 60 秒超时
测试示例:
curl -X POST http://localhost:5001/api/refresh
1.4 /api/filter-options - 获取筛选选项
响应:
{
"success": true,
"data": {
"三级机构": ["达州", "德阳", "绵阳", "南充"],
"团队": ["达州业务一部", "德阳业务三部"],
"是否续保": ["是", "否"],
"是否新能源": ["是", "否"],
"是否过户车": ["是", "否"],
"险种大类": ["商业险", "交强险"],
"吨位": ["<2吨", "2-5吨", "5-10吨", ">10吨"],
"是否电销": ["全部", "是", "否"],
"机构团队映射": {
"达州": ["业务一部", "业务二部"],
"德阳": ["业务三部"]
},
"保单号": ["P202511080001", "P202511080002", "..."]
}
}
测试示例:
curl http://localhost:5001/api/filter-options
1.5 /api/kpi-windows - KPI 三口径数据
请求:
POST /api/kpi-windows
Content-Type: application/json
{
"filters": {
"三级机构": "达州",
"团队": "业务一部",
"是否续保": "是"
},
"date": "2025-11-08"
}
参数说明:
filters(object, 可选): 筛选条件date(string, 可选): 锚定日期 (YYYY-MM-DD), 默认为最新日期
响应:
{
"success": true,
"data": {
"anchor_date": "2025-11-08",
"premium": {
"day": 125000.50,
"last7d": 875420.30,
"last30d": 3250800.75
},
"policy_count": {
"day": 234,
"last7d": 1680,
"last30d": 6420
},
"commission": {
"day": 5000.00,
"last7d": 35016.81,
"last30d": 130032.03
}
}
}
业务逻辑:
- 当日(day): 指定日期当天的数据
- 近7天(last7d): 从指定日期往前推 6 天(共 7 天)
- 近30天(last30d): 从指定日期往前推 29 天(共 30 天)
测试示例:
curl -X POST http://localhost:5001/api/kpi-windows \
-H "Content-Type: application/json" \
-d '{"filters": {"三级机构": "达州"}}'
1.6 /api/week-comparison - 周对比图表数据
请求:
POST /api/week-comparison
Content-Type: application/json
{
"metric": "premium",
"filters": {"三级机构": "达州"},
"date": "2025-11-08"
}
参数说明:
metric(string, 必填): 指标类型 (premium或count)filters(object, 可选): 筛选条件date(string, 可选): 锚定日期
响应:
{
"success": true,
"data": {
"x_axis": ["周三", "周四", "周五", "周六", "周日", "周一", "周二"],
"series": [
{
"name": "D-14 (10-25)",
"data": [120000, 135000, 98000, 110000, 125000, 95000, 98000]
},
{
"name": "D-7 (11-01)",
"data": [95000, 88000, 92000, 105000, 98000, 87000, 92000]
},
{
"name": "D (11-08)",
"data": [112000, 118000, 105000, 120000, 115000, 110000, 111000]
}
]
}
}
周期划分: 以锚定日期为结束日,往前推 7 天为一个周期
- D: 最近 7 天(11-08 ~ 11-14)
- D-7: 次近 7 天(11-01 ~ 11-07)
- D-14: 第三个 7 天(10-25 ~ 10-31)
测试示例:
curl -X POST http://localhost:5001/api/week-comparison \
-H "Content-Type: application/json" \
-d '{"metric": "premium"}'
1.7 /api/policy-mapping - 保单映射信息
位置: [api_server.py:141-161]
Установить api-endpoint-design в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadEditGrepGlobFAQ
Что делает скилл api-endpoint-design?
API endpoint design and testing for vehicle insurance data platform. Use when designing new API endpoints, testing existing ones, validating response formats, or debugging API issues. Covers 11 core endpoints including 3 new pie chart distribution endpoints, parameter validation, error handling, and integration patterns.
Как установить скилл api-endpoint-design?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл api-endpoint-design запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic