find_chemical_compound
Look up a chemical compound by name or molecular formula. Resolves names to formulas or formulas to names, returning matches from a bundled database and online sources.
Instructions
Look up a chemical compound by name or molecular formula.
Searches the bundled name<->formula database (a PubChem subset) first, then
the writable user cache, then -- unless disabled -- the online fallback
(PubChem, Wikidata, and, when an API key is set, EPA CompTox). A name
resolves to its molecular formula(e); a formula resolves to the compound
name(s) sharing it (isomers), ordered with the preferred name first. The
direction is chosen by by. Returns the query, how it was interpreted
(interpreted_as), the normalized Hill-system canonicalization of the
query whenever it parses as a formula (e.g. 'O6C6H12' -> 'C6H12O6'; null
when it is not a parseable formula), the matches (each
{"name", "formula"}, the preferred result first), and the resolving
source / license.
Raises ValueError if nothing matches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Compound to look up -- either a name or a molecular formula. Names match the canonical name or any alias, case-insensitively, ignoring trailing registry annotations like '(9CI)' or '(USAN)'. Formulae are canonicalized to the Hill system, so 'C6H12O6', 'O6C6H12', and 'C₆H₁₂O₆' are equivalent. Examples: 'aspirin', 'acetylsalicylic acid', 'H2O', 'C9H8O4'. | |
| by | No | How to read the query. 'auto' (default) treats a parseable formula as a formula and anything else as a name, falling back to the other direction on a miss. 'name' or 'formula' pin it. | auto |
| limit | No | Maximum number of compounds to return for a formula lookup. Isomers share a formula; results are ordered with the most notable (preferred) name first. |