PyCompTox
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,
CCCDatais renamedCCDData, several methods were renamed for consistency, and API failures now raisepycomptox.exceptionstypes instead ofValueError, 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 which is a different package with the old comptox API.pip install pycomptox
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 (Recommended)
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:
- Environment Variable: Set
COMPTOX_API_KEYenvironment variable - Direct Parameter: Pass
api_keyparameter 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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comptox_python-0.7.0.tar.gz.
File metadata
- Download URL: comptox_python-0.7.0.tar.gz
- Upload date:
- Size: 276.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e836da82078cdc0fc70ac219e73455b97634f4e68e56301ce80823ae3432e1d
|
|
| MD5 |
2131938121af85473dd76d747373e669
|
|
| BLAKE2b-256 |
ef662e4c58af3a8059e295aea021c82e5548b1ca17b43c39014505bce5332227
|
File details
Details for the file comptox_python-0.7.0-py3-none-any.whl.
File metadata
- Download URL: comptox_python-0.7.0-py3-none-any.whl
- Upload date:
- Size: 127.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ecfc3259939b7c236dfc990083dcaed2fe8b02659a7c195aaa3889da7db9c027
|
|
| MD5 |
92b446379252f82a409b2c31a9ea2e04
|
|
| BLAKE2b-256 |
8243d82ff8ebc33de07b25cf22137bb6602b3c00130cf89ad9dba6a17d7bfacf
|