Search Compounds
pubchem_search_compoundsSearch PubChem for chemical compounds by identifier (name, SMILES, InChI, or InChIKey, up to 25 per call), molecular formula in Hill notation, substructure or superstructure containment, 2D Tanimoto similarity, the compounds a bioassay (AID) found active or tested, or an accurate mass or molecular weight range. Returns a page of CIDs, each similarity hit with its Tanimoto score — reach matches past maxResults with offset. Optionally hydrate results with properties to avoid a follow-up pubchem_get_compound_details call.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"searchType": "<searchType>"
},
"name": "pubchem_search_compounds"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| aid | No | Required for assay search. PubChem Assay ID (AID) whose compounds to list, from 1 to 2147483647, e.g. 1000. Find AIDs for a biological target with pubchem_search_assays. For one listed compound's outcome and activity values in this assay, call pubchem_get_bioactivity with its cid and aid: [this AID]. | |
| query | No | Required for substructure/superstructure/similarity searches. A SMILES string (e.g. "CC(=O)O") or PubChem CID as a string from 1 to 2147483647 (e.g. "2244"). | |
| offset | No | Zero-based index of the first CID to return. Pass the nextOffset from a previous call to read the following page. Identifier lookups resolve every match up front, so paging them is free, and assay and mass searches fetch only the requested page, so all three page to the end of their matches; a mass search reaches the first 1000000, the most PubChem counts. Formula, substructure, superstructure, and similarity searches have to ask PubChem for offset + maxResults records to reach a page, so deep pages cost progressively more upstream: those four accept an offset up to 10000. Default: 0. | |
| formula | No | Required for formula search. Molecular formula in Hill notation (e.g. "C6H12O6", "CaH2O2"). | |
| massMax | No | Required for mass search. Upper bound of the mass window, inclusive, in daltons (g/mol for molecular_weight). E.g. 180.064. Search a measured mass with a window around it at the measurement's tolerance: PubChem compares the window with the value it stores for each compound, so a massMax equal to massMin matches only compounds whose stored value equals it to every stored decimal. PubChem counts at most 1000000 matches in a window and can time out on one hundreds of Da wide; narrow the window if either happens. | |
| massMin | No | Required for mass search. Lower bound of the mass window, inclusive, in daltons (g/mol for molecular_weight): 0 or more, and no greater than massMax. E.g. 180.063. | |
| massType | No | Required for mass search. The mass that massMin and massMax bound: "monoisotopic_mass" (from each element's most abundant isotope; the usual high-resolution MS target), "exact_mass" (the most likely isotopic composition, which gives the most intense peak; differs from monoisotopic_mass for compounds rich in Cl or Br and for molecules of about 90 or more carbons), or "molecular_weight" (isotope-averaged, in g/mol). | |
| queryType | No | Required for structure/similarity searches. Format of the query: "smiles" or "cid". | |
| threshold | No | Similarity search only. Minimum Tanimoto similarity (70-100). 90+ for close analogs, 70-80 for scaffold hops. Hits come in PubChem's order, not ranked by score, so raising threshold is how to narrow a page to closer analogs. 100 means a fingerprint identical to the query's, not an identical compound: isotopologues and some positional isomers match at 100. Default: 90. | |
| activeOnly | No | Assay search only. When true (default), lists only the compounds the assay marked active; false lists every compound it tested. | |
| maxResults | No | Maximum CIDs to return per page. The per-call cap is 200: a larger value (up to 1000) returns a page of 200 and is reported in cappedInputs. Use offset to reach matches past this page. Default: 20. | |
| properties | No | Optional: fetch these properties for each result, avoiding a follow-up details call. E.g. ["MolecularFormula", "MolecularWeight", "CanonicalSMILES"]. | |
| searchType | Yes | Search strategy; each mode needs its own fields. "identifier": name/SMILES/InChI/InChIKey lookup — requires identifierType and identifiers. "formula": molecular formula — requires formula. "substructure": find compounds containing the query as a substructure. "superstructure": find compounds that are themselves substructures of the query. "similarity": 2D Tanimoto similarity to the query, each hit with its score — hits come in PubChem's order, not ranked by score, so raise threshold to narrow to closer analogs. substructure, superstructure, and similarity require query and queryType. "assay": compounds tested in a PubChem bioassay — requires aid; activeOnly (default true) keeps only the compounds the assay marked active. "mass": compounds whose monoisotopic mass, exact mass, or molecular weight lies in an inclusive range — requires massType, massMin, and massMax; matches come in PubChem's order, not ranked by closeness to a target mass. | |
| identifiers | No | Required for identifier search. Array of identifiers to resolve. The per-call cap is 25: the first 25 are looked up, and any past that (up to 1000 in all) are returned in unprocessed, in input order, and reported in cappedInputs. Examples: ["aspirin", "ibuprofen"] for name, ["CC(=O)OC1=CC=CC=C1C(=O)O"] for SMILES, ["InChI=1S/C9H8O4/c1-6(10)13-8-5-3-2-4-7(8)9(11)12/h2-5H,1H3,(H,11,12)"] for inchi (sent exactly as written, case kept), ["BSYNRYMUTXBXSQ-UHFFFAOYSA-N"] for inchikey (27-char block format; uppercased before lookup, any case accepted). | |
| identifierType | No | Required for identifier search. Type of chemical identifier: "name", "smiles", "inchi" (a full InChI string, case-sensitive), or "inchikey". | |
| allowOtherElements | No | Formula search only. When true, includes compounds with additional elements beyond the formula. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cap | No | The page size applied: maxResults, or the per-call cap when maxResults exceeds it. | |
| error | No | Present when the call failed. Absent on success. | |
| shown | No | CIDs returned on this page. | |
| notice | No | Recovery guidance when no compounds matched (for an assay search, when the assay recorded none of the requested kind; for a mass search, naming the mass type and window; for a substructure, superstructure, or similarity search on a query CID, saying when PubChem marks that CID non-live and naming the CID it prefers in its place), when the offset runs past the matches observed, when identifiers had no match or could not be interpreted, when identifiers collided on one CID, when PubChem did not return the live status or preferred CID of an identifier-mode row, when further pages remain, when a bounded search reached the offset ceiling, when a mass search reached the most matches PubChem counts, or when a similarity page carries no scores, saying why. Absent when this page is complete, every identifier resolved to its own CID with its status read, and a similarity page carries its scores. | |
| offset | No | Zero-based index of the first CID returned. | |
| results | No | Matching compounds. | |
| truncated | No | True when matching CIDs remain past this page. | |
| activeOnly | No | Assay search only: true when the list holds only the compounds the assay marked active, false when it holds every compound tested. | |
| nextOffset | No | Offset to pass on the next call to continue past this page. Omitted when no further matches remain; when a formula, substructure, superstructure, or similarity page would continue past the 10000 offset ceiling (truncated stays true, and the notice says how to narrow the search and names the page at offset 10000 when it still reaches further matches); and when a mass search page reaches the last of the 1000000 matches PubChem counts (truncated stays true, and the notice says how to narrow the window). | |
| searchType | No | Search strategy used: identifier, formula, substructure, superstructure, similarity, assay, or mass. | |
| totalFound | No | Exact number of matching CIDs across all pages. Omitted when a formula, substructure, superstructure, or similarity search saturated the records it requested — PubChem returns no match count for those — and when a mass search reached the 1000000 matches PubChem counts at most; totalFoundAtLeast reports a floor instead. | |
| unprocessed | No | Identifier-mode only: identifiers past the per-call cap of 25, in input order, not looked up. Pass them in a follow-up call. Omitted when every identifier was looked up. | |
| cappedInputs | No | Inputs that asked for more than their per-call cap, with the value requested and the value served. An ID batch lists the IDs past the cap in unprocessed. Omitted when every input was within its cap. | |
| totalFoundAtLeast | No | Lower bound on matching CIDs, reported in place of totalFound when the exact count is unavailable. At least this many match, and the true total may be higher. A formula or structure search shows more by paging further with offset; a mass search pages only this many, and a narrower window reaches the rest. | |
| unresolvedIdentifiers | No | Identifier-mode only: input identifiers that resolved to no CID — PubChem had no match, or could not interpret the input as identifierType (the notice says which). Omitted when every identifier resolved and for non-identifier searches. |