npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

familysearch-sdk

v1.0.9

Published

Modern TypeScript SDK for FamilySearch API v3 - OAuth, Places API, Tree API, and GEDCOM utilities

Readme

familysearch-sdk

A modern, TypeScript-first SDK for the FamilySearch API v3.

Features

  • 🔷 Full TypeScript support with comprehensive type definitions
  • 🔐 OAuth v3 compatible authentication utilities
  • 📊 Promise-based API for async operations
  • 🌍 Environment support (production, beta, integration)
  • 📝 GEDCOM export - Convert FamilySearch data to GEDCOM 5.5 format
  • 📍 Places API helpers for location searches
  • 👨‍👩‍👧 Tree/Pedigree API for ancestry data

Installation

npm install familysearch-sdk

Quick Start

import {
  createFamilySearchSDK,
  fetchPedigree,
  convertToGedcom
} from 'familysearch-sdk';

// Create SDK instance with your OAuth access token
const sdk = createFamilySearchSDK({
  environment: 'production',
  accessToken: 'your-oauth-token'
});

// Fetch pedigree data
const pedigree = await fetchPedigree(sdk, undefined, {
  generations: 5,
  onProgress: (progress) => {
    console.log(`${progress.percent}% complete`);
  }
});

// Convert to GEDCOM format
const gedcom = convertToGedcom(pedigree, {
  treeName: 'My Family Tree'
});

console.log(gedcom);

OAuth Authentication

The SDK provides utilities for OAuth 2.0 authentication with FamilySearch.

import {
  generateOAuthState,
  buildAuthorizationUrl,
  exchangeCodeForToken,
  validateAccessToken
} from 'familysearch-sdk/auth';

// Generate state for CSRF protection
const state = generateOAuthState();

// Build authorization URL
const authUrl = buildAuthorizationUrl({
  clientId: 'your-client-id',
  redirectUri: 'https://your-app.com/callback',
  environment: 'production'
}, state);

// Redirect user to authUrl...

// After callback, exchange code for token
const tokens = await exchangeCodeForToken(code, {
  clientId: 'your-client-id',
  redirectUri: 'https://your-app.com/callback',
  environment: 'production'
});

// Validate token
const isValid = await validateAccessToken(tokens.access_token, 'production');

Places API

Search and retrieve place information from FamilySearch.

import { createFamilySearchSDK } from 'familysearch-sdk';
import { searchPlaces, getPlaceDetails } from 'familysearch-sdk/places';

const sdk = createFamilySearchSDK({ accessToken: 'token' });

// Search for places
const results = await searchPlaces(sdk, 'London, England', {
  date: '1850',
  count: 10
});

// Get place details
const details = await getPlaceDetails(sdk, 'place-id');
console.log(details.name, details.latitude, details.longitude);

Tree/Pedigree API

Fetch and manage family tree data.

import { createFamilySearchSDK } from 'familysearch-sdk';
import { fetchPedigree, getCurrentUser } from 'familysearch-sdk/tree';

const sdk = createFamilySearchSDK({ accessToken: 'token' });

// Get current user
const user = await getCurrentUser(sdk);
console.log(user?.displayName);

// Fetch pedigree (will use current user's personId)
const pedigree = await fetchPedigree(sdk, undefined, {
  generations: 4,
  includeDetails: true,
  includeNotes: true
});

GEDCOM Conversion

Convert FamilySearch data to GEDCOM 5.5 format.

import { convertToGedcom } from 'familysearch-sdk/utils';

const gedcom = convertToGedcom(pedigreeData, {
  treeName: 'Family Tree',
  includeLinks: true,
  includeNotes: true
});

// Save to file
fs.writeFileSync('family.ged', gedcom);

Environment Configuration

The SDK supports three FamilySearch environments:

| Environment | Description | API Host | |-------------|-------------|----------| | production | Live production API | api.familysearch.org | | beta | Beta testing environment | apibeta.familysearch.org | | integration | Sandbox for development | api-integ.familysearch.org |

import { createFamilySearchSDK, ENVIRONMENT_CONFIGS } from 'familysearch-sdk';

// Create SDK for production
const sdk = createFamilySearchSDK({
  environment: 'production',
  accessToken: 'token'
});

// Access environment configuration
const config = ENVIRONMENT_CONFIGS['production'];
console.log(config.platformHost); // https://api.familysearch.org

Custom Logging

Provide a custom logger for debugging.

const sdk = createFamilySearchSDK({
  accessToken: 'token',
  logger: {
    log: (msg, ...args) => console.log(`[FS SDK] ${msg}`, ...args),
    warn: (msg, ...args) => console.warn(`[FS SDK] ${msg}`, ...args),
    error: (msg, ...args) => console.error(`[FS SDK] ${msg}`, ...args),
  }
});

API Reference

Core SDK

  • FamilySearchSDK - Main SDK class
  • createFamilySearchSDK(config) - Create a new SDK instance
  • initFamilySearchSDK(config) - Initialize/get singleton instance
  • getFamilySearchSDK() - Get singleton instance

Authentication (/auth)

  • generateOAuthState() - Generate CSRF state
  • buildAuthorizationUrl(config, state) - Build OAuth URL
  • exchangeCodeForToken(code, config) - Exchange code for tokens
  • refreshAccessToken(refreshToken, config) - Refresh access token
  • validateAccessToken(token, environment) - Validate token

Places (/places)

  • searchPlaces(sdk, query, options) - Search for places
  • getPlaceById(sdk, id) - Get place by ID
  • getPlaceChildren(sdk, id, options) - Get child places
  • getPlaceDetails(sdk, id) - Get detailed place info

Tree (/tree)

  • fetchPedigree(sdk, personId, options) - Fetch ancestry data
  • getCurrentUser(sdk) - Get current user info
  • getPersonWithDetails(sdk, personId) - Get person details
  • fetchMultiplePersons(sdk, personIds) - Batch fetch persons

Utils (/utils)

  • convertToGedcom(pedigreeData, options) - Convert to GEDCOM

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a pull request.