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 🙏

© 2024 – Pkg Stats / Ryan Hefner

wikitree-js

v0.4.0

Published

Javascript library for the WikiTree API

Downloads

102

Readme

npm Node.js CI

wikitree-js

JavaScript library to access the WikiTree API for Node.js and Web environments.

Setup

Add wikitree-js package to your project:

npm install wikitree-js

Import package:

import {getAncestors} from 'wikitree-js';

Usage

getPerson

API documentation

Example 1

Async/await:

const response = await getPerson('Skłodowska-2');

Promise:

const responsePromise = getPerson('Skłodowska-2')

responsePromise.then(response => {
  // ...
});

Live demo:

Example 2

Async/await:

const response = await getPerson(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
  }
);

Promise:

const responsePromise = getPerson(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
  }
);

responsePromise.then(response => {
  // ...
});

Live demo:

getAncestors

API documentation

Example 1

Async/await:

const response = await getAncestors('Skłodowska-2');

Promise:

const responsePromise = getAncestors('Skłodowska-2')

responsePromise.then(response => {
  // ...
});

Live demo:

Example 2

Async/await:

const response = await getAncestors(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
    depth: 2,
  }
);

Promise:

const responsePromise = getAncestors(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
    depth: 2,
  }
);

responsePromise.then(response => {
  // ...
});

Live demo:

getDescendants

API documentation

Example 1

Async/await:

const response = await getDescendants('Skłodowska-2');

Promise:

const responsePromise = getDescendants('Skłodowska-2')

responsePromise.then(response => {
  // ...
});

Live demo:

Example 2

Async/await:

const response = await getDescendants(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
    depth: 2,
  }
);

Promise:

const responsePromise = getDescendants(
  'Skłodowska-2',
  {
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth', 'Father', 'Mother'],
    depth: 1,
  }
);

responsePromise.then(response => {
  // ...
});

Live demo:

getRelatives

API documentation

Example

Async/await:

const response = await getRelatives(
  ['Skłodowska-2'],
  {
    getChildren: true,
    getParents: true,
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth'],
  }
);

Promise:

const responsePromise = getRelatives(
  ['Skłodowska-2'],
  {
    getChildren: true,
    getParents: true,
    fields: ['Id', 'Name', 'FirstName', 'LastNameAtBirth'],
  })

responsePromise.then(response => {
  // ...
});

Live demo:

login (Node.Js)

This login method works only in Node.Js. To log in in a Web application use

Example

const auth = await login('[email protected]', 'P@s$w0Rd');
const response = await getRelatives(['Private-123'], {}, { auth });

Live demo: Replit

login (Web)

API documentation

The Web login only works for apps hosted on https://apps.wikitree.com/. See WikiTree Apps page for details on how to host your app there.

The login flow works as follows:

  1. Redirect the user to the WikiTree login page giving it a URL to redirect back:
navigateToLoginPage('https://apps.wikitree.com/my-app');
  1. Once the user logs in, they will be redirected back to your app with an authcode URL parameter, e.g.
https://apps.wikitree.com/my-app?authcode=abc123abc
  1. The app needs to take this authcode and call clientLogin with it.
clientLogin(authcode);
  1. All subsequent requests to WikiTree will be authenticated.

Use getLoggedInUserName() to get the currently logged in user's profile name.