Skip to content

Chemical Details API Reference

pycomptox.chemical.details.ChemicalDetails

Bases: CachedAPIClient

A class for retrieving detailed chemical information from the CompTox Dashboard API.

This class provides methods to get comprehensive chemical data including: - Chemical identifiers and names - Chemical structures (SMILES, InChI) - Physical and chemical properties - Assay information - Related data sources

Attributes:

Name Type Description
api_key str

The API key for accessing the CompTox Dashboard API.

base_url str

The base URL for the CompTox API.

session Session

A requests session for making API calls.

time_delay_between_calls float

Minimum time delay (in seconds) between API calls.

_last_call_time float

Timestamp of the last API call.

use_cache bool

Whether to use caching by default.

Source code in src/pycomptox/chemical/details.py
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
class ChemicalDetails(CachedAPIClient):
    """
    A class for retrieving detailed chemical information from the CompTox Dashboard API.

    This class provides methods to get comprehensive chemical data including:
    - Chemical identifiers and names
    - Chemical structures (SMILES, InChI)
    - Physical and chemical properties
    - Assay information
    - Related data sources

    Attributes:
        api_key (str): The API key for accessing the CompTox Dashboard API.
        base_url (str): The base URL for the CompTox API.
        session (requests.Session): A requests session for making API calls.
        time_delay_between_calls (float): Minimum time delay (in seconds) between API calls.
        _last_call_time (float): Timestamp of the last API call.
        use_cache (bool): Whether to use caching by default.
    """

    def __init__(
        self, 
        api_key: Optional[str] = None, 
        base_url: str = "https://comptox.epa.gov/ctx-api",
        time_delay_between_calls: float = 0.0,
        **kwargs
    ):
        """
        Initialize the ChemicalDetails client.

        Args:
            api_key (str, optional): The API key for accessing the CompTox Dashboard API.
                If not provided, the function will attempt to load it from:
                1. COMPTOX_API_KEY environment variable
                2. Saved configuration file (use save_api_key() to set)
            base_url (str, optional): The base URL for the API. 
                Defaults to "https://comptox.epa.gov/ctx-api".
            time_delay_between_calls (float, optional): Minimum time delay (in seconds) 
                between consecutive API calls. Defaults to 0.0 (no delay).
            **kwargs: Additional arguments for CachedAPIClient (cache_manager, use_cache)

        Raises:
            ValueError: If no API key is provided and none can be loaded.

        Example:
            >>> # Using saved API key
            >>> client = ChemicalDetails()

            >>> # With explicit API key
            >>> client = ChemicalDetails(api_key="your_api_key")

            >>> # With rate limiting
            >>> client = ChemicalDetails(time_delay_between_calls=0.5)
        """
        super().__init__(
            api_key=api_key,
            base_url=base_url,
            time_delay_between_calls=time_delay_between_calls,
            **kwargs
        )

    def data_by_dtxsid_batch(
        self, 
        dtxsids: List[str],
        projection: Optional[ProjectionType] = None,
        use_cache: Optional[bool] = None
    ) -> List[Dict[str, Any]]:
        """
        Get detailed data for a batch of DTXSIDs.

        POST /chemical/detail/search/by-dtxsid/
        Besides batch of the values, the user can also define projection (set of attributes to return).
        Maximum 1000 DTXSIDs per request.

        Example:
            curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/" \\
                -H 'accept: application/json'\\
                -H 'content-type: application/json' \\
                -d '["DTXSID7020182"]' 

        Args:
            dtxsids (List[str]): List of DSSTox Substance Identifiers. Maximum 1000 per request.
            projection (ProjectionType, optional): Set of attributes to return. Options:
                - "chemicaldetailstandard": Standard chemical details
                - "chemicalidentifier": Chemical identifiers only
                - "chemicalstructure": Structure information
                - "ntatoolkit": NTA toolkit attributes
                - "ccdchemicaldetails": CCD chemical details
                - "ccdassaydetails": CCD assay details
                - "chemicaldetailall": All chemical details (default)
                - "compact": Compact format

        Returns:
            List[Dict[str, Any]]: List of chemical detail records. Each record may contain:
                - id, preferredName, molFormula, casrn, dtxsid, dtxcid
                - smiles, msReadySmiles, qsarReadySmiles
                - inchiString, inchikey, iupacName
                - activeAssays, totalAssays, percentAssays
                - pubchemCid, pubchemCount, pubmedCount
                - monoisotopicMass, averageMass
                - And many more fields depending on projection

        Raises:
            ValueError: If more than 1000 DTXSIDs provided or request is invalid.
            RuntimeError: If the API request fails.

        Example:
            >>> details = ChemicalDetails()
            >>> dtxsids = ["DTXSID7020182", "DTXSID2021315"]
            >>> results = details.data_by_dtxsid_batch(dtxsids)
            >>> for chem in results:
            ...     print(f"{chem['preferredName']}: {chem['casrn']}")

            >>> # With specific projection
            >>> results = details.data_by_dtxsid_batch(dtxsids, projection="chemicalidentifier")
        """
        if len(dtxsids) > 1000:
            raise ValueError("Maximum 1000 DTXSIDs are allowed per batch request")

        if not dtxsids:
            raise ValueError("At least one DTXSID must be provided")

        endpoint = "/chemical/detail/search/by-dtxsid/"
        params = {}
        if projection:
            params['projection'] = projection

        return self._make_cached_request(endpoint, method='POST', json=dtxsids, params=params, use_cache=use_cache)

    def data_by_dtxcid_batch(
        self, 
        dtxcids: List[str],
        projection: Optional[ProjectionType] = None,
        use_cache: Optional[bool] = None
    ) -> List[Dict[str, Any]]:
        """
        Get detailed data for a batch of DTXCIDs.

        POST /chemical/detail/search/by-dtxcid/
        Besides batch of the values, the user can also define projection (set of attributes to return).
        Maximum 1000 DTXCIDs per request.

        Example:
            curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/" \\
                -H 'accept: application/json'\\
                -H 'content-type: application/json' \\
                -d '["DTXCID505"]' 

        RESPONSE
        200 OK
        example: {
            "id": "string",
            "preferredName": "string",
            "activeAssays": 0,
            "cpdataCount": 0,
            "molFormula": "string",
            "percentAssays": 0,
            "compoundId": 0,
            "pubchemCount": 0,
            "totalAssays": 0,
            "qcLevelDesc": "string",
            "toxcastSelect": "string",
            "isMarkush": false,
            "pprtvLink": "string",
            "sourcesCount": 0,
            "irisLink": "string",
            "multicomponent": 0,
            "msReadySmiles": "string",
            "iupacName": "string",
            "inchiString": "string",
            "pubchemCid": 0,
            "inchikey": "string",
            "pubmedCount": 0,
            "qsarReadySmiles": "string",
            "smiles": "string",
            "isotope": 0,
            "qcNotes": "string",
            "dtxcid": "string",
            "qcLevel": 0,
            "dtxsid": "string",
            "casrn": "string",
            "genericSubstanceId": 0,
            "wikipediaArticle": "string",
            "relatedSubstanceCount": 0,
            "hasStructureImage": 0,
            "monoisotopicMass": 0,
            "descriptorStringTsv": "string",
            "relatedStructureCount": 0
            }
        400: When user has submitted more than allowed number (1000) of DTXCID(s).

        Args:
            dtxcids (List[str]): List of DSSTox Compound Identifiers. Maximum 1000 per request.
            projection (ProjectionType, optional): Set of attributes to return. Same options as data_by_dtxsid_batch.

        Returns:
            List[Dict[str, Any]]: List of chemical detail records with same structure as data_by_dtxsid_batch.

        Raises:
            ValueError: If more than 1000 DTXCIDs provided or request is invalid.
            RuntimeError: If the API request fails.

        Example:
            >>> details = ChemicalDetails()
            >>> dtxcids = ["DTXCID505", "DTXCID30182"]
            >>> results = details.data_by_dtxcid_batch(dtxcids)
            >>> for chem in results:
            ...     print(f"{chem['preferredName']}: {chem['molFormula']}")
        """
        if len(dtxcids) > 1000:
            raise ValueError("Maximum 1000 DTXCIDs are allowed per batch request")

        if not dtxcids:
            raise ValueError("At least one DTXCID must be provided")

        endpoint = "/chemical/detail/search/by-dtxcid/"
        params = {}
        if projection:
            params['projection'] = projection

        return self._make_cached_request(endpoint, method='POST', json=dtxcids, params=params, use_cache=use_cache)

    def data_by_dtxsid(self, dtxsid: str, projection: Optional[ProjectionType] = None, use_cache: Optional[bool] = None) -> Dict[str, Any]:
        """
        Get detailed data by DTXSID.

        GET /chemical/detail/search/by-dtxsid/{dtxsid}
        Specify the dtxsid as part of the path, and optionally define projection (set of attributes to return).

        Example:
            curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/DTXSID7020182" \\
                -H 'accept: application/json' 

        RESPONSE
        200 OK
        example1: {
            "id": "string",
            "preferredName": "string",
            "activeAssays": 0,
            "cpdataCount": 0,
            "molFormula": "string",
            "percentAssays": 0,
            "compoundId": 0,
            "pubchemCount": 0,
            "totalAssays": 0,
            "qcLevelDesc": "string",
            "toxcastSelect": "string",
            "isMarkush": false,
            "pprtvLink": "string",
            "sourcesCount": 0,
            "irisLink": "string",
            "multicomponent": 0,
            "msReadySmiles": "string",
            "iupacName": "string",
            "inchiString": "string",
            "pubchemCid": 0,
            "inchikey": "string",
            "pubmedCount": 0,
            "qsarReadySmiles": "string",
            "smiles": "string",
            "isotope": 0,
            "qcNotes": "string",
            "dtxcid": "string",
            "qcLevel": 0,
            "dtxsid": "string",
            "casrn": "string",
            "genericSubstanceId": 0,
            "wikipediaArticle": "string",
            "relatedSubstanceCount": 0,
            "hasStructureImage": 0,
            "monoisotopicMass": 0,
            "descriptorStringTsv": "string",
            "relatedStructureCount": 0
            }
        example2: {
            "preferredName": "string",
            "iupacName": "string",
            "inchikey": "string",
            "dtxcid": "string",
            "dtxsid": "string",
            "casrn": "string"
            }
        example3: {
            "id": "string",
            "preferredName": "string",
            "msReadySmiles": "string",
            "inchiString": "string",
            "inchikey": "string",
            "qsarReadySmiles": "string",
            "smiles": "string",
            "dtxcid": "string",
            "dtxsid": "string",
            "casrn": "string",
            "hasStructureImage": 0
            }

        Args:
            dtxsid (str): DSSTox Substance Identifier (e.g., "DTXSID7020182").
            projection (ProjectionType, optional): Set of attributes to return. Default: "chemicaldetailall".
                Options:
                - "chemicaldetailstandard": Standard chemical details
                - "chemicalidentifier": Identifiers only (preferredName, iupacName, inchikey, dtxcid, dtxsid, casrn)
                - "chemicalstructure": Structure info (smiles, InChI, hasStructureImage, etc.)
                - "ntatoolkit": NTA toolkit attributes
                - "ccdchemicaldetails": CCD chemical details with properties
                - "ccdassaydetails": CCD assay details
                - "chemicaldetailall": All available attributes (default)
                - "compact": Compact format

        Returns:
            Dict[str, Any]: Chemical detail record with fields depending on projection.

        Raises:
            ValueError: If DTXSID is not found or request is invalid.
            RuntimeError: If the API request fails.

        Example:
            >>> details = ChemicalDetails()
            >>> # Get all details
            >>> data = details.data_by_dtxsid("DTXSID7020182")
            >>> print(f"{data['preferredName']}: {data['casrn']}")
            >>> print(f"Formula: {data['molFormula']}")
            >>> print(f"SMILES: {data['smiles']}")

            >>> # Get only identifiers
            >>> data = details.data_by_dtxsid("DTXSID7020182", projection="chemicalidentifier")
            >>> print(f"{data['preferredName']}: {data['dtxcid']}")
        """
        endpoint = f"/chemical/detail/search/by-dtxsid/{dtxsid}"
        params = {}
        if projection:
            params['projection'] = projection

        return self._make_cached_request(endpoint, params=params, use_cache=use_cache)

    def data_by_dtxcid(self, dtxcid: str, projection: Optional[ProjectionType] = None, use_cache: Optional[bool] = None) -> Dict[str, Any]:
        """
        Get data by dtxcid
        get /chemical/detail/search/by-dtxcid/{dtxcid}
        Specify the dtxcid as part of the path, and optionally user can also define projection (set of attributes to return).
        PATH PARAMETERS
        dtxcid string
        QUERY-STRING PARAMETERS
        projection enum
        Default: chemicaldetailall
        Allowed: chemicaldetailstandard ┃ chemicalidentifier ┃ chemicalstructure ┃ ntatoolkit ┃ ccdchemicaldetails ┃ ccdassaydetails ┃ chemicaldetailall ┃ compact

        curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/DTXCID505" \
            -H 'accept: application/json' 

        RESPONSE
        200 OK
        example1:{
            "id": "string",
            "preferredName": "string",
            "activeAssays": 0,
            "cpdataCount": 0,
            "molFormula": "string",
            "percentAssays": 0,
            "compoundId": 0,
            "pubchemCount": 0,
            "totalAssays": 0,
            "qcLevelDesc": "string",
            "toxcastSelect": "string",
            "isMarkush": false,
            "pprtvLink": "string",
            "sourcesCount": 0,
            "irisLink": "string",
            "multicomponent": 0,
            "msReadySmiles": "string",
            "iupacName": "string",
            "inchiString": "string",
            "pubchemCid": 0,
            "inchikey": "string",
            "pubmedCount": 0,
            "qsarReadySmiles": "string",
            "smiles": "string",
            "isotope": 0,
            "qcNotes": "string",
            "dtxcid": "string",
            "qcLevel": 0,
            "dtxsid": "string",
            "casrn": "string",
            "genericSubstanceId": 0,
            "wikipediaArticle": "string",
            "relatedSubstanceCount": 0,
            "hasStructureImage": 0,
            "monoisotopicMass": 0,
            "descriptorStringTsv": "string",
            "relatedStructureCount": 0
            }
        example2: {
            "preferredName": "string",
            "iupacName": "string",
            "inchikey": "string",
            "dtxcid": "string",
            "dtxsid": "string",
            "casrn": "string"
            }
        example3: {
            "id": "string",
            "preferredName": "string",
            "msReadySmiles": "string",
            "inchiString": "string",
            "inchikey": "string",
            "qsarReadySmiles": "string",
            "smiles": "string",
            "dtxcid": "string",
            "dtxsid": "string",
            "casrn": "string",
            "hasStructureImage": 0
            }
        example4:{
            "id": "string",
            "preferredName": "string",
            "activeAssays": 0,
            "cpdataCount": 0,
            "molFormula": "string",
            "percentAssays": 0,
            "compoundId": 0,
            "pubchemCount": 0,
            "averageMass": 0,
            "totalAssays": 0,
            "qcLevelDesc": "string",
            "toxcastSelect": "string",
            "isMarkush": false,
            "pprtvLink": "string",
            "sourcesCount": 0,
            "irisLink": "string",
            "multicomponent": 0,
            "msReadySmiles": "string",
            "iupacName": "string",
            "inchiString": "string",
            "pubchemCid": 0,
            "inchikey": "string",
            "pubmedCount": 0,
            "qsarReadySmiles": "string",
            "smiles": "string",
            "stereo": "string",
            "isotope": 0,
            "qcNotes": "string",
            "dtxcid": "string",
            "qcLevel": 0,
            "dtxsid": "string",
            "casrn": "string",
            "genericSubstanceId": 0,
            "wikipediaArticle": "string",
            "relatedSubstanceCount": 0,
            "hasStructureImage": 0,
            "monoisotopicMass": 0,
            "descriptorStringTsv": "string",
            "relatedStructureCount": 0,
            "hrFatheadMinnow": 0,
            "hrDiphniaLc50": 0,
            "pkabOperaPred": 0,
            "surfaceTension": 0,
            "toxvalData": "string",
            "devtoxTestPred": 0,
            "henrysLawAtm": 0,
            "oralRatLd50Mol": 0,
            "pkaaOperaPred": 0,
            "expocat": "string",
            "density": 0,
            "nhanes": "string",
            "operaKmDaysOperaPred": 0,
            "waterSolubilityOpera": 0,
            "octanolWaterPartition": 0,
            "waterSolubilityTest": 0,
            "flashPointDegcTestPred": 0,
            "expocatMedianPrediction": "string",
            "viscosityCpCpTestPred": 0,
            "thermalConductivity": 0,
            "tetrahymenaPyriformis": 0,
            "biodegradationHalfLifeDays": 0,
            "vaporPressureMmhgOperaPred": 0,
            "atmosphericHydroxylationRate": 0,
            "bioconcentrationFactorOperaPred": 0,
            "octanolAirPartitionCoeff": 0,
            "meltingPointDegcOperaPred": 0,
            "soilAdsorptionCoefficient": 0,
            "bioconcentrationFactorTestPred": 0,
            "boilingPointDegcOperaPred": 0,
            "meltingPointDegcTestPred": 0,
            "vaporPressureMmhgTestPred": 0,
            "amesMutagenicityTestPred": 0,
            "boilingPointDegcTestPred": 0
            }
        example5: 
        All attributes use for NTA Informatics Toolkit.
        {
            "preferredName": "string",
            "activeAssays": 0,
            "cpdataCount": 0,
            "molFormula": "string",
            "percentAssays": 0,
            "totalAssays": 0,
            "sourcesCount": 0,
            "msReadySmiles": "string",
            "inchikey": "string",
            "smiles": "string",
            "dtxcid": "string",
            "dtxsid": "string",
            "casrn": "string",
            "monoisotopicMass": 0,
            "expocat": "string",
            "nhanes": "string",
            "expocatMedianPrediction": "string"
            }

        Args:
            dtxcid (str): DSSTox Compound Identifier (e.g., "DTXCID505").
            projection (ProjectionType, optional): Set of attributes to return. Same options as data_by_dtxsid.

        Returns:
            Dict[str, Any]: Chemical detail record with fields depending on projection.

        Raises:
            ValueError: If DTXCID is not found or request is invalid.
            RuntimeError: If the API request fails.

        Example:
            >>> details = ChemicalDetails()
            >>> # Get all details including predicted properties
            >>> data = details.data_by_dtxcid("DTXCID505", projection="ccdchemicaldetails")
            >>> print(f"{data['preferredName']}")
            >>> print(f"Boiling Point: {data.get('boilingPointDegcOperaPred', 'N/A')}")
            >>> print(f"Water Solubility: {data.get('waterSolubilityOpera', 'N/A')}")
        """
        endpoint = f"/chemical/detail/search/by-dtxcid/{dtxcid}"
        params = {}
        if projection:
            params['projection'] = projection

        return self._make_cached_request(endpoint, params=params, use_cache=use_cache)

    def find_all_chemical_details(
        self,
        next_page: int = 1,
        projection: Optional[str] = None,
        use_cache: Optional[bool] = None
    ) -> List[Dict[str, Any]]:
        """
        Find all chemical details (paginated).

        GET /chemical/all
        Returns all chemical details. Results are paginated.

        Example:
            curl -X GET "https://comptox.epa.gov/ctx-api/chemical/all" \\
                    -H 'accept: application/json' 

        Args:
            next_page (int, optional): Page number for pagination. Default: 1.
            projection (str, optional): Specifies if projection is used. 
                Option: "all-ids" returns only id, dtxcid, and dtxsid.
                If omitted, the default ChemicalDetailStandard2 data is returned.

        Returns:
            List[Dict[str, Any]]: List of chemical records. Each record contains:
                Without projection (ChemicalDetailStandard2):
                - id, preferredName, molFormula, averageMass
                - qcLevelDesc, iupacName, inchiString, inchikey
                - smiles, qcLevel, dtxsid, casrn, monoisotopicMass

                With projection="all-ids":
                - id, dtxcid, dtxsid

        Raises:
            ValueError: If request is invalid.
            RuntimeError: If the API request fails.

        Warning:
            This endpoint returns large amounts of data. Use with caution and consider
            pagination. The API may return thousands of chemicals.

        Example:
            >>> details = ChemicalDetails()
            >>> # Get first page of all chemicals
            >>> chemicals = details.find_all_chemical_details(next_page=1)
            >>> print(f"Retrieved {len(chemicals)} chemicals")

            >>> # Get only IDs (lighter payload)
            >>> ids = details.find_all_chemical_details(projection="all-ids")
            >>> for chem in ids[:10]:
            ...     print(f"{chem['dtxsid']}: {chem['dtxcid']}")
        """
        endpoint = "/chemical/all"
        params = {'next': next_page}
        if projection:
            params['projection'] = projection

        return self._make_cached_request(endpoint, params=params, use_cache=use_cache)

