PubChem API
Free NIH PubChem API with no key: 100M+ chemical compounds with formulas, molecular weight, structures, synonyms, safety and bioactivity data. Tested.
Endpoint tested and returned HTTP 200 on 2026-08-20
What is the PubChem API?
The PubChem PUG REST API is a free, key-free API from the US National Institutes of Health providing data on more than 100 million chemical compounds — molecular formula and weight, structures, synonyms, safety information and bioactivity.
PubChem is the world's largest open chemistry database, run by the NIH. You can look up compounds by name, CID, SMILES, InChI or molecular formula, and request exactly the properties you need in one request.
The property-selection syntax is what makes it efficient: `/property/MolecularFormula,MolecularWeight/JSON` returns just those fields rather than an enormous compound record. Requesting the full record when you need two numbers is the usual mistake.
Quick facts
- Base URL
https://pubchem.ncbi.nlm.nih.gov/rest/pug- Authentication
- No API key required.
- Rate limit
- 5 requests per second and 400 per minute per IP.
- Pricing
- Free public domain US government data.
- CORS
- Enabled — callable directly from browser JavaScript
- Official docs
- Read the docs
How to use the PubChem API
Every request below was executed against the live API on 2026-08-20, and the response shown is the real body it returned — not an illustration.
1. Look up compound properties by name
GET https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/aspirin/property/MolecularFormula,MolecularWeight/JSON
curl 'https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/aspirin/property/MolecularFormula,MolecularWeight/JSON'const res = await fetch("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/aspirin/property/MolecularFormula,MolecularWeight/JSON");
if (!res.ok) throw new Error(`Request failed: ${res.status}`);
const data = await res.json();
console.log(data);import requests
res = requests.get("https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/name/aspirin/property/MolecularFormula,MolecularWeight/JSON", timeout=20)
res.raise_for_status()
print(res.json()){
"PropertyTable": {
"Properties": [
{
"CID": 2244,
"MolecularFormula": "C9H8O4",
"MolecularWeight": "180.16"
}
]
}
}Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
compound/name/<name> | path | Optional | Look up by common or chemical name. compound/name/aspirin |
compound/cid/<cid> | path | Optional | Look up by PubChem Compound ID. compound/cid/2244 |
property/<list>/JSON | path | Optional | Comma-separated properties to return. property/MolecularFormula/JSON |
compound/smiles/<smiles> | path | Optional | Look up by SMILES string. compound/smiles/CCO |
Response fields
PropertyTable.Propertiesarray- One entry per matched compound.
...CIDinteger- PubChem Compound ID — the canonical identifier.
...MolecularFormulastring- Chemical formula, e.g. C9H8O4.
...MolecularWeightstring- Molecular weight, returned as a string.
...CanonicalSMILESstring- SMILES structure notation, when requested.
...IUPACNamestring- Systematic IUPAC name, when requested.
What you can build with the PubChem API
- Build a chemical compound lookup for education or research
- Convert between chemical names, formulas and structures
- Enrich a drug database with molecular properties
- Validate chemical identifiers in a laboratory system
Common errors and how to fix them
404 PUGREST.NotFound
The compound name is not recognised.
Fix: Try a systematic name, a synonym, or search by SMILES/InChI instead of a colloquial name.
503 PUGREST.ServerBusy
Rate limit exceeded.
Fix: Stay under 5 requests per second; PubChem enforces this strictly.
Huge responses
You requested the full compound record.
Fix: Use the /property/ path to select only the fields you need.
PubChem API — frequently asked questions
Is the PubChem API free?
Yes, completely free with no API key. It is public domain data published by the US National Institutes of Health.
How do I get just the molecular weight?
Use the property path: /compound/name/aspirin/property/MolecularWeight/JSON. Requesting the full compound record returns megabytes you do not need.
Can I search by chemical structure?
Yes, PubChem accepts SMILES and InChI identifiers as lookup keys, alongside names and CIDs.
What is the rate limit?
Five requests per second and 400 per minute per IP, enforced strictly with a 503 ServerBusy response.
Tools that pair with this API
JSON Formatter
Format, beautify and minify JSON online with 2-space, 4-space or tab indentation. Sort keys alphabetically and catch syntax errors instantly — free and private.
Unit Converter
Convert between units of length, weight, temperature, area, volume, speed, time and data storage instantly, with a swap button and common conversion tables.
PubChem is an independent third-party service and is not affiliated with ByteTools or ByteVancer. Details on this page were verified on 2026-08-20; always check the official documentation before relying on this API in production, as terms and limits can change.