notion-accounting-analysis

Notion记账财务数据分析技能,自动读取支出收入流水表,全量翻页获取数据,100%解析relation类别字段,按年月类别标签多维分析并生成Markdown财务报告。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "notion-accounting-analysis" with this command: npx skills add jimislg/notion-accounting-analysis

Notion 记账数据分析 Skill

适用场景:用户说"分析我的 Notion 记账数据"、"生成财务报告"、"查看收支趋势"时触发。 前置条件:用户提供 Notion Integration Token(secret_xxx 格式)和 data_source_id。


核心能力

  1. 全量数据获取 — 自动翻页(处理 Notion API has_more),不漏任何记录
  2. relation 字段 100% 解析 — 先收集所有 relation ID,再批量并发查询对应名称,零遗漏
  3. 多维分析 — 按年/月/类别/标签/大额 TOP 多角度剖析
  4. 智能报告生成 — 自动输出 Markdown 报告到 /workspace/,带优化建议
  5. 异常主动提示 — 若 relation ID 无法解析,会列出 ID 并提示如何修复

已知 relation ID → 类别名称(已验证)

relation ID(前8位)对应类别
2e1bd123...817c房租
2e1bd123...80e8旅游娱乐
2e1bd123...8081房贷
2e1bd123...815a餐饮
2e1bd123...8004总记账
2e1bd123...806f医疗
2e1bd123...8059购物
2e1bd123...80d4所得税
2e1bd123...817f交通
2e1bd123...81dd人情往来
2e1bd123...8084专项
2e1bd123...810d运动
2e1bd123...8054公司额外
2e1bd123...81de日用

💡 若发现新的 relation ID 查不到名称:在 Notion 中打开该记录页面 → 右上角 ...Add connections → 添加 Integration 即可。


字段识别规范(重要踩坑记录)

支出流水表通常有两个分类字段,优先级:

字段类型处理方式
支出类别relation通过 API 查询名称,必须
标签select直接存储名称,可用

错误:只用 select,忽略 relation → 类别大量丢失。 正确:relation 用 ID 查表,select 直接用,两者结合覆盖 100% 类别。


执行流程

第 1 步:确认数据源

用户未提供 data_source_id 时,用搜索接口查找:

curl -s -X POST "https://api.notion.com/v1/search" \
  -H "Authorization: Bearer $NOTION_API_TOKEN" \
  -H "Notion-Version: 2025-09-03" \
  -d '{"query": "支出", "page_size": 20}' \
  | jq '.results[] | {id, title: .properties.Name.title[0].plain_text}'

第 2 步:全量获取数据(必须翻页)

// 错误:只查第一页 → 数据不完整
const page = await fetch('/v1/data_sources/{id}/query', {page_size: 100});

// 正确:循环直到 has_more = false
let cursor = null;
do {
  const body = cursor ? {page_size:100, start_cursor:cursor} : {page_size:100};
  const page = await fetch('/v1/data_sources/{id}/query', body);
  results.push(...page.results);
  cursor = page.has_more ? page.next_cursor : null;
} while (cursor);

第 3 步:relation ID 批量解析(必须)

// 第一步:收集所有 relation IDs(不重复)
const allIds = [...new Set(results.flatMap(r =>
  (r.properties['支出类别']?.relation || []).map(rel => rel.id)
))];

// 第二步:并发查询所有 ID(每个只查一次)
const relMap = Object.fromEntries(
  await Promise.all(allIds.map(async id => [id, await resolvePageName(id)]))
);

第 4 步:分析并输出报告

# 可直接使用附带的分析脚本
node analyze.mjs <token> <expense_data_source_id> [income_data_source_id] [year]

常见错误处理

现象原因解决方案
类别全是"未分类"只用了 select,relation 全部丢失改用 relation ID 查表
总支出比预期少只查了第一页(100条),还有后续页循环翻页直到 has_more=false
relation ID 查不到名称记录不在 integration 可见范围内Notion 页面 → Add connections
金额对不上select 和 relation 重复计算了同一笔select 和 relation 只取一个字段

分析报告模板

# {年份} 年度财务分析报告

> 数据来源:Notion 支出流水表 & 收入流水表
> 分析范围:{年}年({n}笔支出,{n}笔收入)

## 一、收支总览
## 二、月度趋势
## 三、类别分析(relation 100% 解析)
## 四、标签分析
## 五、TOP N 大额支出
## 六、优化建议

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Research

FN Portrait Toolkit

Financial report footnote extraction and analysis tool for Chinese A-share listed companies. Use when: (1) User wants to extract financial note data from ann...

Registry SourceRecently Updated
260Profile unavailable
Research

Amoeba Management Analysis

阿米巴经营分析技能。基于稻盛和夫阿米巴经营理念,提供单位时间核算、经营会计报表分析、阿米巴组织划分评估、业绩改善诊断等能力。 当用户需要做阿米巴经营分析、单位时间核算、经营会计、阿米巴组织划分、利润中心分析、内部交易定价、业绩评价时触发。 触发词:阿米巴、阿米巴经营、单位时间核算、经营会计、利润中心、内部交易、阿...

Registry SourceRecently Updated
810Profile unavailable
Research

AgentPit 财经综合分析

多维度股票综合分析,整合三个专业AI分析系统:日交易技术面分析、TradingAgents多智能体分析、AI对冲基金大师视角。当用户提到分析股票、买不买某股票、股票行情时触发。

Registry SourceRecently Updated
760Profile unavailable
Research

Quant Tools 1.0.0

学术导向量化研究工具集。包含7大核心库(因子分析、组合优化、AI增强、因果验证、衍生品定价、回测引擎、情感分析)和5大投研工具(VeighNa交易框架、Qlib AI投研、WTP高性能框架、AkShare数据接口、JupyterHub研究环境)。适用于策略研发、因子挖掘、论文复现、资产配置、API服务化等投研任务...

Registry SourceRecently Updated
1470Profile unavailable