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.2.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.2-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pubchem_property_fetcher-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7851a2c89200f0e0e1eee6f94efee9f06043976ff0efc6fa379d688efad5b386
MD5 11bfb83eb7b9883a28a7c98595406d01
BLAKE2b-256 5ce1173f81f91b89df852475c8cd9edf271cf68bca02eeebd52476014d5ddcf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for pubchem_property_fetcher-0.1.2.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.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pubchem_property_fetcher-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d3efdb56a871ee8eba3507545faf0eae3028494cd997dc70cde1c38e09f7f2
MD5 454a004be5f612f31939eb6ece1b9e86
BLAKE2b-256 9f1cf24772a25d810f360604c3fcf22744a7f2acd08891b3234b55cbab8c86af

See more details on using hashes here.

Provenance

The following attestation bundles were made for pubchem_property_fetcher-0.1.2-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

0.1.3

2 files

This release

0.1.2 This release

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