Skip to main content

PyCompTox

Python Version PyPI version License: MIT Tests Documentation Status Code style: black

A Python interface for the EPA CompTox Dashboard Chemical API.

Overview

PyCompTox provides a simple and intuitive Python interface to interact with the EPA's CompTox Dashboard Chemical, Bioactivity, Exposure, and Hazard API. This package allows you to search for chemicals by name, identifiers (DTXSID, DTXCID, CAS numbers), molecular formulas, mass ranges, and much more.

from pycomptox import Chemical

client = Chemical()
results = client.search_by_exact_value("Bisphenol A")
print(results[0]["dtxsid"])   # DTXSID7020182

Upgrading to 0.7.0? This release fixes 16 methods that could not work at all, and contains breaking changes: caching is now opt-in rather than on by default, CCCData is renamed CCDData, several methods were renamed for consistency, and API failures now raise pycomptox.exceptions types instead of ValueError, and the minimum Python is now 3.12. See the changelog for the full rename table.

Installation

Quick Install

pip install comptox-python

install the latest released version.
Note: do not install the package by pip install pycomptox which is a different package with the old comptox API.

For the latest development version:

# Clone the repository
git clone https://github.com/USEtox/PyCompTox.git
cd PyCompTox

# Install the package
pip install -e .

# Or with development tools
pip install -e ".[dev]"

# Or with docs tools
pip install -e ".[docs]"

PyCompTox now uses modern Python packaging with pyproject.toml. See INSTALLATION.md for detailed installation options.

Optional Dependencies

  • dev: Testing and typing helpers (pytest, pytest-cov, pytest-mock, types-requests)
  • docs: Documentation build tools (mkdocs, mkdocs-material, mkdocstrings)
pip install -e ".[dev]"

API Key Setup

To use the CompTox Dashboard API, you need an API key. You can obtain one from the CompTox Dashboard API documentation.

Save your API key once and it will be automatically loaded for all future sessions:

pycomptox-setup set YOUR_API_KEY

The API key is stored securely in your user's application data directory:

  • Windows: %APPDATA%\PyCompTox\api_key.txt
  • macOS/Linux: ~/.pycomptox/api_key.txt

Manage Your API Key

# Test if your API key works
pycomptox-setup test

# Show your saved API key (masked)
pycomptox-setup show

# Delete your saved API key
pycomptox-setup delete

Alternative Methods

You can also provide the API key in other ways:

  1. Environment Variable: Set COMPTOX_API_KEY environment variable
  2. Direct Parameter: Pass api_key parameter when creating the client

API Key Storage

Your API key is stored securely in your user's application data directory:

  • Windows: C:\Users\<username>\AppData\Roaming\PyCompTox\api_key.txt
  • macOS/Linux: ~/.pycomptox/api_key.txt

The file is created with user-only read permissions on Unix-like systems.

API Documentation

For detailed API documentation, visit:
Chemical, Bioactivity, Exposure, and Hazard.

License

See the LICENSE file for details.

Disclaimer

This package is not officially affiliated with or endorsed by the U.S. Environmental Protection Agency (EPA). It is an independent implementation of a Python client for the publicly available CompTox Dashboard API.
You can find the official Python client from the official USEPA GitHub page.

Also, note that there is another package called pycomptox that is registered on PyPi nder the same name, which is why this package is installed by pip install comptox-python.

Metadata

Release files for comptox-python 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for comptox-python 0.7.0
File Size Uploaded Provenance Actions
comptox_python-0.7.0.tar.gz 276.5 kB Without provenance Details for comptox_python-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for comptox-python 0.7.0
File Interpreter ABI Platform Actions
comptox_python-0.7.0-py3-none-any.whl Python 3 none any Details for comptox_python-0.7.0-py3-none-any.whl

Total release size: 403.7 kB

Release files / comptox_python-0.7.0.tar.gz

Download URL comptox_python-0.7.0.tar.gz
Size 276.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9e836da82078cdc0fc70ac219e73455b97634f4e68e56301ce80823ae3432e1d
BLAKE2b-256 checksum
How to use checksums
ef662e4c58af3a8059e295aea021c82e5548b1ca17b43c39014505bce5332227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / comptox_python-0.7.0-py3-none-any.whl

Download URL comptox_python-0.7.0-py3-none-any.whl
Size 127.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ecfc3259939b7c236dfc990083dcaed2fe8b02659a7c195aaa3889da7db9c027
BLAKE2b-256 checksum
How to use checksums
8243d82ff8ebc33de07b25cf22137bb6602b3c00130cf89ad9dba6a17d7bfacf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for comptox-python 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files No provenance

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