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.4.tar.gz (12.6 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.4-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pubchem_property_fetcher-0.1.4.tar.gz
  • Upload date:
  • Size: 12.6 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.4.tar.gz
Algorithm Hash digest
SHA256 fbbd167dce11b59f00c55bb59a6238013179f913be740db6cd2d853e7188f96a
MD5 585fad13f45b595d69f39c87dd172736
BLAKE2b-256 e0e9e6555a1c4c137df0a411911da116e8d0b4acd96d236dd30eb9930200067e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pubchem_property_fetcher-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ccef17c9597a73fb3682ed33c77d79c6877dd51100f8cff33062a88e53f3681c
MD5 4251e7cdcb622114259e2c3a3b3b1b78
BLAKE2b-256 3bdbbc64c1781a2032de5c91079d84777180a3aa602534ec09997db84d6b39cf

See more details on using hashes here.

Provenance

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

This release

0.1.4 This release

2 files

0.1.3

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