ChemPal Documentation - v0.0.0
    Preparing search index...

    Class Pubchem

    A utility class for interacting with the PubChem API to retrieve chemical compound information.

    This class provides methods to search for compounds, retrieve their CID (Compound ID), and query detailed molecular properties using PubChem's SDQ (Structure Data Query) agent.

    const pubchem = new Pubchem("2-Acetoxybenzenecarboxylic acid");
    console.log("Result:", await pubchem.getSimpleName());
    // Result: Aspirin
    Index

    Constructors

    • Creates a new Pubchem instance for querying compound information

      Parameters

      • query: string

        The chemical compound name or identifier to search for

      Returns Pubchem

    Methods

    • Retrieves the first matching compound name from PubChem's autocomplete API

      Returns Promise<undefined | string>

      Promise resolving to the first matching compound name

      const compound = await pubchem.getCompound();
      console.log(compound); // "aspirin"
    • Retrieves the CID (Compound ID) for the compound by first getting the compound name and then looking up its CID

      Returns Promise<undefined | number>

      Promise resolving to the Compound ID (CID)

      const cid = await pubchem.getCID();
      console.log(cid); // 2244
    • Queries PubChem's SDQ (Structure Data Query) agent to retrieve detailed molecular properties

      Parameters

      Returns Promise<undefined | SDQResponse>

      Promise resolving to the SDQ response containing detailed compound data

      const sdqData = await pubchem.querySdqAgent();
      console.log(sdqData.SDQOutputSet[0].rows[0].mw); // Molecular weight
    • Retrieves the simple compound name from the SDQ agent query results

      Returns Promise<undefined | string>

      Promise resolving to the compound name

      const name = await pubchem.getSimpleName();
      console.log(name); // "2-acetyloxybenzoic acid"
    • Retrieves the compound name from the SDQ agent query results

      Parameters

      • cmpdsynonym: string

      Returns Promise<undefined | string>

      Promise resolving to the compound name

      const name = await pubchem.getCompoundNameFromAlias("aspirin");
      

    Properties

    baseURL: "https://pubchem.ncbi.nlm.nih.gov"

    Base URL for PubChem API endpoints

    query: string

    The chemical compound name or identifier to search for