prism-py-sdk 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. prism_py_sdk/__init__.py +214 -0
  2. prism_py_sdk/_default_clients.py +32 -0
  3. prism_py_sdk/client.py +200 -0
  4. prism_py_sdk/core/__init__.py +127 -0
  5. prism_py_sdk/core/api_error.py +23 -0
  6. prism_py_sdk/core/client_wrapper.py +100 -0
  7. prism_py_sdk/core/datetime_utils.py +70 -0
  8. prism_py_sdk/core/file.py +67 -0
  9. prism_py_sdk/core/force_multipart.py +18 -0
  10. prism_py_sdk/core/http_client.py +839 -0
  11. prism_py_sdk/core/http_response.py +59 -0
  12. prism_py_sdk/core/http_sse/__init__.py +42 -0
  13. prism_py_sdk/core/http_sse/_api.py +148 -0
  14. prism_py_sdk/core/http_sse/_decoders.py +61 -0
  15. prism_py_sdk/core/http_sse/_exceptions.py +7 -0
  16. prism_py_sdk/core/http_sse/_models.py +17 -0
  17. prism_py_sdk/core/jsonable_encoder.py +120 -0
  18. prism_py_sdk/core/logging.py +107 -0
  19. prism_py_sdk/core/parse_error.py +36 -0
  20. prism_py_sdk/core/pydantic_utilities.py +634 -0
  21. prism_py_sdk/core/query_encoder.py +58 -0
  22. prism_py_sdk/core/remove_none_from_dict.py +11 -0
  23. prism_py_sdk/core/request_options.py +35 -0
  24. prism_py_sdk/core/serialization.py +276 -0
  25. prism_py_sdk/environment.py +7 -0
  26. prism_py_sdk/errors/__init__.py +44 -0
  27. prism_py_sdk/errors/bad_request_error.py +10 -0
  28. prism_py_sdk/errors/forbidden_error.py +10 -0
  29. prism_py_sdk/errors/internal_server_error.py +10 -0
  30. prism_py_sdk/errors/too_many_requests_error.py +10 -0
  31. prism_py_sdk/errors/unauthorized_error.py +10 -0
  32. prism_py_sdk/py.typed +0 -0
  33. prism_py_sdk/solana/__init__.py +52 -0
  34. prism_py_sdk/solana/client.py +63 -0
  35. prism_py_sdk/solana/dex/__init__.py +49 -0
  36. prism_py_sdk/solana/dex/client.py +1244 -0
  37. prism_py_sdk/solana/dex/raw_client.py +2497 -0
  38. prism_py_sdk/solana/dex/types/__init__.py +47 -0
  39. prism_py_sdk/solana/dex/types/get_swaps_dex_response.py +21 -0
  40. prism_py_sdk/solana/dex/types/get_trades_dex_response.py +21 -0
  41. prism_py_sdk/solana/dex/types/search_token_profiles_dex_response.py +21 -0
  42. prism_py_sdk/solana/dex/types/search_wallet_profiles_dex_response.py +21 -0
  43. prism_py_sdk/solana/raw_client.py +13 -0
  44. prism_py_sdk/types/__init__.py +190 -0
  45. prism_py_sdk/types/bad_request_error_body.py +19 -0
  46. prism_py_sdk/types/forbidden_error_body.py +19 -0
  47. prism_py_sdk/types/internal_server_error_body.py +19 -0
  48. prism_py_sdk/types/paginated_response.py +27 -0
  49. prism_py_sdk/types/payload_pagination.py +27 -0
  50. prism_py_sdk/types/solana_dex_price.py +22 -0
  51. prism_py_sdk/types/solana_dex_price_candle.py +25 -0
  52. prism_py_sdk/types/solana_dex_price_history.py +21 -0
  53. prism_py_sdk/types/solana_dex_price_snapshot.py +21 -0
  54. prism_py_sdk/types/solana_dex_price_stats.py +105 -0
  55. prism_py_sdk/types/solana_dex_profile_dynamic_labels.py +5 -0
  56. prism_py_sdk/types/solana_dex_profile_search_payload_dynamic_labels.py +11 -0
  57. prism_py_sdk/types/solana_dex_profile_search_payload_filter.py +42 -0
  58. prism_py_sdk/types/solana_dex_profile_search_payload_filter_operators.py +68 -0
  59. prism_py_sdk/types/solana_dex_profile_search_payload_filter_operators_eq.py +5 -0
  60. prism_py_sdk/types/solana_dex_profile_search_payload_filter_operators_in_item.py +5 -0
  61. prism_py_sdk/types/solana_dex_profile_search_payload_filter_operators_ne.py +5 -0
  62. prism_py_sdk/types/solana_dex_profile_search_payload_filter_operators_nin_item.py +5 -0
  63. prism_py_sdk/types/solana_dex_profile_search_payload_query.py +41 -0
  64. prism_py_sdk/types/solana_dex_profile_search_payload_sort.py +29 -0
  65. prism_py_sdk/types/solana_dex_profile_search_payload_sort_direction_enum.py +5 -0
  66. prism_py_sdk/types/solana_dex_protocol_field.py +6 -0
  67. prism_py_sdk/types/solana_dex_swap.py +38 -0
  68. prism_py_sdk/types/solana_dex_swap_type_enum.py +7 -0
  69. prism_py_sdk/types/solana_dex_token_profile.py +33 -0
  70. prism_py_sdk/types/solana_dex_token_profile_label_enum.py +5 -0
  71. prism_py_sdk/types/solana_dex_token_profile_labels.py +7 -0
  72. prism_py_sdk/types/solana_dex_token_profile_market.py +27 -0
  73. prism_py_sdk/types/solana_dex_token_profile_metadata.py +30 -0
  74. prism_py_sdk/types/solana_dex_token_profile_metrics.py +64 -0
  75. prism_py_sdk/types/solana_dex_token_profile_payload_options.py +42 -0
  76. prism_py_sdk/types/solana_dex_token_profile_search_payload_query_field.py +42 -0
  77. prism_py_sdk/types/solana_dex_token_profile_search_payload_query_field_targets_enum.py +7 -0
  78. prism_py_sdk/types/solana_dex_token_profile_time_window_enum.py +5 -0
  79. prism_py_sdk/types/solana_dex_trade.py +42 -0
  80. prism_py_sdk/types/solana_dex_trade_direction_enum.py +5 -0
  81. prism_py_sdk/types/solana_dex_trade_position_state_enum.py +5 -0
  82. prism_py_sdk/types/solana_dex_wallet_profile.py +33 -0
  83. prism_py_sdk/types/solana_dex_wallet_profile_identity.py +21 -0
  84. prism_py_sdk/types/solana_dex_wallet_profile_label_enum.py +7 -0
  85. prism_py_sdk/types/solana_dex_wallet_profile_labels.py +7 -0
  86. prism_py_sdk/types/solana_dex_wallet_profile_metadata.py +20 -0
  87. prism_py_sdk/types/solana_dex_wallet_profile_metrics.py +74 -0
  88. prism_py_sdk/types/solana_dex_wallet_profile_payload_options.py +37 -0
  89. prism_py_sdk/types/solana_dex_wallet_profile_search_payload_query.py +42 -0
  90. prism_py_sdk/types/solana_dex_wallet_profile_search_payload_query_targets_enum.py +8 -0
  91. prism_py_sdk/types/solana_dex_wallet_profile_time_window_enum.py +5 -0
  92. prism_py_sdk/types/too_many_requests_error_body.py +19 -0
  93. prism_py_sdk/types/unauthorized_error_body.py +19 -0
  94. prism_py_sdk/version.py +3 -0
  95. prism_py_sdk-1.0.1.dist-info/LICENSE +21 -0
  96. prism_py_sdk-1.0.1.dist-info/METADATA +234 -0
  97. prism_py_sdk-1.0.1.dist-info/RECORD +98 -0
  98. prism_py_sdk-1.0.1.dist-info/WHEEL +4 -0