__init__(api_key=None, base_url='https://comptox.epa.gov/ctx-api', time_delay_between_calls=0.0, **kwargs)

Initialize the ChemicalDetails client.

Parameters:

Name Type Description Default
api_key str

The API key for accessing the CompTox Dashboard API. If not provided, the function will attempt to load it from: 1. COMPTOX_API_KEY environment variable 2. Saved configuration file (use save_api_key() to set)

None
base_url str

The base URL for the API. Defaults to "https://comptox.epa.gov/ctx-api".

'https://comptox.epa.gov/ctx-api'
time_delay_between_calls float

Minimum time delay (in seconds) between consecutive API calls. Defaults to 0.0 (no delay).

0.0
**kwargs

Additional arguments for CachedAPIClient (cache_manager, use_cache)

{}

Raises:

Type Description
ValueError

If no API key is provided and none can be loaded.

Example

Using saved API key

client = ChemicalDetails()

With explicit API key

client = ChemicalDetails(api_key="your_api_key")

With rate limiting

client = ChemicalDetails(time_delay_between_calls=0.5)

Source code in src/pycomptox/chemical/details.py
def __init__(
    self, 
    api_key: Optional[str] = None, 
    base_url: str = "https://comptox.epa.gov/ctx-api",
    time_delay_between_calls: float = 0.0,
    **kwargs
):
    """
    Initialize the ChemicalDetails client.

    Args:
        api_key (str, optional): The API key for accessing the CompTox Dashboard API.
            If not provided, the function will attempt to load it from:
            1. COMPTOX_API_KEY environment variable
            2. Saved configuration file (use save_api_key() to set)
        base_url (str, optional): The base URL for the API. 
            Defaults to "https://comptox.epa.gov/ctx-api".
        time_delay_between_calls (float, optional): Minimum time delay (in seconds) 
            between consecutive API calls. Defaults to 0.0 (no delay).
        **kwargs: Additional arguments for CachedAPIClient (cache_manager, use_cache)

    Raises:
        ValueError: If no API key is provided and none can be loaded.

    Example:
        >>> # Using saved API key
        >>> client = ChemicalDetails()

        >>> # With explicit API key
        >>> client = ChemicalDetails(api_key="your_api_key")

        >>> # With rate limiting
        >>> client = ChemicalDetails(time_delay_between_calls=0.5)
    """
    super().__init__(
        api_key=api_key,
        base_url=base_url,
        time_delay_between_calls=time_delay_between_calls,
        **kwargs
    )

