API Client
The EpiSuiteAPIClient
class provides the core interface for interacting with the EPISuite API.
Overview
pyepisuite.api_client.EpiSuiteAPIClient
Source code in src/pyepisuite/api_client.py
search(query_term, time_out=10)
Search the EPISuite API with a query term (SMILES, CAS, or chemical name).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_term
|
str
|
The term to search for. |
required |
time_out
|
int
|
The time out for the request. |
10
|
Returns:
Type | Description |
---|---|
List[Chemical]: A list of Chemical instances. |
Source code in src/pyepisuite/api_client.py
submit(cas='', smiles='')
Submit a CAS number or SMILES string to the EPISuite API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cas
|
str
|
The CAS number of the chemical. |
''
|
smiles
|
str
|
The SMILES string of the chemical. |
''
|
Returns:
Name | Type | Description |
---|---|---|
dict |
The JSON response from the API. |
Raises:
Type | Description |
---|---|
ValueError
|
If neither 'cas' nor 'smiles' is provided. |
Source code in src/pyepisuite/api_client.py
Usage Examples
Basic Client Setup
from pyepisuite import EpiSuiteAPIClient
# Create client with default settings
client = EpiSuiteAPIClient()
# Or with custom base URL
client = EpiSuiteAPIClient(base_url='https://episuite.dev/EpiWebSuite/api')
# With API key (if required)
client = EpiSuiteAPIClient(api_key='your-api-key')
Searching for Chemicals
# Search by CAS number
results = client.search('50-00-0')
# Search by SMILES
results = client.search('C=O')
# Search by chemical name
results = client.search('formaldehyde')
Submitting for Predictions
# Submit using CAS number
predictions = client.submit(cas='50-00-0')
# Submit using SMILES
predictions = client.submit(smiles='C=O')
# The response includes both EPI Suite and EcoSAR results
print(predictions.keys()) # ['chemicalProperties', 'logKow', ..., 'ecosar']
Error Handling
The API client includes robust error handling:
import requests
try:
results = client.search('invalid-identifier')
except requests.exceptions.RequestException as e:
print(f"API request failed: {e}")
except ValueError as e:
print(f"Invalid parameters: {e}")
Configuration Options
Timeout Settings
API Key Authentication
If the API requires authentication:
Related Functions
For higher-level operations, see the utility functions: