crypticorn 2.1.5__py3-none-any.whl → 2.2.0__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.
- crypticorn/auth/main.py +2 -19
- crypticorn/client.py +75 -22
- crypticorn/common/__init__.py +1 -2
- crypticorn/common/auth.py +205 -1
- crypticorn/common/scopes.py +2 -2
- crypticorn/common/urls.py +21 -9
- crypticorn/hive/main.py +4 -12
- crypticorn/klines/client/configuration.py +2 -2
- crypticorn/klines/main.py +2 -12
- crypticorn/metrics/__init__.py +4 -0
- crypticorn/metrics/client/__init__.py +60 -0
- crypticorn/metrics/client/api/__init__.py +10 -0
- crypticorn/metrics/client/api/exchanges_api.py +1003 -0
- crypticorn/metrics/client/api/health_check_api.py +265 -0
- crypticorn/metrics/client/api/indicators_api.py +680 -0
- crypticorn/metrics/client/api/logs_api.py +356 -0
- crypticorn/metrics/client/api/marketcap_api.py +1315 -0
- crypticorn/metrics/client/api/markets_api.py +618 -0
- crypticorn/metrics/client/api/tokens_api.py +300 -0
- crypticorn/metrics/client/api_client.py +758 -0
- crypticorn/metrics/client/api_response.py +20 -0
- crypticorn/metrics/client/configuration.py +575 -0
- crypticorn/metrics/client/exceptions.py +220 -0
- crypticorn/metrics/client/models/__init__.py +37 -0
- crypticorn/metrics/client/models/base_response_dict.py +106 -0
- crypticorn/metrics/client/models/base_response_health_check_response.py +114 -0
- crypticorn/metrics/client/models/base_response_list_dict.py +106 -0
- crypticorn/metrics/client/models/base_response_list_exchange_mapping.py +118 -0
- crypticorn/metrics/client/models/base_response_list_str.py +106 -0
- crypticorn/metrics/client/models/error_response.py +109 -0
- crypticorn/metrics/client/models/exchange_mapping.py +132 -0
- crypticorn/metrics/client/models/health_check_response.py +91 -0
- crypticorn/metrics/client/models/http_validation_error.py +99 -0
- crypticorn/metrics/client/models/market.py +35 -0
- crypticorn/metrics/client/models/severity.py +36 -0
- crypticorn/metrics/client/models/validation_error.py +105 -0
- crypticorn/metrics/client/models/validation_error_loc_inner.py +159 -0
- crypticorn/metrics/client/py.typed +0 -0
- crypticorn/metrics/client/rest.py +195 -0
- crypticorn/metrics/main.py +102 -0
- crypticorn/pay/main.py +2 -12
- crypticorn/trade/main.py +2 -12
- crypticorn-2.2.0.dist-info/METADATA +146 -0
- {crypticorn-2.1.5.dist-info → crypticorn-2.2.0.dist-info}/RECORD +46 -16
- crypticorn/common/auth_client.py +0 -213
- crypticorn-2.1.5.dist-info/METADATA +0 -92
- {crypticorn-2.1.5.dist-info → crypticorn-2.2.0.dist-info}/WHEEL +0 -0
- {crypticorn-2.1.5.dist-info → crypticorn-2.2.0.dist-info}/top_level.txt +0 -0
crypticorn/auth/main.py
CHANGED
@@ -7,7 +7,6 @@ from crypticorn.auth import (
|
|
7
7
|
WalletApi,
|
8
8
|
AuthApi,
|
9
9
|
)
|
10
|
-
from crypticorn.common import BaseURL, ApiVersion, Service, apikey_header as aph
|
11
10
|
|
12
11
|
|
13
12
|
class AuthClient:
|
@@ -17,19 +16,9 @@ class AuthClient:
|
|
17
16
|
|
18
17
|
def __init__(
|
19
18
|
self,
|
20
|
-
|
21
|
-
api_version: ApiVersion,
|
22
|
-
api_key: str = None,
|
23
|
-
jwt: str = None,
|
19
|
+
config: Configuration,
|
24
20
|
):
|
25
|
-
self.
|
26
|
-
self.config = Configuration(
|
27
|
-
host=self.host,
|
28
|
-
access_token=jwt,
|
29
|
-
api_key={aph.scheme_name: api_key} if api_key else None,
|
30
|
-
api_key_prefix=({aph.scheme_name: aph.model.name} if api_key else None),
|
31
|
-
debug=True,
|
32
|
-
)
|
21
|
+
self.config = config
|
33
22
|
self.base_client = ApiClient(configuration=self.config)
|
34
23
|
# Instantiate all the endpoint clients
|
35
24
|
self.admin = AdminApi(self.base_client)
|
@@ -37,9 +26,3 @@ class AuthClient:
|
|
37
26
|
self.user = UserApi(self.base_client)
|
38
27
|
self.wallet = WalletApi(self.base_client)
|
39
28
|
self.login = AuthApi(self.base_client)
|
40
|
-
|
41
|
-
async def __aenter__(self):
|
42
|
-
return self
|
43
|
-
|
44
|
-
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
45
|
-
await self.base_client.close()
|
crypticorn/client.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
from crypticorn.hive import HiveClient
|
1
|
+
from crypticorn.hive import HiveClient, Configuration
|
2
2
|
from crypticorn.klines import KlinesClient
|
3
3
|
from crypticorn.pay import PayClient
|
4
4
|
from crypticorn.trade import TradeClient
|
5
|
-
from crypticorn.
|
6
|
-
|
7
|
-
|
5
|
+
from crypticorn.metrics import MetricsClient
|
6
|
+
from crypticorn.auth import AuthClient
|
7
|
+
from crypticorn.common import BaseUrl, ApiVersion, Service, apikey_header as aph
|
8
|
+
import warnings
|
8
9
|
class ApiClient:
|
9
10
|
"""
|
10
11
|
The official client for interacting with the Crypticorn API.
|
@@ -14,32 +15,30 @@ class ApiClient:
|
|
14
15
|
|
15
16
|
def __init__(
|
16
17
|
self,
|
17
|
-
base_url: BaseURL = BaseURL.PROD,
|
18
18
|
api_key: str = None,
|
19
19
|
jwt: str = None,
|
20
|
-
|
21
|
-
klines_version: ApiVersion = ApiVersion.V1,
|
22
|
-
pay_version: ApiVersion = ApiVersion.V1,
|
23
|
-
trade_version: ApiVersion = ApiVersion.V1,
|
24
|
-
auth_version: ApiVersion = ApiVersion.V1,
|
20
|
+
base_url: BaseUrl = BaseUrl.PROD,
|
25
21
|
):
|
26
22
|
self.base_url = base_url
|
23
|
+
'''The base URL the client will use to connect to the API.'''
|
27
24
|
self.api_key = api_key
|
25
|
+
'''The API key to use for authentication.'''
|
28
26
|
self.jwt = jwt
|
29
|
-
|
30
|
-
self.trade = TradeClient(base_url, trade_version, api_key, jwt)
|
31
|
-
self.klines = KlinesClient(base_url, klines_version, api_key, jwt)
|
32
|
-
self.pay = PayClient(base_url, pay_version, api_key, jwt)
|
33
|
-
# currently not working due to circular import since the AUTH_Handler
|
34
|
-
# is also using the ApiClient
|
35
|
-
# self.auth = AuthClient(base_url, auth_version, api_key, jwt)
|
27
|
+
'''The JWT to use for authentication.'''
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
self.hive = HiveClient(self._get_default_config(Service.HIVE))
|
30
|
+
self.trade = TradeClient(self._get_default_config(Service.TRADE))
|
31
|
+
self.klines = KlinesClient(self._get_default_config(Service.KLINES))
|
32
|
+
self.pay = PayClient(self._get_default_config(Service.PAY))
|
33
|
+
self.metrics = MetricsClient(self._get_default_config(Service.METRICS))
|
34
|
+
self.auth = AuthClient(self._get_default_config(Service.AUTH))
|
42
35
|
|
36
|
+
def __new__(cls, *args, **kwargs):
|
37
|
+
if kwargs.get("api_key") and not kwargs.get("jwt"):
|
38
|
+
# auth-service does not allow api_key
|
39
|
+
warnings.warn("The auth module does only accept JWT to be used to authenticate. If you use this module, you need to provide a JWT.")
|
40
|
+
return super().__new__(cls)
|
41
|
+
|
43
42
|
async def close(self):
|
44
43
|
"""Close all client sessions."""
|
45
44
|
clients = [
|
@@ -47,8 +46,62 @@ class ApiClient:
|
|
47
46
|
self.trade.base_client,
|
48
47
|
self.klines.base_client,
|
49
48
|
self.pay.base_client,
|
49
|
+
self.metrics.base_client,
|
50
|
+
self.auth.base_client,
|
50
51
|
]
|
51
52
|
|
52
53
|
for client in clients:
|
53
54
|
if hasattr(client, "close"):
|
54
55
|
await client.close()
|
56
|
+
|
57
|
+
def _get_default_config(self, service: Service, version: ApiVersion = ApiVersion.V1):
|
58
|
+
"""
|
59
|
+
Get the default configuration for a given service.
|
60
|
+
"""
|
61
|
+
return Configuration(
|
62
|
+
host=f"{self.base_url}/{version}/{service}",
|
63
|
+
access_token=self.jwt,
|
64
|
+
api_key={aph.scheme_name: self.api_key} if self.api_key else None,
|
65
|
+
api_key_prefix=({aph.scheme_name: aph.model.name} if self.api_key else None),
|
66
|
+
)
|
67
|
+
|
68
|
+
def configure(self, config: Configuration, sub_client: any):
|
69
|
+
"""
|
70
|
+
Update a sub-client's configuration by overriding with the values set in the new config.
|
71
|
+
Useful for testing a specific service against a local server instead of the default proxy.
|
72
|
+
|
73
|
+
:param config: The new configuration to use for the sub-client.
|
74
|
+
:param sub_client: The sub-client to configure.
|
75
|
+
|
76
|
+
Example:
|
77
|
+
This will override the host for the Hive client to connect to http://localhost:8000 instead of the default proxy:
|
78
|
+
>>> async with ApiClient(base_url=BaseUrl.DEV, jwt=jwt) as client:
|
79
|
+
>>> client.configure(config=HiveConfig(host="http://localhost:8000"), sub_client=client.hive)
|
80
|
+
"""
|
81
|
+
new_config = sub_client.config
|
82
|
+
for attr in vars(config):
|
83
|
+
new_value = getattr(config, attr)
|
84
|
+
if new_value is not None:
|
85
|
+
setattr(new_config, attr, new_value)
|
86
|
+
|
87
|
+
if sub_client == self.hive:
|
88
|
+
self.hive = HiveClient(new_config)
|
89
|
+
elif sub_client == self.trade:
|
90
|
+
self.trade = TradeClient(new_config)
|
91
|
+
elif sub_client == self.klines:
|
92
|
+
self.klines = KlinesClient(new_config)
|
93
|
+
elif sub_client == self.pay:
|
94
|
+
self.pay = PayClient(new_config)
|
95
|
+
elif sub_client == self.metrics:
|
96
|
+
self.metrics = MetricsClient(new_config)
|
97
|
+
elif sub_client == self.auth:
|
98
|
+
self.auth = AuthClient(new_config)
|
99
|
+
else:
|
100
|
+
raise ValueError(f"Unknown sub-client: {sub_client}")
|
101
|
+
|
102
|
+
async def __aenter__(self):
|
103
|
+
return self
|
104
|
+
|
105
|
+
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
106
|
+
await self.close()
|
107
|
+
|
crypticorn/common/__init__.py
CHANGED
crypticorn/common/auth.py
CHANGED
@@ -1,6 +1,24 @@
|
|
1
|
-
|
1
|
+
import json
|
2
2
|
|
3
|
+
from crypticorn.auth import Verify200Response, AuthClient, Configuration
|
4
|
+
from crypticorn.auth.client.exceptions import ApiException
|
5
|
+
from crypticorn.common import (
|
6
|
+
ApiError,
|
7
|
+
ApiVersion,
|
8
|
+
BaseUrl,
|
9
|
+
Scope,
|
10
|
+
Service,
|
11
|
+
)
|
12
|
+
from fastapi import Depends, HTTPException, Query, status
|
13
|
+
from fastapi.security import (
|
14
|
+
HTTPAuthorizationCredentials,
|
15
|
+
SecurityScopes,
|
16
|
+
HTTPBearer,
|
17
|
+
APIKeyHeader,
|
18
|
+
)
|
19
|
+
from typing_extensions import Annotated
|
3
20
|
|
21
|
+
# Auth Schemes
|
4
22
|
http_bearer = HTTPBearer(
|
5
23
|
bearerFormat="JWT",
|
6
24
|
auto_error=False,
|
@@ -12,3 +30,189 @@ apikey_header = APIKeyHeader(
|
|
12
30
|
auto_error=False,
|
13
31
|
description="The API key to use for authentication.",
|
14
32
|
)
|
33
|
+
|
34
|
+
# Auth Handler
|
35
|
+
class AuthHandler:
|
36
|
+
"""
|
37
|
+
Middleware for verifying API requests. Verifies the validity of the authentication token, scopes, etc.
|
38
|
+
|
39
|
+
@param base_url: The base URL of the API.
|
40
|
+
@param api_version: The version of the API.
|
41
|
+
"""
|
42
|
+
|
43
|
+
def __init__(
|
44
|
+
self,
|
45
|
+
base_url: BaseUrl = BaseUrl.PROD,
|
46
|
+
):
|
47
|
+
self.url = f"{base_url}/{ApiVersion.V1}/{Service.AUTH}"
|
48
|
+
self.client = AuthClient(Configuration(host=self.url))
|
49
|
+
|
50
|
+
self.no_credentials_exception = HTTPException(
|
51
|
+
status_code=status.HTTP_401_UNAUTHORIZED,
|
52
|
+
detail=ApiError.NO_CREDENTIALS.identifier,
|
53
|
+
)
|
54
|
+
|
55
|
+
async def _verify_api_key(self, api_key: str) -> None:
|
56
|
+
"""
|
57
|
+
Verifies the API key.
|
58
|
+
"""
|
59
|
+
return await self.client.login.verify_api_key(api_key)
|
60
|
+
|
61
|
+
async def _verify_bearer(
|
62
|
+
self, bearer: HTTPAuthorizationCredentials
|
63
|
+
) -> Verify200Response:
|
64
|
+
"""
|
65
|
+
Verifies the bearer token.
|
66
|
+
"""
|
67
|
+
self.client.config.access_token = bearer.credentials
|
68
|
+
return await self.client.login.verify()
|
69
|
+
|
70
|
+
async def _validate_scopes(
|
71
|
+
self, api_scopes: list[Scope], user_scopes: list[Scope]
|
72
|
+
) -> bool:
|
73
|
+
"""
|
74
|
+
Checks if the user scopes are a subset of the API scopes.
|
75
|
+
"""
|
76
|
+
if not set(api_scopes).issubset(user_scopes):
|
77
|
+
raise HTTPException(
|
78
|
+
status_code=status.HTTP_403_FORBIDDEN,
|
79
|
+
detail=ApiError.INSUFFICIENT_SCOPES.identifier,
|
80
|
+
)
|
81
|
+
|
82
|
+
async def _extract_message(self, e: ApiException) -> str:
|
83
|
+
"""
|
84
|
+
Tries to extract the message from the body of the exception.
|
85
|
+
"""
|
86
|
+
try:
|
87
|
+
load = json.loads(e.body)
|
88
|
+
except (json.JSONDecodeError, TypeError):
|
89
|
+
return e.body
|
90
|
+
else:
|
91
|
+
common_keys = ["message"]
|
92
|
+
for key in common_keys:
|
93
|
+
if key in load:
|
94
|
+
return load[key]
|
95
|
+
return load
|
96
|
+
|
97
|
+
async def _handle_exception(self, e: Exception) -> HTTPException:
|
98
|
+
"""
|
99
|
+
Handles exceptions and returns a HTTPException with the appropriate status code and detail.
|
100
|
+
"""
|
101
|
+
if isinstance(e, ApiException):
|
102
|
+
return HTTPException(
|
103
|
+
status_code=e.status,
|
104
|
+
detail=await self._extract_message(e),
|
105
|
+
)
|
106
|
+
elif isinstance(e, HTTPException):
|
107
|
+
return e
|
108
|
+
else:
|
109
|
+
return HTTPException(
|
110
|
+
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
111
|
+
detail=str(e),
|
112
|
+
)
|
113
|
+
|
114
|
+
async def api_key_auth(
|
115
|
+
self,
|
116
|
+
api_key: Annotated[str | None, Depends(apikey_header)] = None,
|
117
|
+
sec: SecurityScopes = SecurityScopes(),
|
118
|
+
) -> Verify200Response:
|
119
|
+
"""
|
120
|
+
Verifies the API key and checks if the user scopes are a subset of the API scopes.
|
121
|
+
Use this function if you only want to allow access via the API key.
|
122
|
+
"""
|
123
|
+
return await self.combined_auth(bearer=None, api_key=api_key, sec=sec)
|
124
|
+
|
125
|
+
async def bearer_auth(
|
126
|
+
self,
|
127
|
+
bearer: Annotated[
|
128
|
+
HTTPAuthorizationCredentials | None,
|
129
|
+
Depends(http_bearer),
|
130
|
+
] = None,
|
131
|
+
sec: SecurityScopes = SecurityScopes(),
|
132
|
+
) -> Verify200Response:
|
133
|
+
"""
|
134
|
+
Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
|
135
|
+
Use this function if you only want to allow access via the bearer token.
|
136
|
+
"""
|
137
|
+
return await self.combined_auth(bearer=bearer, api_key=None, sec=sec)
|
138
|
+
|
139
|
+
async def combined_auth(
|
140
|
+
self,
|
141
|
+
bearer: Annotated[
|
142
|
+
HTTPAuthorizationCredentials | None, Depends(http_bearer)
|
143
|
+
] = None,
|
144
|
+
api_key: Annotated[str | None, Depends(apikey_header)] = None,
|
145
|
+
sec: SecurityScopes = SecurityScopes(),
|
146
|
+
) -> Verify200Response:
|
147
|
+
"""
|
148
|
+
Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
|
149
|
+
Returns early on the first successful verification, otherwise tries all available tokens.
|
150
|
+
Use this function if you want to allow access via either the bearer token or the API key.
|
151
|
+
"""
|
152
|
+
tokens = [bearer, api_key]
|
153
|
+
|
154
|
+
last_error = None
|
155
|
+
for token in tokens:
|
156
|
+
try:
|
157
|
+
if token is None:
|
158
|
+
continue
|
159
|
+
res = None
|
160
|
+
if isinstance(token, str):
|
161
|
+
res = await self._verify_api_key(token)
|
162
|
+
elif isinstance(token, HTTPAuthorizationCredentials):
|
163
|
+
res = await self._verify_bearer(token)
|
164
|
+
if res is None:
|
165
|
+
continue
|
166
|
+
if sec:
|
167
|
+
await self._validate_scopes(sec.scopes, res.scopes)
|
168
|
+
return res
|
169
|
+
|
170
|
+
except Exception as e:
|
171
|
+
last_error = await self._handle_exception(e)
|
172
|
+
continue
|
173
|
+
|
174
|
+
raise last_error or self.no_credentials_exception
|
175
|
+
|
176
|
+
async def ws_api_key_auth(
|
177
|
+
self,
|
178
|
+
api_key: Annotated[str | None, Query()] = None,
|
179
|
+
sec: SecurityScopes = SecurityScopes(),
|
180
|
+
) -> Verify200Response:
|
181
|
+
"""
|
182
|
+
Verifies the API key and checks if the user scopes are a subset of the API scopes.
|
183
|
+
Use this function if you only want to allow access via the API key.
|
184
|
+
"""
|
185
|
+
return await self.api_key_auth(api_key=api_key, sec=sec)
|
186
|
+
|
187
|
+
async def ws_bearer_auth(
|
188
|
+
self,
|
189
|
+
bearer: Annotated[str | None, Query()] = None,
|
190
|
+
sec: SecurityScopes = SecurityScopes(),
|
191
|
+
) -> Verify200Response:
|
192
|
+
"""
|
193
|
+
Verifies the bearer token and checks if the user scopes are a subset of the API scopes.
|
194
|
+
Use this function if you only want to allow access via the bearer token.
|
195
|
+
"""
|
196
|
+
credentials = (
|
197
|
+
HTTPAuthorizationCredentials(scheme="Bearer", credentials=bearer)
|
198
|
+
if bearer
|
199
|
+
else None
|
200
|
+
)
|
201
|
+
return await self.bearer_auth(bearer=credentials, sec=sec)
|
202
|
+
|
203
|
+
async def ws_combined_auth(
|
204
|
+
self,
|
205
|
+
bearer: Annotated[str | None, Query()] = None,
|
206
|
+
api_key: Annotated[str | None, Query()] = None,
|
207
|
+
sec: SecurityScopes = SecurityScopes(),
|
208
|
+
) -> Verify200Response:
|
209
|
+
"""
|
210
|
+
Verifies the bearer token and/or API key and checks if the user scopes are a subset of the API scopes.
|
211
|
+
Use this function if you want to allow access via either the bearer token or the API key.
|
212
|
+
"""
|
213
|
+
credentials = (
|
214
|
+
HTTPAuthorizationCredentials(scheme="Bearer", credentials=bearer)
|
215
|
+
if bearer
|
216
|
+
else None
|
217
|
+
)
|
218
|
+
return await self.combined_auth(bearer=credentials, api_key=api_key, sec=sec)
|
crypticorn/common/scopes.py
CHANGED
crypticorn/common/urls.py
CHANGED
@@ -1,25 +1,37 @@
|
|
1
|
-
from enum import
|
1
|
+
from enum import StrEnum
|
2
2
|
|
3
|
+
class ApiEnv(StrEnum):
|
4
|
+
PROD = "prod"
|
5
|
+
DEV = "dev"
|
6
|
+
LOCAL = "local"
|
7
|
+
DOCKER = "docker"
|
3
8
|
|
4
|
-
class
|
5
|
-
PROD = "crypticorn.com"
|
6
|
-
DEV = "crypticorn.dev"
|
7
|
-
|
8
|
-
|
9
|
-
class BaseURL(Enum):
|
9
|
+
class BaseUrl(StrEnum):
|
10
10
|
PROD = "https://api.crypticorn.com"
|
11
11
|
DEV = "https://api.crypticorn.dev"
|
12
12
|
LOCAL = "http://localhost"
|
13
13
|
DOCKER = "http://host.docker.internal"
|
14
14
|
|
15
|
+
@classmethod
|
16
|
+
def from_env(cls, env: ApiEnv) -> "BaseUrl":
|
17
|
+
if env == ApiEnv.PROD:
|
18
|
+
return cls.PROD
|
19
|
+
elif env == ApiEnv.DEV:
|
20
|
+
return cls.DEV
|
21
|
+
elif env == ApiEnv.LOCAL:
|
22
|
+
return cls.LOCAL
|
23
|
+
elif env == ApiEnv.DOCKER:
|
24
|
+
return cls.DOCKER
|
25
|
+
|
15
26
|
|
16
|
-
class ApiVersion(
|
27
|
+
class ApiVersion(StrEnum):
|
17
28
|
V1 = "v1"
|
18
29
|
|
19
30
|
|
20
|
-
class Service(
|
31
|
+
class Service(StrEnum):
|
21
32
|
HIVE = "hive"
|
22
33
|
KLINES = "klines"
|
23
34
|
PAY = "pay"
|
24
35
|
TRADE = "trade"
|
25
36
|
AUTH = "auth"
|
37
|
+
METRICS = "metrics"
|
crypticorn/hive/main.py
CHANGED
@@ -4,8 +4,9 @@ from crypticorn.hive import (
|
|
4
4
|
ModelsApi,
|
5
5
|
DataApi,
|
6
6
|
StatusApi,
|
7
|
+
Configuration,
|
7
8
|
)
|
8
|
-
from crypticorn.common import
|
9
|
+
from crypticorn.common import apikey_header as aph
|
9
10
|
|
10
11
|
|
11
12
|
class HiveClient:
|
@@ -15,18 +16,9 @@ class HiveClient:
|
|
15
16
|
|
16
17
|
def __init__(
|
17
18
|
self,
|
18
|
-
|
19
|
-
api_version: ApiVersion,
|
20
|
-
api_key: str = None,
|
21
|
-
jwt: str = None,
|
19
|
+
config: Configuration,
|
22
20
|
):
|
23
|
-
self.
|
24
|
-
self.config = Configuration(
|
25
|
-
host=self.host,
|
26
|
-
access_token=jwt,
|
27
|
-
api_key={aph.scheme_name: api_key} if api_key else None,
|
28
|
-
api_key_prefix=({aph.scheme_name: aph.model.name} if api_key else None),
|
29
|
-
)
|
21
|
+
self.config = config
|
30
22
|
self.base_client = ApiClient(configuration=self.config)
|
31
23
|
# Instantiate all the endpoint clients
|
32
24
|
self.models = ModelsApi(self.base_client)
|
@@ -191,7 +191,7 @@ class Configuration:
|
|
191
191
|
) -> None:
|
192
192
|
"""Constructor"""
|
193
193
|
self._base_path = (
|
194
|
-
"
|
194
|
+
"http://localhost/v1/klines" if host is None else host
|
195
195
|
)
|
196
196
|
"""Default Base url
|
197
197
|
"""
|
@@ -516,7 +516,7 @@ class Configuration:
|
|
516
516
|
"""
|
517
517
|
return [
|
518
518
|
{
|
519
|
-
"url": "
|
519
|
+
"url": "http://localhost/v1/klines",
|
520
520
|
"description": "No description provided",
|
521
521
|
}
|
522
522
|
]
|
crypticorn/klines/main.py
CHANGED
@@ -8,7 +8,6 @@ from crypticorn.klines import (
|
|
8
8
|
SymbolsApi,
|
9
9
|
UDFApi,
|
10
10
|
)
|
11
|
-
from crypticorn.common import BaseURL, ApiVersion, Service, apikey_header as aph
|
12
11
|
|
13
12
|
|
14
13
|
class FundingRatesApiWrapper(FundingRatesApi):
|
@@ -58,18 +57,9 @@ class KlinesClient:
|
|
58
57
|
|
59
58
|
def __init__(
|
60
59
|
self,
|
61
|
-
|
62
|
-
api_version: ApiVersion,
|
63
|
-
api_key: str = None,
|
64
|
-
jwt: str = None,
|
60
|
+
config: Configuration,
|
65
61
|
):
|
66
|
-
self.
|
67
|
-
self.config = Configuration(
|
68
|
-
host=self.host,
|
69
|
-
access_token=jwt,
|
70
|
-
api_key={aph.scheme_name: api_key} if api_key else None,
|
71
|
-
api_key_prefix=({aph.scheme_name: aph.model.name} if api_key else None),
|
72
|
-
)
|
62
|
+
self.config = config
|
73
63
|
self.base_client = ApiClient(configuration=self.config)
|
74
64
|
# Instantiate all the endpoint clients
|
75
65
|
self.funding = FundingRatesApiWrapper(self.base_client)
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# flake8: noqa
|
4
|
+
|
5
|
+
"""
|
6
|
+
Marketcap Service API
|
7
|
+
|
8
|
+
API for retrieving historical marketcap data, available exchanges, and indicators. ## Features - Historical marketcap data - OHLCV data with marketcap - Technical indicators (KER, SMA) - Exchange and symbol mappings - Error logs
|
9
|
+
|
10
|
+
The version of the OpenAPI document: 1.0.0
|
11
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
12
|
+
|
13
|
+
Do not edit the class manually.
|
14
|
+
""" # noqa: E501
|
15
|
+
|
16
|
+
|
17
|
+
__version__ = "1.0.0"
|
18
|
+
|
19
|
+
# import apis into sdk package
|
20
|
+
from crypticorn.metrics.client.api.exchanges_api import ExchangesApi
|
21
|
+
from crypticorn.metrics.client.api.health_check_api import HealthCheckApi
|
22
|
+
from crypticorn.metrics.client.api.indicators_api import IndicatorsApi
|
23
|
+
from crypticorn.metrics.client.api.logs_api import LogsApi
|
24
|
+
from crypticorn.metrics.client.api.marketcap_api import MarketcapApi
|
25
|
+
from crypticorn.metrics.client.api.markets_api import MarketsApi
|
26
|
+
from crypticorn.metrics.client.api.tokens_api import TokensApi
|
27
|
+
|
28
|
+
# import ApiClient
|
29
|
+
from crypticorn.metrics.client.api_response import ApiResponse
|
30
|
+
from crypticorn.metrics.client.api_client import ApiClient
|
31
|
+
from crypticorn.metrics.client.configuration import Configuration
|
32
|
+
from crypticorn.metrics.client.exceptions import OpenApiException
|
33
|
+
from crypticorn.metrics.client.exceptions import ApiTypeError
|
34
|
+
from crypticorn.metrics.client.exceptions import ApiValueError
|
35
|
+
from crypticorn.metrics.client.exceptions import ApiKeyError
|
36
|
+
from crypticorn.metrics.client.exceptions import ApiAttributeError
|
37
|
+
from crypticorn.metrics.client.exceptions import ApiException
|
38
|
+
|
39
|
+
# import models into sdk package
|
40
|
+
from crypticorn.metrics.client.models.base_response_dict import BaseResponseDict
|
41
|
+
from crypticorn.metrics.client.models.base_response_health_check_response import (
|
42
|
+
BaseResponseHealthCheckResponse,
|
43
|
+
)
|
44
|
+
from crypticorn.metrics.client.models.base_response_list_dict import (
|
45
|
+
BaseResponseListDict,
|
46
|
+
)
|
47
|
+
from crypticorn.metrics.client.models.base_response_list_exchange_mapping import (
|
48
|
+
BaseResponseListExchangeMapping,
|
49
|
+
)
|
50
|
+
from crypticorn.metrics.client.models.base_response_list_str import BaseResponseListStr
|
51
|
+
from crypticorn.metrics.client.models.error_response import ErrorResponse
|
52
|
+
from crypticorn.metrics.client.models.exchange_mapping import ExchangeMapping
|
53
|
+
from crypticorn.metrics.client.models.http_validation_error import HTTPValidationError
|
54
|
+
from crypticorn.metrics.client.models.health_check_response import HealthCheckResponse
|
55
|
+
from crypticorn.metrics.client.models.market import Market
|
56
|
+
from crypticorn.metrics.client.models.severity import Severity
|
57
|
+
from crypticorn.metrics.client.models.validation_error import ValidationError
|
58
|
+
from crypticorn.metrics.client.models.validation_error_loc_inner import (
|
59
|
+
ValidationErrorLocInner,
|
60
|
+
)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# flake8: noqa
|
2
|
+
|
3
|
+
# import apis into api package
|
4
|
+
from crypticorn.metrics.client.api.exchanges_api import ExchangesApi
|
5
|
+
from crypticorn.metrics.client.api.health_check_api import HealthCheckApi
|
6
|
+
from crypticorn.metrics.client.api.indicators_api import IndicatorsApi
|
7
|
+
from crypticorn.metrics.client.api.logs_api import LogsApi
|
8
|
+
from crypticorn.metrics.client.api.marketcap_api import MarketcapApi
|
9
|
+
from crypticorn.metrics.client.api.markets_api import MarketsApi
|
10
|
+
from crypticorn.metrics.client.api.tokens_api import TokensApi
|