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/dailymed

v0.1.1

Published

Typed client for the DailyMed REST API v2 — drug labels, SPL data, NDC codes, and drug classes

Readme

@ncbijs/dailymed

Runtime: Browser + Node.js

Typed client for the DailyMed REST API v2. Search drug names, look up Structured Product Labels (SPLs), query NDC codes, and list Established Pharmacologic Classes (EPCs) with automatic rate limiting and retry logic.

Installation

pnpm install @ncbijs/dailymed

Usage

import { DailyMed } from '@ncbijs/dailymed';

const dailymed = new DailyMed();

const names = await dailymed.drugNames('aspirin');
for (const entry of names.data) {
  console.log(`${entry.drugName} (${entry.nameType})`);
}

const spls = await dailymed.spls('metformin');
for (const spl of spls.data) {
  console.log(`${spl.setId}: ${spl.title}`);
}

const ndcs = await dailymed.ndcs('ibuprofen', { pageSize: 5 });
for (const ndc of ndcs.data) {
  console.log(ndc.ndc);
}

const classes = await dailymed.drugClasses({ pageSize: 10 });
for (const drugClass of classes.data) {
  console.log(`${drugClass.code}: ${drugClass.name}`);
}

API

new DailyMed(config?)

| Option | Default | Description | | ------------ | ------- | ----------------------------------- | | maxRetries | 3 | Number of retries on 429/5xx errors |

DailyMed is a fully public API with no API key required. Rate limit: 5 requests/second.

drugNames(drugName: string, options?: DailyMedPageOptions): Promise<DailyMedPage<DailyMedDrugName>>

Search drug names by keyword. Returns matching drug name entries with name type.

spls(drugName: string, options?: DailyMedPageOptions): Promise<DailyMedPage<DailyMedSpl>>

Search Structured Product Labels (SPLs) by drug name. Returns set IDs, titles, published dates, and SPL versions.

ndcs(drugName: string, options?: DailyMedPageOptions): Promise<DailyMedPage<DailyMedNdc>>

Search NDC (National Drug Code) codes by drug name.

drugClasses(options?: DailyMedPageOptions): Promise<DailyMedPage<DailyMedDrugClass>>

List all Established Pharmacologic Classes (EPCs) with codes and coding systems.

Pagination

All methods accept DailyMedPageOptions:

| Option | Type | Description | | ---------- | -------- | ----------------------- | | page | number | Page number (1-indexed) | | pageSize | number | Results per page |

All methods return DailyMedPage<T> with:

| Field | Type | Description | | ------------ | -------------------- | ------------------------ | | data | ReadonlyArray<T> | Results for this page | | pagination | DailyMedPagination | Total elements and pages |

Error handling

import { DailyMed, DailyMedHttpError } from '@ncbijs/dailymed';

try {
  await dailymed.drugNames('nonexistent-drug-xyz');
} catch (err) {
  if (err instanceof DailyMedHttpError) {
    console.error(`HTTP ${err.status}: ${err.body}`);
  }
}

The client automatically retries on HTTP 429, 500, 502, 503 and network errors with exponential backoff + jitter. DailyMed is rate-limited to 5 requests/second.

Response types

DailyMedDrugName

interface DailyMedDrugName {
  drugName: string;
  nameType: string;
}

DailyMedSpl

interface DailyMedSpl {
  setId: string;
  title: string;
  publishedDate: string;
  splVersion: number;
}

DailyMedNdc

interface DailyMedNdc {
  ndc: string;
}

DailyMedDrugClass

interface DailyMedDrugClass {
  code: string;
  codingSystem: string;
  classType: string;
  name: string;
}

DailyMedPagination

interface DailyMedPagination {
  totalElements: number;
  totalPages: number;
  currentPage: number;
  elementsPerPage: number;
}