Debian Codegraph @

docs/api.md

raw
1 ---
2 tocdepth: '3'
3 ---
4
5 (api)=
6
7 # API documentation
8
9 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.
10
11 ```{eval-rst}
12 .. module:: pubchempy
13 ```
14
15 ## Search functions
16
17 ```{eval-rst}
18 .. autofunction:: get_compounds
19 .. autofunction:: get_substances
20 .. autofunction:: get_assays
21 .. autofunction:: get_properties
22 .. autofunction:: get_synonyms
23 ```
24
25 ## Objects
26
27 The PubChem database is organized into three main record types:
28
29 - **Substances**: Raw chemical records deposited by data contributors.
30 - **Compounds**: Standardized and deduplicated chemical records derived from substances.
31 - **Assays**: Experimental data from biological screening and testing.
32
33 PubChemPy has classes to represent each of these record types.
34
35 ```{eval-rst}
36 .. autoclass:: pubchempy.Compound
37 :members:
38 .. autoclass:: pubchempy.Atom
39 :members:
40 .. autoclass:: pubchempy.Bond
41 :members:
42 .. autoclass:: pubchempy.Substance
43 :members:
44 .. autoclass:: pubchempy.Assay
45 :members:
46 ```
47
48 ## Identifier functions
49
50 ```{eval-rst}
51 .. autofunction:: get_cids
52 .. autofunction:: get_sids
53 .. autofunction:: get_aids
54 ```
55
56 ## Request functions
57
58 ```{eval-rst}
59 .. autofunction:: download
60 .. autofunction:: request
61 .. autofunction:: get
62 .. autofunction:: get_json
63 .. autofunction:: get_sdf
64 ```
65
66 ## *pandas* functions
67
68 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.
69
70 If you already have a list of Compounds or Substances, the functions below allow a {class}`~pandas.DataFrame` to be constructed easily.
71
72 ```{eval-rst}
73 .. autofunction:: compounds_to_frame
74 .. autofunction:: substances_to_frame
75 ```
76
77 ## Constants
78
79 ```{eval-rst}
80 .. autodata:: pubchempy.API_BASE
81 .. autodata:: pubchempy.ELEMENTS
82 .. autodata:: pubchempy.PROPERTY_MAP
83 .. autoclass:: pubchempy.CompoundIdType
84 :members:
85 .. autoclass:: pubchempy.BondType
86 :members:
87 .. autoclass:: pubchempy.CoordinateType
88 :members:
89 .. autoclass:: pubchempy.ProjectCategory
90 :members:
91 ```
92
93 ## Exceptions
94
95 ```{eval-rst}
96 .. autoexception:: pubchempy.PubChemPyError
97 :show-inheritance:
98 .. autoexception:: pubchempy.ResponseParseError
99 :show-inheritance:
100 .. autoexception:: pubchempy.PubChemHTTPError
101 :show-inheritance:
102 .. autoexception:: pubchempy.BadRequestError
103 :show-inheritance:
104 .. autoexception:: pubchempy.NotFoundError
105 :show-inheritance:
106 .. autoexception:: pubchempy.MethodNotAllowedError
107 :show-inheritance:
108 .. autoexception:: pubchempy.ServerError
109 :show-inheritance:
110 .. autoexception:: pubchempy.UnimplementedError
111 :show-inheritance:
112 .. autoexception:: pubchempy.ServerBusyError
113 :show-inheritance:
114 .. autoexception:: pubchempy.TimeoutError
115 :show-inheritance:
116 .. autoexception:: pubchempy.PubChemPyDeprecationWarning
117 :show-inheritance:
118 ```
119
120 ## Changes
121
122 - 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.
123 - 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.