CAS Common Chemistry
Query chemical compound data from the CAS Common Chemistry API.
Setup
Set API key as environment variable:
bash
# Linux/Mac
export CAS_API_KEY="your_api_key_here"
# Windows (PowerShell)
[Environment]::SetEnvironmentVariable('CAS_API_KEY', 'your_api_key', 'User')
Requires requests library:
bash
pip install requests
Quick Start
Get Complete Data (Recommended)
Fetch all available data and auto-export JSON + SVG + TXT:
bash
python scripts/cas_api.py full 100-42-5 --output-dir ./output
Search by Name
bash
python scripts/cas_api.py search "styrene"
Get Details Only
bash
python scripts/cas_api.py detail 100-42-5 python scripts/cas_api.py detail 100-42-5 --json
Available Data Fields
| Field | Description |
|---|---|
| rn | CAS Registry Number |
| uri | Unique resource identifier |
| name | Official chemical name |
| molecularFormula | Molecular formula |
| molecularMass | Molecular mass |
| smile | SMILES notation |
| canonicalSmile | Canonical SMILES |
| inchi | InChI identifier |
| inchiKey | InChI key |
| hasMolfile | Whether MOL file exists |
| experimentalProperties | Boiling point, melting point, density, etc. |
| propertyCitations | Data source citations |
| synonyms | All alternative names |
| replacedRns | Replaced/deleted CAS RNs |
| images | SVG structure images |
Commands
full - Complete Data Export
Get all data and automatically export files:
bash
python scripts/cas_api.py full <CAS_RN> --output-dir <DIR>
Outputs:
- •
<CAS_RN>.json- Complete JSON data - •
<CAS_RN>.svg- Structure image - •
<CAS_RN>.txt- Formatted text summary
search - Find Compounds
bash
python scripts/cas_api.py search "benzene" python scripts/cas_api.py search "C6H6" --size 10 python scripts/cas_api.py search "71-43-2" --json
detail - Get Information
bash
python scripts/cas_api.py detail 100-42-5 python scripts/cas_api.py detail 100-42-5 --json
export - Export SVG Only
bash
python scripts/cas_api.py export 100-42-5 --output structure.svg
Batch Processing
Process multiple compounds from file:
bash
python scripts/batch_query.py --input compounds.txt --output results.json
Input file format (one per line):
code
styrene benzene 100-42-5
Limitations
CAS Common Chemistry API does not include:
- •Synthesis routes/reactions
- •Commercial suppliers
- •Literature references
- •Full CAS REGISTRY (165M+ substances)
For complete data, use CAS SciFinder API.
Resources
- •
scripts/cas_api.py- Main CLI tool - •
scripts/batch_query.py- Batch processing utility - •
references/api_reference.md- Complete API documentation