FamilySearch Genealogy Skill
Two modes of operation:
- 1. Live API (primary) — Query FamilySearch directly for person search, pedigree, descendants, historical records
- Offline GEDCOM — Parse exported
.ged files for local exploration, narratives, and statistics
Mode 1: FamilySearch API (Primary)
Prerequisites
- 1. FamilySearch Account — Free at
- Developer App Key — Register at
- OAuth 2.0 Access Token — Via authentication flow below
Store credentials:
Option A — Environment variable (all platforms):
CODEBLOCK0
Option B — macOS Keychain:
CODEBLOCK1
The script checks FAMILYSEARCH_TOKEN env var first, then falls back to macOS Keychain.
Authentication
OAuth 2.0 Authorization Code flow:
- 1. Direct user to: INLINECODE2
- User logs in, grants access
- Exchange code for token:
curl -X POST "https://ident.familysearch.org/cis-web/oauth2/v3/token" \
-d "grant_type=authorization_code&code={AUTH_CODE}&client_id={APP_KEY}"
- 4. Store returned
access_token in Keychain
Sandbox for testing: https://integration.familysearch.org / INLINECODE5
API Usage
CODEBLOCK3
| Command | Description |
|---|
| INLINECODE6 | Search persons in Family Tree |
| INLINECODE7 |
Get person details |
|
ancestry <PID> --generations 4 | Ascending pedigree (1-8 generations) |
|
descendants <PID> --generations 2 | Descending tree |
|
parents <PID> | Get parents |
|
spouses <PID> | Get spouses |
|
children <PID> | Get children |
Search parameters: --given, --surname, --birth-date, --birth-place, --death-date, --death-place, INLINECODE19
Results use GEDCOM X format (JSON). Key fields: persons[].id, persons[].display.name, .birthDate, .birthPlace, .deathDate, .deathPlace.
Ahnentafel numbering in ancestry: 1=subject, 2=father, 3=mother, 4=paternal grandfather, etc.
Mode 2: Offline GEDCOM Files
For exported .ged files from FamilySearch, Ancestry, MyHeritage, etc. No API key needed — pure offline.
Getting a GEDCOM File
FamilySearch: familysearch.org → Family Tree → Tools → Export GEDCOM
Usage
CODEBLOCK4
| Command | Description |
|---|
| INLINECODE27 | Fuzzy name search — returns matches with IDs |
| INLINECODE28 |
Full profile: birth, death, parents, spouses, children |
|
ancestors <id_or_name> [depth] | Pedigree chart up (default: 4 generations) |
|
descendants <id_or_name> [depth] | Pedigree chart down (default: 3 generations) |
|
story <id_or_name> | Narrative biography paragraph |
|
timeline <id_or_name> | Chronological life events |
|
stats | Tree summary: counts, surnames, birth decades, completeness |
|
find-date <year> | Find people born/died in a given year |
|
common-ancestor <name1> <name2> | Find closest common ancestor |
INLINECODE36 : GEDCOM ID (e.g., I001) or partial name (fuzzy, case-insensitive).
Narrative Genealogy
Beyond data retrieval, this skill supports narrative genealogy — connecting facts to stories:
- - Note occupations, migrations, life events when exploring a tree
- Cross-reference API/GEDCOM data with stories the user shares conversationally
- Build family narratives that explain why — not just dates and names
- Flag research opportunities: missing records, undocumented branches, conflicting dates
- Use
story command (GEDCOM mode) for auto-generated biographical narratives
Agent Workflow
- 1. User asks about family history → Check if they have a FamilySearch account (API) or GEDCOM file (offline)
- API mode: Search by name → get person ID → explore ancestry/descendants/relationships
- GEDCOM mode: Load file → search → explore
- Either mode: Combine structured data with user's oral history for richer narratives
- Cross-reference: Use API to find records that fill gaps in GEDCOM data
Rate Limits & Best Practices
- - FamilySearch API is free but rate-limited — cache results locally
- Never store FamilySearch usernames/passwords — OAuth tokens only
- Tokens expire; re-authenticate on 401 responses
- GEDCOM parser handles files up to ~100K individuals
- File encoding: auto-detects UTF-8 (with BOM), UTF-8, latin-1
FamilySearch 家谱技能
两种操作模式:
- 1. 实时 API(主要)— 直接查询 FamilySearch 进行人物搜索、世系、后代、历史记录
- 离线 GEDCOM — 解析导出的 .ged 文件,用于本地探索、叙述和统计
模式 1:FamilySearch API(主要)
前提条件
- 1. FamilySearch 账户 — 在 免费注册
- 开发者应用密钥 — 在 注册
- OAuth 2.0 访问令牌 — 通过以下认证流程获取
存储凭据:
选项 A — 环境变量(所有平台):
bash
export FAMILYSEARCH_TOKEN=
选项 B — macOS 钥匙串:
bash
security add-generic-password -a familysearch-app-key -s openclaw-familysearch -w
security add-generic-password -a familysearch-token -s openclaw-familysearch-token -w
脚本首先检查 FAMILYSEARCH_TOKEN 环境变量,然后回退到 macOS 钥匙串。
认证
OAuth 2.0 授权码流程:
- 1. 引导用户访问:https://ident.familysearch.org/cis-web/oauth2/v3/authorization?responsetype=code&clientid={APPKEY}&redirecturi={REDIRECT_URI}
- 用户登录并授予访问权限
- 用授权码换取令牌:
bash
curl -X POST https://ident.familysearch.org/cis-web/oauth2/v3/token \
-d grant
type=authorizationcode&code={AUTH
CODE}&clientid={APP_KEY}
- 4. 将返回的 access_token 存储在钥匙串中
沙箱用于测试:https://integration.familysearch.org / https://api-integ.familysearch.org
API 使用
bash
python scripts/familysearch.py <命令> [参数]
| 命令 | 描述 |
|---|
| search --given John --surname Lewis --birth-place Oregon | 在家族树中搜索人物 |
| person <PID> |
获取人物详情 |
| ancestry
--generations 4 | 向上世系(1-8代) |
| descendants --generations 2 | 向下世系树 |
| parents | 获取父母 |
| spouses | 获取配偶 |
| children | 获取子女 |
搜索参数:--given、--surname、--birth-date、--birth-place、--death-date、--death-place、--sex
结果使用 GEDCOM X 格式(JSON)。关键字段:persons[].id、persons[].display.name、.birthDate、.birthPlace、.deathDate、.deathPlace。
祖先编号在世系中:1=主体,2=父亲,3=母亲,4=祖父,以此类推。
模式 2:离线 GEDCOM 文件
适用于从 FamilySearch、Ancestry、MyHeritage 等导出的 .ged 文件。无需 API 密钥 — 纯离线。
获取 GEDCOM 文件
FamilySearch:familysearch.org → 家族树 → 工具 → 导出 GEDCOM
使用
bash
python scripts/gedcom_query.py <命令> [参数...]
| 命令 | 描述 |
|---|
| search <名称> | 模糊名称搜索 — 返回匹配结果及其ID |
| person <ID或名称> |
完整档案:出生、死亡、父母、配偶、子女 |
| ancestors [深度] | 向上世系图(默认:4代) |
| descendants [深度] | 向下世系图(默认:3代) |
| story | 叙述性传记段落 |
| timeline | 按时间顺序排列的人生事件 |
| stats | 家族树摘要:数量、姓氏、出生年代、完整性 |
| find-date <年份> | 查找在给定年份出生或去世的人 |
| common-ancestor <名称1> <名称2> | 查找最近的共同祖先 |
ID或名称:GEDCOM ID(例如 I001)或部分名称(模糊匹配,不区分大小写)。
叙述性家谱
除了数据检索,此技能还支持叙述性家谱 — 将事实与故事联系起来:
- - 在探索家族树时记录职业、迁徙、人生事件
- 将 API/GEDCOM 数据与用户在对话中分享的故事进行交叉引用
- 构建解释为什么的家族叙事 — 而不仅仅是日期和姓名
- 标记研究机会:缺失的记录、未记录的支系、冲突的日期
- 使用 story 命令(GEDCOM 模式)自动生成传记叙述
代理工作流程
- 1. 用户询问家族历史 → 检查他们是否有 FamilySearch 账户(API)或 GEDCOM 文件(离线)
- API 模式:按名称搜索 → 获取人物 ID → 探索祖先/后代/关系
- GEDCOM 模式:加载文件 → 搜索 → 探索
- 任一模式:将结构化数据与用户的口述历史结合,形成更丰富的叙述
- 交叉引用:使用 API 查找填补 GEDCOM 数据空白的记录
速率限制与最佳实践
- - FamilySearch API 免费但有速率限制 — 在本地缓存结果
- 切勿存储 FamilySearch 用户名/密码 — 仅使用 OAuth 令牌
- 令牌会过期;在收到 401 响应时重新认证
- GEDCOM 解析器可处理最多约 10 万人的文件
- 文件编码:自动检测 UTF-8(含 BOM)、UTF-8、latin-1