Skip to main content

pubchem-property-fetcher

A CLI tool and Python API to resolve chemical SMILES strings and batch-fetch properties using the PubChem PUG REST API.

It handles SMILES canonicalization via RDKit, groups properties to minimize API calls, respects PubChem's rate limits, and uses exponential backoff to handle server-side throttling (429, 503). Results are exported as CSV using Polars.

Installation

Ensure you have Python 3.10+ installed. Install the package including its dependencies:

pip install pubchem-property-fetcher

Usage

CLI

Run the script directly from the command line. Pass in SMILES strings, specify the properties, and set an output file. If no output is provided, it prints the CSV to standard output.

# Fetch MolecularWeight and IUPACName
python -m pubchem_property_fetcher "OCC.CC" "CCO" "CCC" \
    --properties MolecularWeight --properties IUPACName \
    --output results.csv

Special Properties:

  • --properties synonyms: Fetches common aliases for the structures. Limit the amount returned with --max-synonyms N.
  • --properties label: A custom pipeline property that heuristically picks the most human-readable name from the synonym list, falling back to the formal IUPAC name if no good synonyms exist.

For standard properties like MolecularWeight, XLogP, ExactMass, or TPSA, see the PubChem PUG REST Docs.

Python API

import asyncio
from typing import Any

from pubchem_property_fetcher import (
    PubChemClient,
    clean_smiles,
    fetch_cid_bulk,
    fetch_properties_bulk,
)


# fetch properties
async def main() -> dict[int, dict[str, Any]]:
    # standardize SMILES
    smiles = clean_smiles(["CCO", "CCC"])

    async with PubChemClient() as client:
        # get PubChem Compound IDs (CIDs)
        cids_map = await fetch_cid_bulk(smiles, client)
        cids = list(cids_map.values())
        return await fetch_properties_bulk(cids, ["IUPACName", "MolecularWeight"], client)


print(asyncio.run(main()))
# {702: {'IUPACName': 'ethanol', 'MolecularWeight': 46.07}, ...}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pubchem_property_fetcher-0.1.3.tar.gz (12.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pubchem_property_fetcher-0.1.3-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file pubchem_property_fetcher-0.1.3.tar.gz.

File metadata

  • Download URL: pubchem_property_fetcher-0.1.3.tar.gz
  • Upload date:
  • Size: 12.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pubchem_property_fetcher-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2fe936ecaf2ee1a1a9d9b5f107fa47bef6e602c6f576f692d46256b6ba02dee3
MD5 75e444ac0d4adffc9b253f429f01d3b1
BLAKE2b-256 0eb795030b35a199b6db152ad410b7a114f41a605479e7ddac774d3d4820d6af

See more details on using hashes here.

Provenance

The following attestation bundles were made for pubchem_property_fetcher-0.1.3.tar.gz:

Publisher: release.yml on audivir/pubchem-property-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pubchem_property_fetcher-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for pubchem_property_fetcher-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 62e5467d4903b6cfd6a92d28c793bdcd710e0fbde555473b8ea7df29c4996528
MD5 6fb3b5d32af51e93f93f765a936e4ec1
BLAKE2b-256 faea6ebd3b85c49192b794ccae4ab46611f1d979533e3c4b55106030f146e8ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for pubchem_property_fetcher-0.1.3-py3-none-any.whl:

Publisher: release.yml on audivir/pubchem-property-fetcher

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.1.4

2 files

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page