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

@biocomputingup/api-clients

v0.0.3

Published

A collection of API Clients for various biological resources mainly started for verifying Xrefs

Readme

@biocomputingup/api-clients

A robust TypeScript library providing schema-validated API clients for querying and verifying biological resource cross-references (Xrefs).

This library contains dedicated clients for three major biological and chemical databases:

  1. Cellosaurus — Cell line database client.
  2. ChEBI (Chemical Entities of Biological Interest) — Chemical structures and annotation database client.
  3. PubChem — Chemical substances and compounds database client.

All responses are validated at runtime using Zod schemas to ensure high type-safety and reliability.


Installation

Install the package and its peer dependency zod using your preferred package manager:

npm install @biocomputingup/api-clients zod
# or
yarn add @biocomputingup/api-clients zod
# or
pnpm add @biocomputingup/api-clients zod

Import Options

The library is built to support both CommonJS and ESM. You can import all clients from the main entrypoint or import specific clients separately via subpath exports to minimize bundle sizes.

Standard Import

import { 
  CellosaurusClient, 
  ChebiClient, 
  PubChemClient,
  EntryNotFoundException,
  UnknownHttpException
} from "@biocomputingup/api-clients";

Subpath Imports

// Import only the Cellosaurus client
import { CellosaurusClient } from "@biocomputingup/api-clients/clients/cellosaurus";

// Import only the ChEBI client
import { ChebiClient } from "@biocomputingup/api-clients/clients/chebi";

// Import only the PubChem client
import { PubChemClient } from "@biocomputingup/api-clients/clients/pubchem";

Clients Guide

1. Cellosaurus Client

The CellosaurusClient allows you to fetch detailed records from the Cellosaurus database.

Configuration Options

interface CellusaurusClientOptions {
  baseAPIUrl: string; // Defaults to "https://api.cellosaurus.org"
}

API Methods

  • getCellosaurusEntry(id: string): Promise<CellosaurusResponseType>
    Fetches the full entry details for a cell line by its accession ID (e.g., CVCL_0030).
  • getCellosaurusEntryName(id: string): Promise<string | null>
    A helper method that fetches the entry and retrieves the longest synonym name associated with the cell line. Returns null if not found or on failure.

Example Usage

import { CellosaurusClient, EntryNotFoundException } from "@biocomputingup/api-clients";

const client = new CellosaurusClient();

try {
  // Fetch full HeLa cell line data
  const entry: CellosaurusResponseType = await client.getCellosaurusEntry("CVCL_0030");
  console.log("Cell line list:", entry.Cellosaurus["cell-line-list"]);

  // Get the longest synonym name
  const name = await client.getCellosaurusEntryName("CVCL_0030");
  console.log("Cell line name:", name); // "Henrietta Lacks cells"
} catch (error) {
  if (error instanceof EntryNotFoundException) {
    console.error("Entry not found in Cellosaurus");
  } else {
    console.error("An unexpected error occurred:", error);
  }
}

2. ChEBI Client

The ChebiClient queries chemical entities of biological interest from the EBI ChEBI database backend.

Configuration Options

interface ChEBIClientOptions {
  baseUrl: string; // E.g., "https://www.ebi.ac.uk/chebi/backend/api/"
}

API Methods

  • getCompound(chebiId: string): Promise<CompoundType>
    Fetches details of a compound by its ChEBI ID (e.g., CHEBI:27732).

Example Usage

import { ChebiClient } from "@biocomputingup/api-clients";

const client = new ChebiClient({
  baseUrl: "https://www.ebi.ac.uk/chebi/backend/api/",
}, console); // Optional second argument: Logger interface (defaults to console)

try {
  const compound = await client.getCompound("CHEBI:27732");
  console.log("Compound Name:", compound.name); // "caffeine"
  console.log("Definition:", compound.definition);
  console.log("Star Rating:", compound.stars);
} catch (error) {
  console.error("Failed to query ChEBI:", error);
}

3. PubChem Client

The PubChemClient interacts with the PubChem PUG REST API.

Configuration Options

interface PubChemClientOptions {
  baseAPIUrl: string; // Defaults to "https://pubchem.ncbi.nlm.nih.gov/rest/pug"
}

API Methods

  • getCompound(id: string, props?: PubChemCompoundKey[]): Promise<PubChemCompoundType>
    Fetches specified properties for a compound by its CID (e.g., 2244).
    • props defaults to ["Title", "SMILES", "InChI", "InChIKey"].
    • Note: In the current version, this method returns the compound properties matching index 1 in the API response table.
  • getSubstance(id: string): Promise<void>
    Queries substance data by SID (e.g., 528403372) and writes the raw response to /tmp/pubchem-sid.json.

Example Usage

import { PubChemClient } from "@biocomputingup/api-clients";

const client = new PubChemClient();

try {
  // Fetch properties for Aspirin (CID: 2244)
  const compound = await client.getCompound("2244");
  console.log("CID:", compound.CID);
  console.log("Title:", compound.Title); // "Aspirin"
  console.log("SMILES:", compound.SMILES);
} catch (error) {
  console.error("Error querying PubChem:", error);
}

Error Handling

Standard exceptions are thrown across all clients to simplify error handling logic.

EntryNotFoundException

Thrown when the requested identifier is not found on the remote database (equivalent to an HTTP 404).

  • Properties:
    • message: Description containing client name, identifier, and operation.

UnknownHttpException

Thrown when a non-ok HTTP status (other than 404) is returned.

  • Properties:
    • message: Status code, URL requested, and response body payload.
import { EntryNotFoundException, UnknownHttpException } from "@biocomputingup/api-clients";

// In your catch blocks:
if (error instanceof EntryNotFoundException) {
  // Handle 404 cases
} else if (error instanceof UnknownHttpException) {
  // Handle other API issues
}

Development & Building

The project uses vite-plus for linting, testing, formatting, and packing.

1. Install Dependencies

vp install

2. Run Unit Tests

vp test

3. Build & Pack Library

Compile and pack the library into ESM/CJS bundles under the dist/ directory:

vp pack

4. Code Quality

Run checks to verify formatting, types, and lints:

vp check