data_by_dtxcid(dtxcid, projection=None, use_cache=None)

Get data by dtxcid get /chemical/detail/search/by-dtxcid/{dtxcid} Specify the dtxcid as part of the path, and optionally user can also define projection (set of attributes to return). PATH PARAMETERS dtxcid string QUERY-STRING PARAMETERS projection enum Default: chemicaldetailall Allowed: chemicaldetailstandard ┃ chemicalidentifier ┃ chemicalstructure ┃ ntatoolkit ┃ ccdchemicaldetails ┃ ccdassaydetails ┃ chemicaldetailall ┃ compact

curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/DTXCID505" -H 'accept: application/json'

RESPONSE 200 OK example1:{ "id": "string", "preferredName": "string", "activeAssays": 0, "cpdataCount": 0, "molFormula": "string", "percentAssays": 0, "compoundId": 0, "pubchemCount": 0, "totalAssays": 0, "qcLevelDesc": "string", "toxcastSelect": "string", "isMarkush": false, "pprtvLink": "string", "sourcesCount": 0, "irisLink": "string", "multicomponent": 0, "msReadySmiles": "string", "iupacName": "string", "inchiString": "string", "pubchemCid": 0, "inchikey": "string", "pubmedCount": 0, "qsarReadySmiles": "string", "smiles": "string", "isotope": 0, "qcNotes": "string", "dtxcid": "string", "qcLevel": 0, "dtxsid": "string", "casrn": "string", "genericSubstanceId": 0, "wikipediaArticle": "string", "relatedSubstanceCount": 0, "hasStructureImage": 0, "monoisotopicMass": 0, "descriptorStringTsv": "string", "relatedStructureCount": 0 } example2: { "preferredName": "string", "iupacName": "string", "inchikey": "string", "dtxcid": "string", "dtxsid": "string", "casrn": "string" } example3: { "id": "string", "preferredName": "string", "msReadySmiles": "string", "inchiString": "string", "inchikey": "string", "qsarReadySmiles": "string", "smiles": "string", "dtxcid": "string", "dtxsid": "string", "casrn": "string", "hasStructureImage": 0 } example4:{ "id": "string", "preferredName": "string", "activeAssays": 0, "cpdataCount": 0, "molFormula": "string", "percentAssays": 0, "compoundId": 0, "pubchemCount": 0, "averageMass": 0, "totalAssays": 0, "qcLevelDesc": "string", "toxcastSelect": "string", "isMarkush": false, "pprtvLink": "string", "sourcesCount": 0, "irisLink": "string", "multicomponent": 0, "msReadySmiles": "string", "iupacName": "string", "inchiString": "string", "pubchemCid": 0, "inchikey": "string", "pubmedCount": 0, "qsarReadySmiles": "string", "smiles": "string", "stereo": "string", "isotope": 0, "qcNotes": "string", "dtxcid": "string", "qcLevel": 0, "dtxsid": "string", "casrn": "string", "genericSubstanceId": 0, "wikipediaArticle": "string", "relatedSubstanceCount": 0, "hasStructureImage": 0, "monoisotopicMass": 0, "descriptorStringTsv": "string", "relatedStructureCount": 0, "hrFatheadMinnow": 0, "hrDiphniaLc50": 0, "pkabOperaPred": 0, "surfaceTension": 0, "toxvalData": "string", "devtoxTestPred": 0, "henrysLawAtm": 0, "oralRatLd50Mol": 0, "pkaaOperaPred": 0, "expocat": "string", "density": 0, "nhanes": "string", "operaKmDaysOperaPred": 0, "waterSolubilityOpera": 0, "octanolWaterPartition": 0, "waterSolubilityTest": 0, "flashPointDegcTestPred": 0, "expocatMedianPrediction": "string", "viscosityCpCpTestPred": 0, "thermalConductivity": 0, "tetrahymenaPyriformis": 0, "biodegradationHalfLifeDays": 0, "vaporPressureMmhgOperaPred": 0, "atmosphericHydroxylationRate": 0, "bioconcentrationFactorOperaPred": 0, "octanolAirPartitionCoeff": 0, "meltingPointDegcOperaPred": 0, "soilAdsorptionCoefficient": 0, "bioconcentrationFactorTestPred": 0, "boilingPointDegcOperaPred": 0, "meltingPointDegcTestPred": 0, "vaporPressureMmhgTestPred": 0, "amesMutagenicityTestPred": 0, "boilingPointDegcTestPred": 0 } example5: All attributes use for NTA Informatics Toolkit. { "preferredName": "string", "activeAssays": 0, "cpdataCount": 0, "molFormula": "string", "percentAssays": 0, "totalAssays": 0, "sourcesCount": 0, "msReadySmiles": "string", "inchikey": "string", "smiles": "string", "dtxcid": "string", "dtxsid": "string", "casrn": "string", "monoisotopicMass": 0, "expocat": "string", "nhanes": "string", "expocatMedianPrediction": "string" }

