NIH API: Get chemical facts by name or CAS number
Looks up a chemical on PubChem by common name or CAS number and returns its formula, molecular weight, names, description, SMILES, InChIKey and 2D structure image link.
Unofficial. Not affiliated with or endorsed by NIH.
Inputs
Values from the run on Oct 23, 2026, shown under Output.
- Chemical, required
chemical Common chemical name or CAS number, for example caffeine or 58-08-2.
caffeine
Input as JSON
{ "chemical": "caffeine"}Output
{ "name": "Caffeine", "smiles": "CN1C=NC2=C1C(=O)N(C(=O)N2C)C", "inchikey": "RYYVLZVUVIJVGH-UHFFFAOYSA-N", "cas_number": "58-08-2", "iupac_name": "1,3,7-trimethylpurine-2,6-dione", "description": "Caffeine is a trimethylxanthine in which the three methyl groups are located at positions 1, 3, and 7.", "pubchem_cid": 2519, "pubchem_url": "https://pubchem.ncbi.nlm.nih.gov/compound/2519" , "common_synonyms": [ "Guaranine", "1,3,7-Trimethylxanthine", "Methyltheobromine" ], "molecular_formula": "C8H10N4O2", "structure_image_url": "https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/2519/PNG?record_type=2d" , "molecular_weight_g_per_mol": 194.19}Code
curl https://api.fous.com/v1/runs \ -H "Authorization: Bearer $FOUS_API_KEY" \ -H "Content-Type: application/json" \ -d '{"method":"pubchem.ncbi.nlm.nih.gov/get_chemical","input":{"chemical":"caffeine"}}' # Save as fous.py, then run: python3 fous.pyimport json, os, timefrom urllib.error import HTTPErrorfrom urllib.request import Request, urlopenAPI = "https://api.fous.com/v1/runs" KEY = os.environ["FOUS_API_KEY"]HEADERS = { "Authorization": f"Bearer {KEY}", "Content-Type": "application/json" ,}def call(url, body=None): data = json.dumps(body).encode() if body else None request = Request(url, data, HEADERS) try: with urlopen(request, timeout=120) as r: return r.status, json.load(r) except HTTPError as error: message = json.load(error)["error"]["message"] raise RuntimeError(message) from errorstatus, run = call(API, { "method": "pubchem.ncbi.nlm.nih.gov/get_chemical" , "input": { "chemical": "caffeine" }})# 202: still going after 30 s. Ask again until it ends.while status == 202: time.sleep(2) status, run = call(f"{API}/{run['id']}")print(json.dumps(run["data"], indent=2))// Save as fous.mjs, then run: node fous.mjsconst api = "https://api.fous.com/v1/runs" ;const headers = { Authorization: `Bearer ${process.env.FOUS_API_KEY}`, "Content-Type": "application/json" ,};let response = await fetch(api, { method: "POST", headers, body: JSON.stringify({ "method": "pubchem.ncbi.nlm.nih.gov/get_chemical" , "input": { "chemical": "caffeine" } }), signal: AbortSignal.timeout(120_000),});let run = await response.json();// 202: still going after 30 s. Ask again until it ends.while (response.status === 202) { await new Promise((done) => setTimeout(done, 2_000)); response = await fetch(`${api}/${run.id}`, { headers }); run = await response.json();}if (!response.ok) throw new Error(run.error.message);console.log(run.data);# Connect your agent to Fous once, over MCP (Streamable HTTP):# https://api.fous.com/mcp# Set FOUS_API_KEY first: create a key at https://app.fous.com/keys.# Claude Codeclaude mcp add \ --scope user \ --transport http fous https://api.fous.com/mcp \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Codexcodex mcp add fous \ --url https://api.fous.com/mcp \ --bearer-token-env-var FOUS_API_KEY# Cursor, VS Code, Windsurf, Cline and morenpx -y add-mcp https://api.fous.com/mcp -g -n fous \ --header "Authorization: Bearer ${FOUS_API_KEY:?Set FOUS_API_KEY to your Fous API key}"# Then ask your agent:# "Use Fous to run pubchem.ncbi.nlm.nih.gov/get_chemical# with {"chemical":"caffeine"}"Over HTTP, the answer’s data holds the output. A run still going after 30 seconds answers 202 with its id: ask GET /v1/runs/{id} until it ends.
Schema
Input schema
{ "type": "object", "required": [ "chemical" ], "properties": { "chemical": { "type": "string", "minLength": 1, "description": "Common chemical name or CAS number, for example caffeine or 58-08-2." } }}Output schema
{ "type": "object", "required": [ "name", "molecular_formula", "molecular_weight_g_per_mol", "iupac_name", "cas_number", "common_synonyms", "description", "structure_image_url", "pubchem_url", "pubchem_cid", "smiles", "inchikey" ], "properties": { "name": { "type": "string", "description": "Compound name." }, "smiles": { "type": [ "string", "null" ], "description": "SMILES molecular structure.", "x-fous-developer": true }, "inchikey": { "type": [ "string", "null" ], "description": "InChIKey structure identifier.", "x-fous-developer": true }, "cas_number": { "type": [ "string", "null" ], "description": "CAS registry number if listed among PubChem synonyms." }, "iupac_name": { "type": [ "string", "null" ], "description": "IUPAC chemical name." }, "description": { "type": [ "string", "null" ], "description": "Brief plain-text description." }, "pubchem_cid": { "type": "integer", "description": "PubChem compound ID.", "x-fous-developer": true }, "pubchem_url": { "type": "string", "description": "PubChem compound page." }, "common_synonyms": { "type": "array", "items": { "type": "string" }, "description": "Up to ten other names for the chemical." }, "molecular_formula": { "type": [ "string", "null" ], "description": "Molecular formula." }, "structure_image_url": { "type": "string", "description": "2D chemical structure PNG link." }, "molecular_weight_g_per_mol": { "type": [ "number", "null" ], "description": "Molecular weight in grams per mole." } }}- Price
- 1 credit per completed run (1¢ with pay as you go); failed runs are free.
- Method
pubchem.ncbi.nlm.nih.gov/get_chemical- Returns
- name, molecular formula and weight, IUPAC name, CAS number, synonyms, description, structure image URL, PubChem URL, CID, SMILES, InChIKey
Use it from your agent
Give your agent this line. It reads SKILL.md, gets a Fous API key and connects the Fous MCP server. Its run then takes the method pubchem.ncbi.nlm.nih.gov/get_chemical with the inputs above.
Ask your agent
- What is the molecular formula and molecular weight of caffeine?
- Look up CAS 50-78-2 and give me its SMILES and InChIKey.
- Can you find the IUPAC name and synonyms for aspirin on PubChem?
- I need the structure image link and PubChem CID for nicotine, please.
- Which chemical has CAS number 64-17-5, and what is its description on nih.gov?
See more
All NIH methodsLooks up a chemical on PubChem by name or CAS number and returns its GHS hazard labels, route-specific first aid, flash point and workplace exposure limits.
pubchem.ncbi.nlm.nih.gov/get_chemical_safetyFinds PubMed medical and life-science articles by topic, with publication details and free full-text links when PubMed confirms them.
pubmed.ncbi.nlm.nih.gov/search_articlesGets the full PubMed abstract and publication details for one article by title, PubMed link, or PubMed number (PMID). A title is searched in PubMed titles first and must closely match a found article. Some articles have no abstract or free full text.
pubmed.ncbi.nlm.nih.gov/get_articleFinds NIH research grants by topic, organisation, or researcher name. Searches the last five fiscal years by default.
reporter.nih.gov/search_grantsFinds ICD-10-CM diagnosis codes and official names from a plain-language condition description, retrying with simplified wording when the first search finds nothing.
clinicaltables.nlm.nih.gov/search_diagnosis_codesExplains an ICD-10-CM diagnosis code with its official name, category, chapter, and whether it is billable, using the NLM Clinical Tables diagnosis table.
clinicaltables.nlm.nih.gov/explain_diagnosis_codeFinds possible pill matches on the Drugs.com pill identifier by imprint, optionally narrowed by color and shape, with each pill's labeler.
drugs.com/identify_pillLooks up a medicine by brand or generic name on Drugs.com and returns a plain-language overview: class, uses, availability, schedule, dosage forms, side effects, and pregnancy and breastfeeding notes.
drugs.com/get_drug