Skip to content

Chemical API

Entry Point

ts
import { ChemicalTooltip } from 'bio-tooltips/mychem';

Methods

MethodDescription
ChemicalTooltip.init(config?)Initializes chemical tooltips and returns a cleanup function.
ChemicalTooltip.preload()Matches the shared tooltip module lifecycle shape.

Config Type

MyChemTooltipConfig combines the shared CoreTooltipConfig with MyChem-specific options.

OptionDefaultDescription
apimychemAdapter identifier.
selector.chemical-tooltipElements to attach chemical tooltips to.
truncateSummary4Summary line clamp.
synonymCount6Synonyms shown before overflow UI.
listCount5Items shown in grouped sections before overflow UI.
structureRendererundefinedOptional custom renderer for the structure figure. The default renderer uses PubChem PNG URLs.
display.identityexpandedName, badges, and match context.
display.structurePropertiesexpandedStructure image plus formula, mass, identity, SMILES, and InChIKey.
display.detailedPropertiestrueSecondary property table such as LogP, TPSA, H-bond counts, charge, and stereochemistry count.
display.summaryexpandedDescription text.
display.synonymsexpandedSynonym list.
display.classestrueChemical classes and categories.
display.pharmacologytrueMechanism, indications, targets, and bioactivity summaries.
display.regulatorytrueApproval status, products, and orphan designations.
display.safetytrueReported side effects and adverse event data.
display.identifierstrueExternal identifiers and links.
display.footertrueMyChem attribution and JSON link.
display.rawJsonfalseRaw MyChem record display.
display.sourcePathsfalseSource path labels for rendered fields.

Markup Attributes

AttributeDescription
data-queryOptional lookup value. Use this for stable IDs while keeping readable visible text.
data-scopeIdentifier or search field, such as pubchem, chembl, chebi, drugbank, unii, inchikey, or name.
data-lookupOptional lookup mode: id or best-guess. Non-name scopes default to id; name defaults to best-guess.

Optional RDKit SVG Rendering

RDKit rendering is not part of the default MyChem bundle. Install @rdkit/rdkit, import the optional entry point, and pass the renderer into ChemicalTooltip.init.

ts
import { ChemicalTooltip } from 'bio-tooltips/mychem';
import { createRDKitStructureRenderer } from 'bio-tooltips/mychem/rdkit';

const structureRenderer = await createRDKitStructureRenderer();

ChemicalTooltip.init({
  structureRenderer,
});

If RDKit cannot render a structure, the tooltip falls back to the default PubChem PNG renderer.

For exact exported types, see the generated MyChem reference pages for config, client, and types.