Parameters:

Name Type Description Default
dtxcid str

DSSTox Compound Identifier (e.g., "DTXCID505").

required
projection ProjectionType

Set of attributes to return. Same options as data_by_dtxsid.

None

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: Chemical detail record with fields depending on projection.

Raises:

Type Description
ValueError

If DTXCID is not found or request is invalid.

RuntimeError

If the API request fails.

Example

details = ChemicalDetails()

Get all details including predicted properties

data = details.data_by_dtxcid("DTXCID505", projection="ccdchemicaldetails") print(f"{data['preferredName']}") print(f"Boiling Point: {data.get('boilingPointDegcOperaPred', 'N/A')}") print(f"Water Solubility: {data.get('waterSolubilityOpera', 'N/A')}")

Source code in src/pycomptox/chemical/details.py
def data_by_dtxcid(self, dtxcid: str, projection: Optional[ProjectionType] = None, use_cache: Optional[bool] = None) -> Dict[str, Any]:
    """
    Get data by dtxcid
    get /chemical/detail/search/by-dtxcid/{dtxcid}
    Specify the dtxcid as part of the path, and optionally user can also define projection (set of attributes to return).
    PATH PARAMETERS
    dtxcid string
    QUERY-STRING PARAMETERS
    projection enum
    Default: chemicaldetailall
    Allowed: chemicaldetailstandard ┃ chemicalidentifier ┃ chemicalstructure ┃ ntatoolkit ┃ ccdchemicaldetails ┃ ccdassaydetails ┃ chemicaldetailall ┃ compact

    curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/DTXCID505" \
        -H 'accept: application/json' 

    RESPONSE
    200 OK
    example1:{
        "id": "string",
        "preferredName": "string",
        "activeAssays": 0,
        "cpdataCount": 0,
        "molFormula": "string",
        "percentAssays": 0,
        "compoundId": 0,
        "pubchemCount": 0,
        "totalAssays": 0,
        "qcLevelDesc": "string",
        "toxcastSelect": "string",
        "isMarkush": false,
        "pprtvLink": "string",
        "sourcesCount": 0,
        "irisLink": "string",
        "multicomponent": 0,
        "msReadySmiles": "string",
        "iupacName": "string",
        "inchiString": "string",
        "pubchemCid": 0,
        "inchikey": "string",
        "pubmedCount": 0,
        "qsarReadySmiles": "string",
        "smiles": "string",
        "isotope": 0,
        "qcNotes": "string",
        "dtxcid": "string",
        "qcLevel": 0,
        "dtxsid": "string",
        "casrn": "string",
        "genericSubstanceId": 0,
        "wikipediaArticle": "string",
        "relatedSubstanceCount": 0,
        "hasStructureImage": 0,
        "monoisotopicMass": 0,
        "descriptorStringTsv": "string",
        "relatedStructureCount": 0
        }
    example2: {
        "preferredName": "string",
        "iupacName": "string",
        "inchikey": "string",
        "dtxcid": "string",
        "dtxsid": "string",
        "casrn": "string"
        }
    example3: {
        "id": "string",
        "preferredName": "string",
        "msReadySmiles": "string",
        "inchiString": "string",
        "inchikey": "string",
        "qsarReadySmiles": "string",
        "smiles": "string",
        "dtxcid": "string",
        "dtxsid": "string",
        "casrn": "string",
        "hasStructureImage": 0
        }
    example4:{
        "id": "string",
        "preferredName": "string",
        "activeAssays": 0,
        "cpdataCount": 0,
        "molFormula": "string",
        "percentAssays": 0,
        "compoundId": 0,
        "pubchemCount": 0,
        "averageMass": 0,
        "totalAssays": 0,
        "qcLevelDesc": "string",
        "toxcastSelect": "string",
        "isMarkush": false,
        "pprtvLink": "string",
        "sourcesCount": 0,
        "irisLink": "string",
        "multicomponent": 0,
        "msReadySmiles": "string",
        "iupacName": "string",
        "inchiString": "string",
        "pubchemCid": 0,
        "inchikey": "string",
        "pubmedCount": 0,
        "qsarReadySmiles": "string",
        "smiles": "string",
        "stereo": "string",
        "isotope": 0,
        "qcNotes": "string",
        "dtxcid": "string",
        "qcLevel": 0,
        "dtxsid": "string",
        "casrn": "string",
        "genericSubstanceId": 0,
        "wikipediaArticle": "string",
        "relatedSubstanceCount": 0,
        "hasStructureImage": 0,
        "monoisotopicMass": 0,
        "descriptorStringTsv": "string",
        "relatedStructureCount": 0,
        "hrFatheadMinnow": 0,
        "hrDiphniaLc50": 0,
        "pkabOperaPred": 0,
        "surfaceTension": 0,
        "toxvalData": "string",
        "devtoxTestPred": 0,
        "henrysLawAtm": 0,
        "oralRatLd50Mol": 0,
        "pkaaOperaPred": 0,
        "expocat": "string",
        "density": 0,
        "nhanes": "string",
        "operaKmDaysOperaPred": 0,
        "waterSolubilityOpera": 0,
        "octanolWaterPartition": 0,
        "waterSolubilityTest": 0,
        "flashPointDegcTestPred": 0,
        "expocatMedianPrediction": "string",
        "viscosityCpCpTestPred": 0,
        "thermalConductivity": 0,
        "tetrahymenaPyriformis": 0,
        "biodegradationHalfLifeDays": 0,
        "vaporPressureMmhgOperaPred": 0,
        "atmosphericHydroxylationRate": 0,
        "bioconcentrationFactorOperaPred": 0,
        "octanolAirPartitionCoeff": 0,
        "meltingPointDegcOperaPred": 0,
        "soilAdsorptionCoefficient": 0,
        "bioconcentrationFactorTestPred": 0,
        "boilingPointDegcOperaPred": 0,
        "meltingPointDegcTestPred": 0,
        "vaporPressureMmhgTestPred": 0,
        "amesMutagenicityTestPred": 0,
        "boilingPointDegcTestPred": 0
        }
    example5: 
    All attributes use for NTA Informatics Toolkit.
    {
        "preferredName": "string",
        "activeAssays": 0,
        "cpdataCount": 0,
        "molFormula": "string",
        "percentAssays": 0,
        "totalAssays": 0,
        "sourcesCount": 0,
        "msReadySmiles": "string",
        "inchikey": "string",
        "smiles": "string",
        "dtxcid": "string",
        "dtxsid": "string",
        "casrn": "string",
        "monoisotopicMass": 0,
        "expocat": "string",
        "nhanes": "string",
        "expocatMedianPrediction": "string"
        }

    Args:
        dtxcid (str): DSSTox Compound Identifier (e.g., "DTXCID505").
        projection (ProjectionType, optional): Set of attributes to return. Same options as data_by_dtxsid.

    Returns:
        Dict[str, Any]: Chemical detail record with fields depending on projection.

    Raises:
        ValueError: If DTXCID is not found or request is invalid.
        RuntimeError: If the API request fails.

    Example:
        >>> details = ChemicalDetails()
        >>> # Get all details including predicted properties
        >>> data = details.data_by_dtxcid("DTXCID505", projection="ccdchemicaldetails")
        >>> print(f"{data['preferredName']}")
        >>> print(f"Boiling Point: {data.get('boilingPointDegcOperaPred', 'N/A')}")
        >>> print(f"Water Solubility: {data.get('waterSolubilityOpera', 'N/A')}")
    """
    endpoint = f"/chemical/detail/search/by-dtxcid/{dtxcid}"
    params = {}
    if projection:
        params['projection'] = projection

    return self._make_cached_request(endpoint, params=params, use_cache=use_cache)

