1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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
|
---
tocdepth: '3'
---
(api)=
# API documentation
This part of the documentation is automatically generated from the PubChemPy source code and comments. It contains comprehensive information on every function, class and method available in the PubChemPy library.
```{eval-rst}
.. module:: pubchempy
```
## Search functions
```{eval-rst}
.. autofunction:: get_compounds
.. autofunction:: get_substances
.. autofunction:: get_assays
.. autofunction:: get_properties
.. autofunction:: get_synonyms
```
## Objects
The PubChem database is organized into three main record types:
- **Substances**: Raw chemical records deposited by data contributors.
- **Compounds**: Standardized and deduplicated chemical records derived from substances.
- **Assays**: Experimental data from biological screening and testing.
PubChemPy has classes to represent each of these record types.
```{eval-rst}
.. autoclass:: pubchempy.Compound
:members:
.. autoclass:: pubchempy.Atom
:members:
.. autoclass:: pubchempy.Bond
:members:
.. autoclass:: pubchempy.Substance
:members:
.. autoclass:: pubchempy.Assay
:members:
```
## Identifier functions
```{eval-rst}
.. autofunction:: get_cids
.. autofunction:: get_sids
.. autofunction:: get_aids
```
## Request functions
```{eval-rst}
.. autofunction:: download
.. autofunction:: request
.. autofunction:: get
.. autofunction:: get_json
.. autofunction:: get_sdf
```
## *pandas* functions
Each of the search functions, {func}`~pubchempy.get_compounds`, {func}`~pubchempy.get_substances` and {func}`~pubchempy.get_properties` has an `as_dataframe` parameter. When set to `True`, these functions automatically extract properties from each result in the list into a pandas {class}`~pandas.DataFrame` and return that instead of the results themselves.
If you already have a list of Compounds or Substances, the functions below allow a {class}`~pandas.DataFrame` to be constructed easily.
```{eval-rst}
.. autofunction:: compounds_to_frame
.. autofunction:: substances_to_frame
```
## Constants
```{eval-rst}
.. autodata:: pubchempy.API_BASE
.. autodata:: pubchempy.ELEMENTS
.. autodata:: pubchempy.PROPERTY_MAP
.. autoclass:: pubchempy.CompoundIdType
:members:
.. autoclass:: pubchempy.BondType
:members:
.. autoclass:: pubchempy.CoordinateType
:members:
.. autoclass:: pubchempy.ProjectCategory
:members:
```
## Exceptions
```{eval-rst}
.. autoexception:: pubchempy.PubChemPyError
:show-inheritance:
.. autoexception:: pubchempy.ResponseParseError
:show-inheritance:
.. autoexception:: pubchempy.PubChemHTTPError
:show-inheritance:
.. autoexception:: pubchempy.BadRequestError
:show-inheritance:
.. autoexception:: pubchempy.NotFoundError
:show-inheritance:
.. autoexception:: pubchempy.MethodNotAllowedError
:show-inheritance:
.. autoexception:: pubchempy.ServerError
:show-inheritance:
.. autoexception:: pubchempy.UnimplementedError
:show-inheritance:
.. autoexception:: pubchempy.ServerBusyError
:show-inheritance:
.. autoexception:: pubchempy.TimeoutError
:show-inheritance:
.. autoexception:: pubchempy.PubChemPyDeprecationWarning
:show-inheritance:
```
## Changes
- As of v1.0.3, the `atoms` and `bonds` properties on {class}`Compounds <pubchempy.Compound>` now return lists of {class}`~pubchempy.Atom` and {class}`~pubchempy.Bond` objects, rather than dicts.
- As of v1.0.2, search functions now return an empty list instead of raising a {class}`~pubchempy.NotFoundError` exception when no results are found. {class}`~pubchempy.NotFoundError` is still raised when attempting to create a {class}`~pubchempy.Compound` using the `from_cid` class method with an invalid CID.
|