Search Compounds
pubchem_search_compoundsSearch PubChem compounds by identifier, formula, structure, similarity, or bioassay activity, and return CIDs with optional properties and paging.
Instructions
Search PubChem for chemical compounds by identifier (name, SMILES, or InChIKey, up to 25 per call), molecular formula in Hill notation, substructure or superstructure containment, 2D Tanimoto similarity, or the compounds a bioassay (AID) found active or tested. Returns a page of CIDs — reach matches past maxResults with offset. Optionally hydrate results with properties to avoid a follow-up pubchem_get_compound_details call.
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. | |
| 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 searches fetch only the requested page; 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 — hence the 10000 ceiling. Default: 0. | |
| formula | No | Required for formula search. Molecular formula in Hill notation (e.g. "C6H12O6", "CaH2O2"). | |
| 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. 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/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. 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. | |
| 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, ["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", 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), when the offset runs past the matches observed, when identifiers had no match or could not be interpreted, when identifiers collided on one CID, or when further pages remain. Absent when this page is complete and every identifier resolved to its own CID. | |
| 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. | |
| searchType | No | Search strategy used: identifier, formula, substructure, superstructure, similarity, or assay. | |
| 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, so 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; page further with offset to observe more. | |
| 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. |