data_by_dtxcid_batch(dtxcids, projection=None, use_cache=None)

Get detailed data for a batch of DTXCIDs.

POST /chemical/detail/search/by-dtxcid/ Besides batch of the values, the user can also define projection (set of attributes to return). Maximum 1000 DTXCIDs per request.

Example

curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/" \ -H 'accept: application/json'\ -H 'content-type: application/json' \ -d '["DTXCID505"]'

RESPONSE 200 OK example: { "id": "string", "preferredName": "string", "activeAssays": 0, "cpdataCount": 0, "molFormula": "string", "percentAssays": 0, "compoundId": 0, "pubchemCount": 0, "totalAssays": 0, "qcLevelDesc": "string", "toxcastSelect": "string", "isMarkush": false, "pprtvLink": "string", "sourcesCount": 0, "irisLink": "string", "multicomponent": 0, "msReadySmiles": "string", "iupacName": "string", "inchiString": "string", "pubchemCid": 0, "inchikey": "string", "pubmedCount": 0, "qsarReadySmiles": "string", "smiles": "string", "isotope": 0, "qcNotes": "string", "dtxcid": "string", "qcLevel": 0, "dtxsid": "string", "casrn": "string", "genericSubstanceId": 0, "wikipediaArticle": "string", "relatedSubstanceCount": 0, "hasStructureImage": 0, "monoisotopicMass": 0, "descriptorStringTsv": "string", "relatedStructureCount": 0 } 400: When user has submitted more than allowed number (1000) of DTXCID(s).

