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

@ncbijs/id-converter

v0.1.1

Published

Batch article ID conversion between PMID, PMCID, DOI, and Manuscript ID

Downloads

108

Readme

Runtime: Browser + Node.js


Why

Researchers encounter articles through different identifiers — DOIs from citation managers, PMIDs from PubMed searches, PMCIDs from full-text repositories, Manuscript IDs from submission systems. Converting between them manually is tedious and error-prone, and the raw NCBI API returns a mix of JSON formats with inconsistent error handling.

@ncbijs/id-converter converts up to 200 IDs in a single request, normalizes the response into typed objects, and includes validation helpers to detect ID formats before making a network call.

  • Batch conversion — up to 200 IDs per request
  • Zero dependencies — pure TypeScript, works in browser and Node.js
  • Validation helpersisPMID, isPMCID, isDOI, isMID for format detection
  • Version history — optionally retrieve all PMCID versions for an article
  • Typed responses — every field is typed, no any or loose objects

Install

npm install @ncbijs/id-converter

Quick start

import { convert, isPMID, isDOI } from '@ncbijs/id-converter';

// Convert a mix of IDs
const results = await convert(['35266103', '10.1038/s41586-022-04569-1', 'PMC9012345']);

for (const result of results) {
  console.log(`PMID: ${result.pmid}, DOI: ${result.doi}, PMCID: ${result.pmcid}`);
}

// Validate before converting
const id = 'PMC9012345';
if (isPMID(id)) console.log('This is a PMID');
if (isDOI(id)) console.log('This is a DOI');

API

convert(ids, options?)

Batch convert article identifiers. Accepts any mix of PMIDs, PMCIDs, DOIs, and Manuscript IDs.

const results = await convert(['35266103', 'PMC9012345']);

| Parameter | Type | Required | Description | | --------- | ----------------------- | -------- | ------------------------ | | ids | ReadonlyArray<string> | Yes | Array of IDs (max 200). | | options | object | No | See options table below. |

Options

| Option | Type | Default | Description | | ---------- | --------- | ----------- | -------------------------------------------------------------- | | idtype | IdType | auto-detect | Hint the input type: 'pmid', 'pmcid', 'doi', or 'mid'. | | versions | boolean | false | Include PMCID version history in the response. | | showaiid | boolean | false | Include Archiving Institution article ID. | | tool | string | — | Your application name (recommended by NCBI). | | email | string | — | Contact email (recommended by NCBI). |

Returns Promise<ReadonlyArray<ConvertedId>>.

// With options
const results = await convert(['35266103'], {
  versions: true,
  tool: 'my-app',
  email: '[email protected]',
});

for (const result of results) {
  console.log(`PMID: ${result.pmid}, PMCID: ${result.pmcid}, DOI: ${result.doi}`);
  if (result.versions) {
    for (const version of result.versions) {
      console.log(`  ${version.pmcid} (current: ${version.current})`);
    }
  }
}

isPMID(value)

Check if a string matches the PMID format (positive integer).

isPMID('35266103'); // true
isPMID('PMC9012345'); // false

Returns boolean.

isPMCID(value)

Check if a string matches the PMCID format (PMC prefix followed by digits, optionally with a version suffix).

isPMCID('PMC9012345'); // true
isPMCID('PMC9012345.1'); // true
isPMCID('35266103'); // false

Returns boolean.

isDOI(value)

Check if a string matches the DOI format (10. prefix with registrant and suffix).

isDOI('10.1038/s41586-022-04569-1'); // true
isDOI('35266103'); // false

Returns boolean.

isMID(value)

Check if a string matches the Manuscript ID format (NIHMS prefix followed by digits).

isMID('NIHMS123456'); // true
isMID('35266103'); // false

Returns boolean.

Storage mode

Convert article IDs from locally stored data with the same return types — no network, no rate limits.

import { createConverter } from '@ncbijs/id-converter';
import { DuckDbFileStorage } from '@ncbijs/store';

const storage = await DuckDbFileStorage.open('./ncbijs.duckdb');
const convertIds = createConverter(storage);

const results = await convertIds(['35296856']);
console.log(results[0].pmcid); // 'PMC...'

The createConverter() factory accepts any object implementing the DataStorage interface (getRecord + searchRecords). ReadableStorage from @ncbijs/store satisfies this interface.

Types

All types are exported for use in your own interfaces:

import type {
  ConvertedId,
  ConvertParams,
  IdType,
  OutputFormat,
  VersionedId,
} from '@ncbijs/id-converter';

ConvertedId

interface ConvertedId {
  readonly pmid: string | null;
  readonly pmcid: string | null;
  readonly doi: string | null;
  readonly mid: string | null;
  readonly live: boolean;
  readonly releaseDate: string;
  readonly versions?: ReadonlyArray<VersionedId>;
  readonly aiid?: string;
}

VersionedId

interface VersionedId {
  readonly pmcid: string;
  readonly current: boolean;
}

IdType

'pmid' | 'pmcid' | 'doi' | 'mid'

OutputFormat

'json' | 'xml' | 'csv' | 'html'