@@ -0,0 +1,214 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .types import (
10
+ BadRequestErrorBody,
11
+ ForbiddenErrorBody,
12
+ InternalServerErrorBody,
13
+ PaginatedResponse,
14
+ PayloadPagination,
15
+ SolanaDexPrice,
16
+ SolanaDexPriceCandle,
17
+ SolanaDexPriceHistory,
18
+ SolanaDexPriceSnapshot,
19
+ SolanaDexPriceStats,
20
+ SolanaDexProfileDynamicLabels,
21
+ SolanaDexProfileSearchPayloadDynamicLabels,
22
+ SolanaDexProfileSearchPayloadFilter,
23
+ SolanaDexProfileSearchPayloadFilterOperators,
24
+ SolanaDexProfileSearchPayloadFilterOperatorsEq,
25
+ SolanaDexProfileSearchPayloadFilterOperatorsInItem,
26
+ SolanaDexProfileSearchPayloadFilterOperatorsNe,
27
+ SolanaDexProfileSearchPayloadFilterOperatorsNinItem,
28
+ SolanaDexProfileSearchPayloadQuery,
29
+ SolanaDexProfileSearchPayloadSort,
30
+ SolanaDexProfileSearchPayloadSortDirectionEnum,
31
+ SolanaDexProtocolField,
32
+ SolanaDexSwap,
33
+ SolanaDexSwapTypeEnum,
34
+ SolanaDexTokenProfile,
35
+ SolanaDexTokenProfileLabelEnum,
36
+ SolanaDexTokenProfileLabels,
37
+ SolanaDexTokenProfileMarket,
38
+ SolanaDexTokenProfileMetadata,
39
+ SolanaDexTokenProfileMetrics,
40
+ SolanaDexTokenProfilePayloadOptions,
41
+ SolanaDexTokenProfileSearchPayloadQueryField,
42
+ SolanaDexTokenProfileSearchPayloadQueryFieldTargetsEnum,
43
+ SolanaDexTokenProfileTimeWindowEnum,
44
+ SolanaDexTrade,
45
+ SolanaDexTradeDirectionEnum,
46
+ SolanaDexTradePositionStateEnum,
47
+ SolanaDexWalletProfile,
48
+ SolanaDexWalletProfileIdentity,
49
+ SolanaDexWalletProfileLabelEnum,
50
+ SolanaDexWalletProfileLabels,
51
+ SolanaDexWalletProfileMetadata,
52
+ SolanaDexWalletProfileMetrics,
53
+ SolanaDexWalletProfilePayloadOptions,
54
+ SolanaDexWalletProfileSearchPayloadQuery,
55
+ SolanaDexWalletProfileSearchPayloadQueryTargetsEnum,
56
+ SolanaDexWalletProfileTimeWindowEnum,
57
+ TooManyRequestsErrorBody,
58
+ UnauthorizedErrorBody,
59
+ )
60
+ from .errors import BadRequestError, ForbiddenError, InternalServerError, TooManyRequestsError, UnauthorizedError
61
+ from . import solana
62
+ from ._default_clients import DefaultAioHttpClient, DefaultAsyncHttpxClient
63
+ from .client import ApiClient, AsyncApiClient
64
+ from .environment import ApiClientEnvironment
65
+ from .version import __version__
66
+ _dynamic_imports: typing.Dict[str, str] = {
67
+ "ApiClient": ".client",
68
+ "ApiClientEnvironment": ".environment",
69
+ "AsyncApiClient": ".client",
70
+ "BadRequestError": ".errors",
71
+ "BadRequestErrorBody": ".types",
72
+ "DefaultAioHttpClient": "._default_clients",
73
+ "DefaultAsyncHttpxClient": "._default_clients",
74
+ "ForbiddenError": ".errors",
75
+ "ForbiddenErrorBody": ".types",
76
+ "InternalServerError": ".errors",
77
+ "InternalServerErrorBody": ".types",
78
+ "PaginatedResponse": ".types",
79
+ "PayloadPagination": ".types",
80
+ "SolanaDexPrice": ".types",
81
+ "SolanaDexPriceCandle": ".types",
82
+ "SolanaDexPriceHistory": ".types",
83
+ "SolanaDexPriceSnapshot": ".types",
84
+ "SolanaDexPriceStats": ".types",
85
+ "SolanaDexProfileDynamicLabels": ".types",
86
+ "SolanaDexProfileSearchPayloadDynamicLabels": ".types",
87
+ "SolanaDexProfileSearchPayloadFilter": ".types",
88
+ "SolanaDexProfileSearchPayloadFilterOperators": ".types",
89
+ "SolanaDexProfileSearchPayloadFilterOperatorsEq": ".types",
90
+ "SolanaDexProfileSearchPayloadFilterOperatorsInItem": ".types",
91
+ "SolanaDexProfileSearchPayloadFilterOperatorsNe": ".types",
92
+ "SolanaDexProfileSearchPayloadFilterOperatorsNinItem": ".types",
93
+ "SolanaDexProfileSearchPayloadQuery": ".types",
94
+ "SolanaDexProfileSearchPayloadSort": ".types",
95
+ "SolanaDexProfileSearchPayloadSortDirectionEnum": ".types",
96
+ "SolanaDexProtocolField": ".types",
97
+ "SolanaDexSwap": ".types",
98
+ "SolanaDexSwapTypeEnum": ".types",
99
+ "SolanaDexTokenProfile": ".types",
100
+ "SolanaDexTokenProfileLabelEnum": ".types",
101
+ "SolanaDexTokenProfileLabels": ".types",
102
+ "SolanaDexTokenProfileMarket": ".types",
103
+ "SolanaDexTokenProfileMetadata": ".types",
104
+ "SolanaDexTokenProfileMetrics": ".types",
105
+ "SolanaDexTokenProfilePayloadOptions": ".types",
106
+ "SolanaDexTokenProfileSearchPayloadQueryField": ".types",
107
+ "SolanaDexTokenProfileSearchPayloadQueryFieldTargetsEnum": ".types",
108
+ "SolanaDexTokenProfileTimeWindowEnum": ".types",
109
+ "SolanaDexTrade": ".types",
110
+ "SolanaDexTradeDirectionEnum": ".types",
111
+ "SolanaDexTradePositionStateEnum": ".types",
112
+ "SolanaDexWalletProfile": ".types",
113
+ "SolanaDexWalletProfileIdentity": ".types",
114
+ "SolanaDexWalletProfileLabelEnum": ".types",
115
+ "SolanaDexWalletProfileLabels": ".types",
116
+ "SolanaDexWalletProfileMetadata": ".types",
117
+ "SolanaDexWalletProfileMetrics": ".types",
118
+ "SolanaDexWalletProfilePayloadOptions": ".types",
119
+ "SolanaDexWalletProfileSearchPayloadQuery": ".types",
120
+ "SolanaDexWalletProfileSearchPayloadQueryTargetsEnum": ".types",
121
+ "SolanaDexWalletProfileTimeWindowEnum": ".types",
122
+ "TooManyRequestsError": ".errors",
123
+ "TooManyRequestsErrorBody": ".types",
124
+ "UnauthorizedError": ".errors",
125
+ "UnauthorizedErrorBody": ".types",
126
+ "__version__": ".version",
127
+ "solana": ".solana",
128
+ }
129
+
130
+
131
+ def __getattr__(attr_name: str) -> typing.Any:
132
+ module_name = _dynamic_imports.get(attr_name)
133
+ if module_name is None:
134
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
135
+ try:
136
+ module = import_module(module_name, __package__)
137
+ if module_name == f".{attr_name}":
138
+ return module
139
+ else:
140
+ return getattr(module, attr_name)
141
+ except ImportError as e:
142
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
143
+ except AttributeError as e:
144
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
145
+
146
+
147
+ def __dir__():
148
+ lazy_attrs = list(_dynamic_imports.keys())
149
+ return sorted(lazy_attrs)
150
+
151
+
152
+ __all__ = [
153
+ "ApiClient",
154
+ "ApiClientEnvironment",
155
+ "AsyncApiClient",
156
+ "BadRequestError",
157
+ "BadRequestErrorBody",
158
+ "DefaultAioHttpClient",
159
+ "DefaultAsyncHttpxClient",
160
+ "ForbiddenError",
161
+ "ForbiddenErrorBody",
162
+ "InternalServerError",
163
+ "InternalServerErrorBody",
164
+ "PaginatedResponse",
165
+ "PayloadPagination",
166
+ "SolanaDexPrice",
167
+ "SolanaDexPriceCandle",
168
+ "SolanaDexPriceHistory",
169
+ "SolanaDexPriceSnapshot",
170
+ "SolanaDexPriceStats",
171
+ "SolanaDexProfileDynamicLabels",
172
+ "SolanaDexProfileSearchPayloadDynamicLabels",
173
+ "SolanaDexProfileSearchPayloadFilter",
174
+ "SolanaDexProfileSearchPayloadFilterOperators",
175
+ "SolanaDexProfileSearchPayloadFilterOperatorsEq",
176
+ "SolanaDexProfileSearchPayloadFilterOperatorsInItem",
177
+ "SolanaDexProfileSearchPayloadFilterOperatorsNe",
178
+ "SolanaDexProfileSearchPayloadFilterOperatorsNinItem",
179
+ "SolanaDexProfileSearchPayloadQuery",
180
+ "SolanaDexProfileSearchPayloadSort",
181
+ "SolanaDexProfileSearchPayloadSortDirectionEnum",
182
+ "SolanaDexProtocolField",
183
+ "SolanaDexSwap",
184
+ "SolanaDexSwapTypeEnum",
185
+ "SolanaDexTokenProfile",
186
+ "SolanaDexTokenProfileLabelEnum",
187
+ "SolanaDexTokenProfileLabels",
188
+ "SolanaDexTokenProfileMarket",
189
+ "SolanaDexTokenProfileMetadata",
190
+ "SolanaDexTokenProfileMetrics",
191
+ "SolanaDexTokenProfilePayloadOptions",
192
+ "SolanaDexTokenProfileSearchPayloadQueryField",
193
+ "SolanaDexTokenProfileSearchPayloadQueryFieldTargetsEnum",
194
+ "SolanaDexTokenProfileTimeWindowEnum",
195
+ "SolanaDexTrade",
196
+ "SolanaDexTradeDirectionEnum",
197
+ "SolanaDexTradePositionStateEnum",
198
+ "SolanaDexWalletProfile",
199
+ "SolanaDexWalletProfileIdentity",
200
+ "SolanaDexWalletProfileLabelEnum",
201
+ "SolanaDexWalletProfileLabels",
202
+ "SolanaDexWalletProfileMetadata",
203
+ "SolanaDexWalletProfileMetrics",
204
+ "SolanaDexWalletProfilePayloadOptions",
205
+ "SolanaDexWalletProfileSearchPayloadQuery",
206
+ "SolanaDexWalletProfileSearchPayloadQueryTargetsEnum",
207
+ "SolanaDexWalletProfileTimeWindowEnum",
208
+ "TooManyRequestsError",
209
+ "TooManyRequestsErrorBody",
210
+ "UnauthorizedError",
211
+ "UnauthorizedErrorBody",
212
+ "__version__",
213
+ "solana",
214
+ ]
@@ -0,0 +1,32 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ import httpx
6
+
7
+ SDK_DEFAULT_TIMEOUT = 60
8
+
9
+ try:
10
+ import httpx_aiohttp # type: ignore[import-not-found]
11
+ except ImportError:
12
+
13
+ class DefaultAioHttpClient(httpx.AsyncClient): # type: ignore
14
+ def __init__(self, **kwargs: typing.Any) -> None:
15
+ raise RuntimeError(
16
+ "To use the aiohttp client, install the aiohttp extra: pip install prism-py-sdk[aiohttp]"
17
+ )
18
+
19
+ else:
20
+
21
+ class DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
22
+ def __init__(self, **kwargs: typing.Any) -> None:
23
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
24
+ kwargs.setdefault("follow_redirects", True)
25
+ super().__init__(**kwargs)
26
+
27
+
28
+ class DefaultAsyncHttpxClient(httpx.AsyncClient):
29
+ def __init__(self, **kwargs: typing.Any) -> None:
30
+ kwargs.setdefault("timeout", SDK_DEFAULT_TIMEOUT)
31
+ kwargs.setdefault("follow_redirects", True)
32
+ super().__init__(**kwargs)
prism_py_sdk/client.py ADDED
@@ -0,0 +1,200 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from __future__ import annotations
4
+
5
+ import typing
6
+
7
+ import httpx
8
+ from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
+ from .core.logging import LogConfig, Logger
10
+ from .environment import ApiClientEnvironment
11
+
12
+ if typing.TYPE_CHECKING:
13
+ from .solana.client import AsyncSolanaClient, SolanaClient
14
+
15
+
16
+ class ApiClient:
17
+ """
18
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
19
+
20
+ Parameters
21
+ ----------
22
+ base_url : typing.Optional[str]
23
+ The base url to use for requests from the client.
24
+
25
+ environment : ApiClientEnvironment
26
+ The environment to use for requests from the client. from .environment import ApiClientEnvironment
27
+
28
+
29
+
30
+ Defaults to ApiClientEnvironment.DEFAULT
31
+
32
+
33
+
34
+ api_key : str
35
+ headers : typing.Optional[typing.Dict[str, str]]
36
+ Additional headers to send with every request.
37
+
38
+ timeout : typing.Optional[float]
39
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
40
+
41
+ follow_redirects : typing.Optional[bool]
42
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
43
+
44
+ httpx_client : typing.Optional[httpx.Client]
45
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
46
+
47
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
48
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
49
+
50
+ Examples
51
+ --------
52
+ from prism_py_sdk import ApiClient
53
+
54
+ client = ApiClient(
55
+ api_key="YOUR_API_KEY",
56
+ )
57
+ """
58
+
59
+ def __init__(
60
+ self,
61
+ *,
62
+ base_url: typing.Optional[str] = None,
63
+ environment: ApiClientEnvironment = ApiClientEnvironment.DEFAULT,
64
+ api_key: str,
65
+ headers: typing.Optional[typing.Dict[str, str]] = None,
66
+ timeout: typing.Optional[float] = None,
67
+ follow_redirects: typing.Optional[bool] = True,
68
+ httpx_client: typing.Optional[httpx.Client] = None,
69
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
70
+ ):
71
+ _defaulted_timeout = (
72
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
73
+ )
74
+ self._client_wrapper = SyncClientWrapper(
75
+ base_url=_get_base_url(base_url=base_url, environment=environment),
76
+ api_key=api_key,
77
+ headers=headers,
78
+ httpx_client=httpx_client
79
+ if httpx_client is not None
80
+ else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
81
+ if follow_redirects is not None
82
+ else httpx.Client(timeout=_defaulted_timeout),
83
+ timeout=_defaulted_timeout,
84
+ logging=logging,
85
+ )
86
+ self._solana: typing.Optional[SolanaClient] = None
87
+
88
+ @property
89
+ def solana(self):
90
+ if self._solana is None:
91
+ from .solana.client import SolanaClient # noqa: E402
92
+
93
+ self._solana = SolanaClient(client_wrapper=self._client_wrapper)
94
+ return self._solana
95
+
96
+
97
+ def _make_default_async_client(
98
+ timeout: typing.Optional[float],
99
+ follow_redirects: typing.Optional[bool],
100
+ ) -> httpx.AsyncClient:
101
+ try:
102
+ import httpx_aiohttp # type: ignore[import-not-found]
103
+ except ImportError:
104
+ pass
105
+ else:
106
+ if follow_redirects is not None:
107
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout, follow_redirects=follow_redirects)
108
+ return httpx_aiohttp.HttpxAiohttpClient(timeout=timeout)
109
+
110
+ if follow_redirects is not None:
111
+ return httpx.AsyncClient(timeout=timeout, follow_redirects=follow_redirects)
112
+ return httpx.AsyncClient(timeout=timeout)
113
+
114
+
115
+ class AsyncApiClient:
116
+ """
117
+ Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
118
+
119
+ Parameters
120
+ ----------
121
+ base_url : typing.Optional[str]
122
+ The base url to use for requests from the client.
123
+
124
+ environment : ApiClientEnvironment
125
+ The environment to use for requests from the client. from .environment import ApiClientEnvironment
126
+
127
+
128
+
129
+ Defaults to ApiClientEnvironment.DEFAULT
130
+
131
+
132
+
133
+ api_key : str
134
+ headers : typing.Optional[typing.Dict[str, str]]
135
+ Additional headers to send with every request.
136
+
137
+ timeout : typing.Optional[float]
138
+ The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
139
+
140
+ follow_redirects : typing.Optional[bool]
141
+ Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
142
+
143
+ httpx_client : typing.Optional[httpx.AsyncClient]
144
+ The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
145
+
146
+ logging : typing.Optional[typing.Union[LogConfig, Logger]]
147
+ Configure logging for the SDK. Accepts a LogConfig dict with 'level' (debug/info/warn/error), 'logger' (custom logger implementation), and 'silent' (boolean, defaults to True) fields. You can also pass a pre-configured Logger instance.
148
+
149
+ Examples
150
+ --------
151
+ from prism_py_sdk import AsyncApiClient
152
+
153
+ client = AsyncApiClient(
154
+ api_key="YOUR_API_KEY",
155
+ )
156
+ """
157
+
158
+ def __init__(
159
+ self,
160
+ *,
161
+ base_url: typing.Optional[str] = None,
162
+ environment: ApiClientEnvironment = ApiClientEnvironment.DEFAULT,
163
+ api_key: str,
164
+ headers: typing.Optional[typing.Dict[str, str]] = None,
165
+ timeout: typing.Optional[float] = None,
166
+ follow_redirects: typing.Optional[bool] = True,
167
+ httpx_client: typing.Optional[httpx.AsyncClient] = None,
168
+ logging: typing.Optional[typing.Union[LogConfig, Logger]] = None,
169
+ ):
170
+ _defaulted_timeout = (
171
+ timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
172
+ )
173
+ self._client_wrapper = AsyncClientWrapper(
174
+ base_url=_get_base_url(base_url=base_url, environment=environment),
175
+ api_key=api_key,
176
+ headers=headers,
177
+ httpx_client=httpx_client
178
+ if httpx_client is not None
179
+ else _make_default_async_client(timeout=_defaulted_timeout, follow_redirects=follow_redirects),
180
+ timeout=_defaulted_timeout,
181
+ logging=logging,
182
+ )
183
+ self._solana: typing.Optional[AsyncSolanaClient] = None
184
+
185
+ @property
186
+ def solana(self):
187
+ if self._solana is None:
188
+ from .solana.client import AsyncSolanaClient # noqa: E402
189
+
190
+ self._solana = AsyncSolanaClient(client_wrapper=self._client_wrapper)
191
+ return self._solana
192
+
193
+
194
+ def _get_base_url(*, base_url: typing.Optional[str] = None, environment: ApiClientEnvironment) -> str:
195
+ if base_url is not None:
196
+ return base_url
197
+ elif environment is not None:
198
+ return environment.value
199
+ else:
200
+ raise Exception("Please pass in either base_url or environment to construct the client")
@@ -0,0 +1,127 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ import typing
6
+ from importlib import import_module
7
+
8
+ if typing.TYPE_CHECKING:
9
+ from .api_error import ApiError
10
+ from .client_wrapper import AsyncClientWrapper, BaseClientWrapper, SyncClientWrapper
11
+ from .datetime_utils import Rfc2822DateTime, parse_rfc2822_datetime, serialize_datetime
12
+ from .file import File, convert_file_dict_to_httpx_tuples, with_content_type
13
+ from .http_client import AsyncHttpClient, HttpClient
14
+ from .http_response import AsyncHttpResponse, HttpResponse
15
+ from .jsonable_encoder import encode_path_param, jsonable_encoder
16
+ from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger
17
+ from .parse_error import ParsingError
18
+ from .pydantic_utilities import (
19
+ IS_PYDANTIC_V2,
20
+ UniversalBaseModel,
21
+ UniversalRootModel,
22
+ parse_obj_as,
23
+ universal_field_validator,
24
+ universal_root_validator,
25
+ update_forward_refs,
26
+ )
27
+ from .query_encoder import encode_query
28
+ from .remove_none_from_dict import remove_none_from_dict
29
+ from .request_options import RequestOptions
30
+ from .serialization import FieldMetadata, convert_and_respect_annotation_metadata
31
+ _dynamic_imports: typing.Dict[str, str] = {
32
+ "ApiError": ".api_error",
33
+ "AsyncClientWrapper": ".client_wrapper",
34
+ "AsyncHttpClient": ".http_client",
35
+ "AsyncHttpResponse": ".http_response",
36
+ "BaseClientWrapper": ".client_wrapper",
37
+ "ConsoleLogger": ".logging",
38
+ "FieldMetadata": ".serialization",
39
+ "File": ".file",
40
+ "HttpClient": ".http_client",
41
+ "HttpResponse": ".http_response",
42
+ "ILogger": ".logging",
43
+ "IS_PYDANTIC_V2": ".pydantic_utilities",
44
+ "LogConfig": ".logging",
45
+ "LogLevel": ".logging",
46
+ "Logger": ".logging",
47
+ "ParsingError": ".parse_error",
48
+ "RequestOptions": ".request_options",
49
+ "Rfc2822DateTime": ".datetime_utils",
50
+ "SyncClientWrapper": ".client_wrapper",
51
+ "UniversalBaseModel": ".pydantic_utilities",
52
+ "UniversalRootModel": ".pydantic_utilities",
53
+ "convert_and_respect_annotation_metadata": ".serialization",
54
+ "convert_file_dict_to_httpx_tuples": ".file",
55
+ "create_logger": ".logging",
56
+ "encode_path_param": ".jsonable_encoder",
57
+ "encode_query": ".query_encoder",
58
+ "jsonable_encoder": ".jsonable_encoder",
59
+ "parse_obj_as": ".pydantic_utilities",
60
+ "parse_rfc2822_datetime": ".datetime_utils",
61
+ "remove_none_from_dict": ".remove_none_from_dict",
62
+ "serialize_datetime": ".datetime_utils",
63
+ "universal_field_validator": ".pydantic_utilities",
64
+ "universal_root_validator": ".pydantic_utilities",
65
+ "update_forward_refs": ".pydantic_utilities",
66
+ "with_content_type": ".file",
67
+ }
68
+
69
+
70
+ def __getattr__(attr_name: str) -> typing.Any:
71
+ module_name = _dynamic_imports.get(attr_name)
72
+ if module_name is None:
73
+ raise AttributeError(f"No {attr_name} found in _dynamic_imports for module name -> {__name__}")
74
+ try:
75
+ module = import_module(module_name, __package__)
76
+ if module_name == f".{attr_name}":
77
+ return module
78
+ else:
79
+ return getattr(module, attr_name)
80
+ except ImportError as e:
81
+ raise ImportError(f"Failed to import {attr_name} from {module_name}: {e}") from e
82
+ except AttributeError as e:
83
+ raise AttributeError(f"Failed to get {attr_name} from {module_name}: {e}") from e
84
+
85
+
86
+ def __dir__():
87
+ lazy_attrs = list(_dynamic_imports.keys())
88
+ return sorted(lazy_attrs)
89
+
90
+
91
+ __all__ = [
92
+ "ApiError",
93
+ "AsyncClientWrapper",
94
+ "AsyncHttpClient",
95
+ "AsyncHttpResponse",
96
+ "BaseClientWrapper",
97
+ "ConsoleLogger",
98
+ "FieldMetadata",
99
+ "File",
100
+ "HttpClient",
101
+ "HttpResponse",
102
+ "ILogger",
103
+ "IS_PYDANTIC_V2",
104
+ "LogConfig",
105
+ "LogLevel",
106
+ "Logger",
107
+ "ParsingError",
108
+ "RequestOptions",
109
+ "Rfc2822DateTime",
110
+ "SyncClientWrapper",
111
+ "UniversalBaseModel",
112
+ "UniversalRootModel",
113
+ "convert_and_respect_annotation_metadata",
114
+ "convert_file_dict_to_httpx_tuples",
115
+ "create_logger",
116
+ "encode_path_param",
117
+ "encode_query",
118
+ "jsonable_encoder",
119
+ "parse_obj_as",
120
+ "parse_rfc2822_datetime",
121
+ "remove_none_from_dict",
122
+ "serialize_datetime",
123
+ "universal_field_validator",
124
+ "universal_root_validator",
125
+ "update_forward_refs",
126
+ "with_content_type",
127
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from typing import Any, Dict, Optional
4
+
5
+
6
+ class ApiError(Exception):
7
+ headers: Optional[Dict[str, str]]
8
+ status_code: Optional[int]
9
+ body: Any
10
+
11
+ def __init__(
12
+ self,
13
+ *,
14
+ headers: Optional[Dict[str, str]] = None,
15
+ status_code: Optional[int] = None,
16
+ body: Any = None,
17
+ ) -> None:
18
+ self.headers = headers
19
+ self.status_code = status_code
20
+ self.body = body
21
+
22
+ def __str__(self) -> str:
23
+ return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}"