Parameters:

Name Type Description Default
dtxcids List[str]

List of DSSTox Compound Identifiers. Maximum 1000 per request.

required
projection ProjectionType

Set of attributes to return. Same options as data_by_dtxsid_batch.

None

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: List of chemical detail records with same structure as data_by_dtxsid_batch.

Raises:

Type Description
ValueError

If more than 1000 DTXCIDs provided or request is invalid.

RuntimeError

If the API request fails.

Example

details = ChemicalDetails() dtxcids = ["DTXCID505", "DTXCID30182"] results = details.data_by_dtxcid_batch(dtxcids) for chem in results: ... print(f"{chem['preferredName']}: {chem['molFormula']}")

Source code in src/pycomptox/chemical/details.py
def data_by_dtxcid_batch(
    self, 
    dtxcids: List[str],
    projection: Optional[ProjectionType] = None,
    use_cache: Optional[bool] = None
) -> List[Dict[str, Any]]:
    """
    Get detailed data for a batch of DTXCIDs.

    POST /chemical/detail/search/by-dtxcid/
    Besides batch of the values, the user can also define projection (set of attributes to return).
    Maximum 1000 DTXCIDs per request.

    Example:
        curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxcid/" \\
            -H 'accept: application/json'\\
            -H 'content-type: application/json' \\
            -d '["DTXCID505"]' 

    RESPONSE
    200 OK
    example: {
        "id": "string",
        "preferredName": "string",
        "activeAssays": 0,
        "cpdataCount": 0,
        "molFormula": "string",
        "percentAssays": 0,
        "compoundId": 0,
        "pubchemCount": 0,
        "totalAssays": 0,
        "qcLevelDesc": "string",
        "toxcastSelect": "string",
        "isMarkush": false,
        "pprtvLink": "string",
        "sourcesCount": 0,
        "irisLink": "string",
        "multicomponent": 0,
        "msReadySmiles": "string",
        "iupacName": "string",
        "inchiString": "string",
        "pubchemCid": 0,
        "inchikey": "string",
        "pubmedCount": 0,
        "qsarReadySmiles": "string",
        "smiles": "string",
        "isotope": 0,
        "qcNotes": "string",
        "dtxcid": "string",
        "qcLevel": 0,
        "dtxsid": "string",
        "casrn": "string",
        "genericSubstanceId": 0,
        "wikipediaArticle": "string",
        "relatedSubstanceCount": 0,
        "hasStructureImage": 0,
        "monoisotopicMass": 0,
        "descriptorStringTsv": "string",
        "relatedStructureCount": 0
        }
    400: When user has submitted more than allowed number (1000) of DTXCID(s).

    Args:
        dtxcids (List[str]): List of DSSTox Compound Identifiers. Maximum 1000 per request.
        projection (ProjectionType, optional): Set of attributes to return. Same options as data_by_dtxsid_batch.

    Returns:
        List[Dict[str, Any]]: List of chemical detail records with same structure as data_by_dtxsid_batch.

    Raises:
        ValueError: If more than 1000 DTXCIDs provided or request is invalid.
        RuntimeError: If the API request fails.

    Example:
        >>> details = ChemicalDetails()
        >>> dtxcids = ["DTXCID505", "DTXCID30182"]
        >>> results = details.data_by_dtxcid_batch(dtxcids)
        >>> for chem in results:
        ...     print(f"{chem['preferredName']}: {chem['molFormula']}")
    """
    if len(dtxcids) > 1000:
        raise ValueError("Maximum 1000 DTXCIDs are allowed per batch request")

    if not dtxcids:
        raise ValueError("At least one DTXCID must be provided")

    endpoint = "/chemical/detail/search/by-dtxcid/"
    params = {}
    if projection:
        params['projection'] = projection

    return self._make_cached_request(endpoint, method='POST', json=dtxcids, params=params, use_cache=use_cache)

data_by_dtxsid(dtxsid, projection=None, use_cache=None)

Get detailed data by DTXSID.

GET /chemical/detail/search/by-dtxsid/{dtxsid} Specify the dtxsid as part of the path, and optionally define projection (set of attributes to return).

Example

curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/DTXSID7020182" \ -H 'accept: application/json'

RESPONSE 200 OK example1: { "id": "string", "preferredName": "string", "activeAssays": 0, "cpdataCount": 0, "molFormula": "string", "percentAssays": 0, "compoundId": 0, "pubchemCount": 0, "totalAssays": 0, "qcLevelDesc": "string", "toxcastSelect": "string", "isMarkush": false, "pprtvLink": "string", "sourcesCount": 0, "irisLink": "string", "multicomponent": 0, "msReadySmiles": "string", "iupacName": "string", "inchiString": "string", "pubchemCid": 0, "inchikey": "string", "pubmedCount": 0, "qsarReadySmiles": "string", "smiles": "string", "isotope": 0, "qcNotes": "string", "dtxcid": "string", "qcLevel": 0, "dtxsid": "string", "casrn": "string", "genericSubstanceId": 0, "wikipediaArticle": "string", "relatedSubstanceCount": 0, "hasStructureImage": 0, "monoisotopicMass": 0, "descriptorStringTsv": "string", "relatedStructureCount": 0 } example2: { "preferredName": "string", "iupacName": "string", "inchikey": "string", "dtxcid": "string", "dtxsid": "string", "casrn": "string" } example3: { "id": "string", "preferredName": "string", "msReadySmiles": "string", "inchiString": "string", "inchikey": "string", "qsarReadySmiles": "string", "smiles": "string", "dtxcid": "string", "dtxsid": "string", "casrn": "string", "hasStructureImage": 0 }

Parameters:

Name Type Description Default
dtxsid str

DSSTox Substance Identifier (e.g., "DTXSID7020182").

required
projection ProjectionType

Set of attributes to return. Default: "chemicaldetailall". Options: - "chemicaldetailstandard": Standard chemical details - "chemicalidentifier": Identifiers only (preferredName, iupacName, inchikey, dtxcid, dtxsid, casrn) - "chemicalstructure": Structure info (smiles, InChI, hasStructureImage, etc.) - "ntatoolkit": NTA toolkit attributes - "ccdchemicaldetails": CCD chemical details with properties - "ccdassaydetails": CCD assay details - "chemicaldetailall": All available attributes (default) - "compact": Compact format

None

Returns:

Type Description
Dict[str, Any]

Dict[str, Any]: Chemical detail record with fields depending on projection.

Raises:

Type Description
ValueError

If DTXSID is not found or request is invalid.

RuntimeError

If the API request fails.

Example

details = ChemicalDetails()

Get all details

data = details.data_by_dtxsid("DTXSID7020182") print(f"{data['preferredName']}: {data['casrn']}") print(f"Formula: {data['molFormula']}") print(f"SMILES: {data['smiles']}")

Get only identifiers

data = details.data_by_dtxsid("DTXSID7020182", projection="chemicalidentifier") print(f"{data['preferredName']}: {data['dtxcid']}")

Source code in src/pycomptox/chemical/details.py
def data_by_dtxsid(self, dtxsid: str, projection: Optional[ProjectionType] = None, use_cache: Optional[bool] = None) -> Dict[str, Any]:
    """
    Get detailed data by DTXSID.

    GET /chemical/detail/search/by-dtxsid/{dtxsid}
    Specify the dtxsid as part of the path, and optionally define projection (set of attributes to return).

    Example:
        curl -X GET "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/DTXSID7020182" \\
            -H 'accept: application/json' 

    RESPONSE
    200 OK
    example1: {
        "id": "string",
        "preferredName": "string",
        "activeAssays": 0,
        "cpdataCount": 0,
        "molFormula": "string",
        "percentAssays": 0,
        "compoundId": 0,
        "pubchemCount": 0,
        "totalAssays": 0,
        "qcLevelDesc": "string",
        "toxcastSelect": "string",
        "isMarkush": false,
        "pprtvLink": "string",
        "sourcesCount": 0,
        "irisLink": "string",
        "multicomponent": 0,
        "msReadySmiles": "string",
        "iupacName": "string",
        "inchiString": "string",
        "pubchemCid": 0,
        "inchikey": "string",
        "pubmedCount": 0,
        "qsarReadySmiles": "string",
        "smiles": "string",
        "isotope": 0,
        "qcNotes": "string",
        "dtxcid": "string",
        "qcLevel": 0,
        "dtxsid": "string",
        "casrn": "string",
        "genericSubstanceId": 0,
        "wikipediaArticle": "string",
        "relatedSubstanceCount": 0,
        "hasStructureImage": 0,
        "monoisotopicMass": 0,
        "descriptorStringTsv": "string",
        "relatedStructureCount": 0
        }
    example2: {
        "preferredName": "string",
        "iupacName": "string",
        "inchikey": "string",
        "dtxcid": "string",
        "dtxsid": "string",
        "casrn": "string"
        }
    example3: {
        "id": "string",
        "preferredName": "string",
        "msReadySmiles": "string",
        "inchiString": "string",
        "inchikey": "string",
        "qsarReadySmiles": "string",
        "smiles": "string",
        "dtxcid": "string",
        "dtxsid": "string",
        "casrn": "string",
        "hasStructureImage": 0
        }

    Args:
        dtxsid (str): DSSTox Substance Identifier (e.g., "DTXSID7020182").
        projection (ProjectionType, optional): Set of attributes to return. Default: "chemicaldetailall".
            Options:
            - "chemicaldetailstandard": Standard chemical details
            - "chemicalidentifier": Identifiers only (preferredName, iupacName, inchikey, dtxcid, dtxsid, casrn)
            - "chemicalstructure": Structure info (smiles, InChI, hasStructureImage, etc.)
            - "ntatoolkit": NTA toolkit attributes
            - "ccdchemicaldetails": CCD chemical details with properties
            - "ccdassaydetails": CCD assay details
            - "chemicaldetailall": All available attributes (default)
            - "compact": Compact format

    Returns:
        Dict[str, Any]: Chemical detail record with fields depending on projection.

    Raises:
        ValueError: If DTXSID is not found or request is invalid.
        RuntimeError: If the API request fails.

    Example:
        >>> details = ChemicalDetails()
        >>> # Get all details
        >>> data = details.data_by_dtxsid("DTXSID7020182")
        >>> print(f"{data['preferredName']}: {data['casrn']}")
        >>> print(f"Formula: {data['molFormula']}")
        >>> print(f"SMILES: {data['smiles']}")

        >>> # Get only identifiers
        >>> data = details.data_by_dtxsid("DTXSID7020182", projection="chemicalidentifier")
        >>> print(f"{data['preferredName']}: {data['dtxcid']}")
    """
    endpoint = f"/chemical/detail/search/by-dtxsid/{dtxsid}"
    params = {}
    if projection:
        params['projection'] = projection

    return self._make_cached_request(endpoint, params=params, use_cache=use_cache)

data_by_dtxsid_batch(dtxsids, projection=None, use_cache=None)

Get detailed data for a batch of DTXSIDs.

POST /chemical/detail/search/by-dtxsid/ Besides batch of the values, the user can also define projection (set of attributes to return). Maximum 1000 DTXSIDs per request.

Example

curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/" \ -H 'accept: application/json'\ -H 'content-type: application/json' \ -d '["DTXSID7020182"]'

Parameters:

Name Type Description Default
dtxsids List[str]

List of DSSTox Substance Identifiers. Maximum 1000 per request.

required
projection ProjectionType

Set of attributes to return. Options: - "chemicaldetailstandard": Standard chemical details - "chemicalidentifier": Chemical identifiers only - "chemicalstructure": Structure information - "ntatoolkit": NTA toolkit attributes - "ccdchemicaldetails": CCD chemical details - "ccdassaydetails": CCD assay details - "chemicaldetailall": All chemical details (default) - "compact": Compact format

None

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: List of chemical detail records. Each record may contain: - id, preferredName, molFormula, casrn, dtxsid, dtxcid - smiles, msReadySmiles, qsarReadySmiles - inchiString, inchikey, iupacName - activeAssays, totalAssays, percentAssays - pubchemCid, pubchemCount, pubmedCount - monoisotopicMass, averageMass - And many more fields depending on projection

Raises:

Type Description
ValueError

If more than 1000 DTXSIDs provided or request is invalid.

RuntimeError

If the API request fails.

Example

details = ChemicalDetails() dtxsids = ["DTXSID7020182", "DTXSID2021315"] results = details.data_by_dtxsid_batch(dtxsids) for chem in results: ... print(f"{chem['preferredName']}: {chem['casrn']}")

With specific projection

results = details.data_by_dtxsid_batch(dtxsids, projection="chemicalidentifier")

Source code in src/pycomptox/chemical/details.py
def data_by_dtxsid_batch(
    self, 
    dtxsids: List[str],
    projection: Optional[ProjectionType] = None,
    use_cache: Optional[bool] = None
) -> List[Dict[str, Any]]:
    """
    Get detailed data for a batch of DTXSIDs.

    POST /chemical/detail/search/by-dtxsid/
    Besides batch of the values, the user can also define projection (set of attributes to return).
    Maximum 1000 DTXSIDs per request.

    Example:
        curl -X POST "https://comptox.epa.gov/ctx-api/chemical/detail/search/by-dtxsid/" \\
            -H 'accept: application/json'\\
            -H 'content-type: application/json' \\
            -d '["DTXSID7020182"]' 

    Args:
        dtxsids (List[str]): List of DSSTox Substance Identifiers. Maximum 1000 per request.
        projection (ProjectionType, optional): Set of attributes to return. Options:
            - "chemicaldetailstandard": Standard chemical details
            - "chemicalidentifier": Chemical identifiers only
            - "chemicalstructure": Structure information
            - "ntatoolkit": NTA toolkit attributes
            - "ccdchemicaldetails": CCD chemical details
            - "ccdassaydetails": CCD assay details
            - "chemicaldetailall": All chemical details (default)
            - "compact": Compact format

    Returns:
        List[Dict[str, Any]]: List of chemical detail records. Each record may contain:
            - id, preferredName, molFormula, casrn, dtxsid, dtxcid
            - smiles, msReadySmiles, qsarReadySmiles
            - inchiString, inchikey, iupacName
            - activeAssays, totalAssays, percentAssays
            - pubchemCid, pubchemCount, pubmedCount
            - monoisotopicMass, averageMass
            - And many more fields depending on projection

    Raises:
        ValueError: If more than 1000 DTXSIDs provided or request is invalid.
        RuntimeError: If the API request fails.

    Example:
        >>> details = ChemicalDetails()
        >>> dtxsids = ["DTXSID7020182", "DTXSID2021315"]
        >>> results = details.data_by_dtxsid_batch(dtxsids)
        >>> for chem in results:
        ...     print(f"{chem['preferredName']}: {chem['casrn']}")

        >>> # With specific projection
        >>> results = details.data_by_dtxsid_batch(dtxsids, projection="chemicalidentifier")
    """
    if len(dtxsids) > 1000:
        raise ValueError("Maximum 1000 DTXSIDs are allowed per batch request")

    if not dtxsids:
        raise ValueError("At least one DTXSID must be provided")

    endpoint = "/chemical/detail/search/by-dtxsid/"
    params = {}
    if projection:
        params['projection'] = projection

    return self._make_cached_request(endpoint, method='POST', json=dtxsids, params=params, use_cache=use_cache)

find_all_chemical_details(next_page=1, projection=None, use_cache=None)

Find all chemical details (paginated).

GET /chemical/all Returns all chemical details. Results are paginated.

Example

curl -X GET "https://comptox.epa.gov/ctx-api/chemical/all" \ -H 'accept: application/json'

Parameters:

Name Type Description Default
next_page int

Page number for pagination. Default: 1.

1
projection str

Specifies if projection is used. Option: "all-ids" returns only id, dtxcid, and dtxsid. If omitted, the default ChemicalDetailStandard2 data is returned.

None

Returns:

Type Description
List[Dict[str, Any]]

List[Dict[str, Any]]: List of chemical records. Each record contains: Without projection (ChemicalDetailStandard2): - id, preferredName, molFormula, averageMass - qcLevelDesc, iupacName, inchiString, inchikey - smiles, qcLevel, dtxsid, casrn, monoisotopicMass

With projection="all-ids": - id, dtxcid, dtxsid

Raises:

Type Description
ValueError

If request is invalid.

RuntimeError

If the API request fails.

Warning

This endpoint returns large amounts of data. Use with caution and consider pagination. The API may return thousands of chemicals.

Example

details = ChemicalDetails()

Get first page of all chemicals

chemicals = details.find_all_chemical_details(next_page=1) print(f"Retrieved {len(chemicals)} chemicals")

Get only IDs (lighter payload)

ids = details.find_all_chemical_details(projection="all-ids") for chem in ids[:10]: ... print(f"{chem['dtxsid']}: {chem['dtxcid']}")

Source code in src/pycomptox/chemical/details.py
def find_all_chemical_details(
    self,
    next_page: int = 1,
    projection: Optional[str] = None,
    use_cache: Optional[bool] = None
) -> List[Dict[str, Any]]:
    """
    Find all chemical details (paginated).

    GET /chemical/all
    Returns all chemical details. Results are paginated.

    Example:
        curl -X GET "https://comptox.epa.gov/ctx-api/chemical/all" \\
                -H 'accept: application/json' 

    Args:
        next_page (int, optional): Page number for pagination. Default: 1.
        projection (str, optional): Specifies if projection is used. 
            Option: "all-ids" returns only id, dtxcid, and dtxsid.
            If omitted, the default ChemicalDetailStandard2 data is returned.

    Returns:
        List[Dict[str, Any]]: List of chemical records. Each record contains:
            Without projection (ChemicalDetailStandard2):
            - id, preferredName, molFormula, averageMass
            - qcLevelDesc, iupacName, inchiString, inchikey
            - smiles, qcLevel, dtxsid, casrn, monoisotopicMass

            With projection="all-ids":
            - id, dtxcid, dtxsid

    Raises:
        ValueError: If request is invalid.
        RuntimeError: If the API request fails.

    Warning:
        This endpoint returns large amounts of data. Use with caution and consider
        pagination. The API may return thousands of chemicals.

    Example:
        >>> details = ChemicalDetails()
        >>> # Get first page of all chemicals
        >>> chemicals = details.find_all_chemical_details(next_page=1)
        >>> print(f"Retrieved {len(chemicals)} chemicals")

        >>> # Get only IDs (lighter payload)
        >>> ids = details.find_all_chemical_details(projection="all-ids")
        >>> for chem in ids[:10]:
        ...     print(f"{chem['dtxsid']}: {chem['dtxcid']}")
    """
    endpoint = "/chemical/all"
    params = {'next': next_page}
    if projection:
        params['projection'] = projection

    return self._make_cached_request(endpoint, params=params, use_cache=use_cache)