API Client
The EpiSuiteAPIClient class provides the core interface for interacting with the EPISuite API.
By default, the client now prefers a local runtime when data/local/EpiSuiteCLI.jar is available.
Set PYEPISUITE_MODE=remote to force the hosted API.
Overview
pyepisuite.api_client.EpiSuiteAPIClient
Source code in src/pyepisuite/api_client.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 | |
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
stop_local_runtime()
staticmethod
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.
# If a local JAR is present, this starts local mode automatically.
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')
Explicit Local Client
from pyepisuite import LocalEpiSuiteAPIClient, stop_local_episuite_server
# Always target local runtime.
client = LocalEpiSuiteAPIClient()
ids = client.search('formaldehyde')
result = client.submit(cas='000050-00-0')
# Stop managed local process when needed.
stop_local_episuite_server()
Mode Selection
Use PYEPISUITE_MODE to control behavior:
auto(default): prefer local runtime if JAR exists, otherwise use remote APIlocal: require local runtime and fail fast if startup failsremote: always use hosted API
Optional local environment variables:
PYEPISUITE_LOCAL_JAR_PATH: absolute/relative path toEpiSuiteCLI.jarPYEPISUITE_LOCAL_BASE_URL: connect-only mode, e.g.http://127.0.0.1:45511PYEPISUITE_LOCAL_STARTUP_TIMEOUT: startup timeout in seconds (default60)
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: