fragment-api-py 1.0.0__tar.gz
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.
- fragment_api_py-1.0.0/FragmentAPI/__init__.py +11 -0
- fragment_api_py-1.0.0/FragmentAPI/api.py +295 -0
- fragment_api_py-1.0.0/FragmentAPI/exceptions.py +13 -0
- fragment_api_py-1.0.0/FragmentAPI/models.py +59 -0
- fragment_api_py-1.0.0/FragmentAPI/utils.py +55 -0
- fragment_api_py-1.0.0/LICENSE +0 -0
- fragment_api_py-1.0.0/PKG-INFO +60 -0
- fragment_api_py-1.0.0/PYPI_README.md +38 -0
- fragment_api_py-1.0.0/README.md +75 -0
- fragment_api_py-1.0.0/fragment_api_py.egg-info/PKG-INFO +60 -0
- fragment_api_py-1.0.0/fragment_api_py.egg-info/SOURCES.txt +15 -0
- fragment_api_py-1.0.0/fragment_api_py.egg-info/dependency_links.txt +1 -0
- fragment_api_py-1.0.0/fragment_api_py.egg-info/requires.txt +4 -0
- fragment_api_py-1.0.0/fragment_api_py.egg-info/top_level.txt +1 -0
- fragment_api_py-1.0.0/pyproject.toml +26 -0
- fragment_api_py-1.0.0/setup.cfg +4 -0
- fragment_api_py-1.0.0/setup.py +32 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
from typing import Optional, Dict, Any
|
|
2
|
+
from .models import FragmentSession, FragmentAPIError
|
|
3
|
+
from .utils import make_request, handle_api_error
|
|
4
|
+
from .exceptions import FragmentAuthError, FragmentOrderError, FragmentPaymentError
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
class FragmentAPI:
|
|
8
|
+
def __init__(self, api_url: str = "https://fragment-api.net"):
|
|
9
|
+
if not isinstance(api_url, str) or not api_url.startswith(('http://', 'https://')):
|
|
10
|
+
api_url = f'https://{api_url}'
|
|
11
|
+
self.api_url = api_url.rstrip('/') + '/'
|
|
12
|
+
self.session = None
|
|
13
|
+
|
|
14
|
+
def _make_request(self, method: str, endpoint: str,
|
|
15
|
+
params: Optional[dict] = None,
|
|
16
|
+
json_data: Optional[dict] = None) -> Dict[str, Any]:
|
|
17
|
+
return make_request(self.api_url, method, endpoint, params, json_data)
|
|
18
|
+
|
|
19
|
+
def save_session(self, filename: str = "fragment_session.json"):
|
|
20
|
+
if self.session:
|
|
21
|
+
self.session.save_to_file(filename)
|
|
22
|
+
|
|
23
|
+
def load_session(self, filename: str = "fragment_session.json"):
|
|
24
|
+
self.session = FragmentSession.load_from_file(filename)
|
|
25
|
+
return self.session
|
|
26
|
+
|
|
27
|
+
def auth(self) -> 'FragmentAuth':
|
|
28
|
+
return FragmentAuth(self)
|
|
29
|
+
|
|
30
|
+
def general(self) -> 'FragmentGeneral':
|
|
31
|
+
return FragmentGeneral(self)
|
|
32
|
+
|
|
33
|
+
def premium(self) -> 'FragmentPremium':
|
|
34
|
+
return FragmentPremium(self)
|
|
35
|
+
|
|
36
|
+
def stars(self) -> 'FragmentStars':
|
|
37
|
+
return FragmentStars(self)
|
|
38
|
+
|
|
39
|
+
def ton(self) -> 'FragmentTON':
|
|
40
|
+
return FragmentTON(self)
|
|
41
|
+
|
|
42
|
+
class FragmentAuth:
|
|
43
|
+
def __init__(self, api: FragmentAPI):
|
|
44
|
+
self.api = api
|
|
45
|
+
|
|
46
|
+
def create_auth_key(self, fragment_cookies: str, seed: str) -> FragmentSession:
|
|
47
|
+
data = {
|
|
48
|
+
"fragment_cookies": fragment_cookies,
|
|
49
|
+
"seed": seed
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try:
|
|
53
|
+
response = self.api._make_request("POST", "/v2/auth", json_data=data)
|
|
54
|
+
|
|
55
|
+
if not response.get("success"):
|
|
56
|
+
raise FragmentAuthError(
|
|
57
|
+
FragmentErrorType.INVALID_FRAGMENT_COOKIES,
|
|
58
|
+
"Failed to create auth key",
|
|
59
|
+
400,
|
|
60
|
+
response
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# Создаем и сохраняем сессию
|
|
64
|
+
self.api.session = FragmentSession(
|
|
65
|
+
auth_key=response["auth_key"],
|
|
66
|
+
fragment_cookies=fragment_cookies
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return self.api.session
|
|
70
|
+
|
|
71
|
+
except FragmentAPIError as e:
|
|
72
|
+
if "Invalid fragment_cookies" in str(e):
|
|
73
|
+
e = FragmentAuthError(
|
|
74
|
+
FragmentErrorType.INVALID_FRAGMENT_COOKIES,
|
|
75
|
+
str(e),
|
|
76
|
+
e.status_code,
|
|
77
|
+
e.details
|
|
78
|
+
)
|
|
79
|
+
raise e
|
|
80
|
+
|
|
81
|
+
class FragmentGeneral:
|
|
82
|
+
def __init__(self, api: FragmentAPI):
|
|
83
|
+
self.api = api
|
|
84
|
+
|
|
85
|
+
def ping(self) -> dict:
|
|
86
|
+
return self.api._make_request("GET", "/v2/ping")
|
|
87
|
+
|
|
88
|
+
def get_balance(self, auth_key: Optional[str] = None) -> dict:
|
|
89
|
+
"""
|
|
90
|
+
Получить баланс кошелька
|
|
91
|
+
"""
|
|
92
|
+
if auth_key is None:
|
|
93
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
94
|
+
raise FragmentAuthError(
|
|
95
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
96
|
+
"No auth key provided and no active session",
|
|
97
|
+
401
|
|
98
|
+
)
|
|
99
|
+
auth_key = self.api.session.auth_key
|
|
100
|
+
wallet_type = self.api.session.wallet_type
|
|
101
|
+
else:
|
|
102
|
+
wallet_type = "v4r2"
|
|
103
|
+
|
|
104
|
+
params = {
|
|
105
|
+
"auth_key": auth_key,
|
|
106
|
+
"wallet_type": wallet_type
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
response = self.api._make_request("GET", "/v2/getBalance", params=params)
|
|
110
|
+
|
|
111
|
+
# Обновляем баланс в сессии
|
|
112
|
+
if self.api.session and response.get("success"):
|
|
113
|
+
self.api.session.last_balance = response.get("balance")
|
|
114
|
+
|
|
115
|
+
return response
|
|
116
|
+
|
|
117
|
+
def get_user_info(self, username: str, auth_key: Optional[str] = None) -> dict:
|
|
118
|
+
if auth_key is None:
|
|
119
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
120
|
+
raise FragmentAuthError(
|
|
121
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
122
|
+
"No auth key provided and no active session",
|
|
123
|
+
401
|
|
124
|
+
)
|
|
125
|
+
auth_key = self.api.session.auth_key
|
|
126
|
+
|
|
127
|
+
params = {
|
|
128
|
+
"username": username,
|
|
129
|
+
"auth_key": auth_key
|
|
130
|
+
}
|
|
131
|
+
return self.api._make_request("GET", "/v2/getUserInfo", params=params)
|
|
132
|
+
|
|
133
|
+
def get_orders(self, auth_key: Optional[str] = None, limit: int = 10, offset: int = 0) -> dict:
|
|
134
|
+
if auth_key is None:
|
|
135
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
136
|
+
raise FragmentAuthError(
|
|
137
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
138
|
+
"No auth key provided and no active session",
|
|
139
|
+
401
|
|
140
|
+
)
|
|
141
|
+
auth_key = self.api.session.auth_key
|
|
142
|
+
|
|
143
|
+
params = {
|
|
144
|
+
"auth_key": auth_key,
|
|
145
|
+
"limit": limit,
|
|
146
|
+
"offset": offset
|
|
147
|
+
}
|
|
148
|
+
return self.api._make_request("GET", "/v2/getOrders", params=params)
|
|
149
|
+
|
|
150
|
+
class FragmentPremium:
|
|
151
|
+
def __init__(self, api: FragmentAPI):
|
|
152
|
+
self.api = api
|
|
153
|
+
|
|
154
|
+
def create_premium_order(self, username: str, duration: int,
|
|
155
|
+
auth_key: Optional[str] = None,
|
|
156
|
+
show_sender: bool = False) -> dict:
|
|
157
|
+
if auth_key is None:
|
|
158
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
159
|
+
raise FragmentAuthError(
|
|
160
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
161
|
+
"No auth key provided and no active session",
|
|
162
|
+
401
|
|
163
|
+
)
|
|
164
|
+
auth_key = self.api.session.auth_key
|
|
165
|
+
|
|
166
|
+
data = {
|
|
167
|
+
"username": username,
|
|
168
|
+
"duration": duration,
|
|
169
|
+
"auth_key": auth_key,
|
|
170
|
+
"show_sender": show_sender
|
|
171
|
+
}
|
|
172
|
+
return self.api._make_request("POST", "/v2/buyPremium/create", json_data=data)
|
|
173
|
+
|
|
174
|
+
def pay_premium_order(self, order_uuid: str, cost: float,
|
|
175
|
+
auth_key: Optional[str] = None,
|
|
176
|
+
wallet_type: Optional[str] = None) -> dict:
|
|
177
|
+
if auth_key is None:
|
|
178
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
179
|
+
raise FragmentAuthError(
|
|
180
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
181
|
+
"No auth key provided and no active session",
|
|
182
|
+
401
|
|
183
|
+
)
|
|
184
|
+
auth_key = self.api.session.auth_key
|
|
185
|
+
wallet_type = self.api.session.wallet_type
|
|
186
|
+
|
|
187
|
+
data = {
|
|
188
|
+
"order_uuid": order_uuid,
|
|
189
|
+
"auth_key": auth_key,
|
|
190
|
+
"cost": cost,
|
|
191
|
+
"wallet_type": wallet_type or "v4r2"
|
|
192
|
+
}
|
|
193
|
+
return self.api._make_request("POST", "/v2/buyPremium/pay", json_data=data)
|
|
194
|
+
|
|
195
|
+
def check_premium_order(self, uuid: str) -> dict:
|
|
196
|
+
params = {"uuid": uuid}
|
|
197
|
+
return self.api._make_request("GET", "/v2/buyPremium/check", params=params)
|
|
198
|
+
|
|
199
|
+
class FragmentStars:
|
|
200
|
+
def __init__(self, api: FragmentAPI):
|
|
201
|
+
self.api = api
|
|
202
|
+
|
|
203
|
+
def create_stars_order(self, username: str, amount: int,
|
|
204
|
+
auth_key: Optional[str] = None,
|
|
205
|
+
show_sender: bool = True) -> dict:
|
|
206
|
+
if auth_key is None:
|
|
207
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
208
|
+
raise FragmentAuthError(
|
|
209
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
210
|
+
"No auth key provided and no active session",
|
|
211
|
+
401
|
|
212
|
+
)
|
|
213
|
+
auth_key = self.api.session.auth_key
|
|
214
|
+
|
|
215
|
+
data = {
|
|
216
|
+
"username": username,
|
|
217
|
+
"amount": amount,
|
|
218
|
+
"auth_key": auth_key,
|
|
219
|
+
"show_sender": show_sender
|
|
220
|
+
}
|
|
221
|
+
return self.api._make_request("POST", "/v2/buyStars/create", json_data=data)
|
|
222
|
+
|
|
223
|
+
def pay_stars_order(self, order_uuid: str, cost: float,
|
|
224
|
+
auth_key: Optional[str] = None,
|
|
225
|
+
wallet_type: Optional[str] = None) -> dict:
|
|
226
|
+
if auth_key is None:
|
|
227
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
228
|
+
raise FragmentAuthError(
|
|
229
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
230
|
+
"No auth key provided and no active session",
|
|
231
|
+
401
|
|
232
|
+
)
|
|
233
|
+
auth_key = self.api.session.auth_key
|
|
234
|
+
wallet_type = self.api.session.wallet_type
|
|
235
|
+
|
|
236
|
+
data = {
|
|
237
|
+
"order_uuid": order_uuid,
|
|
238
|
+
"auth_key": auth_key,
|
|
239
|
+
"cost": cost,
|
|
240
|
+
"wallet_type": wallet_type or "v4r2"
|
|
241
|
+
}
|
|
242
|
+
return self.api._make_request("POST", "/v2/buyStars/pay", json_data=data)
|
|
243
|
+
|
|
244
|
+
def check_stars_order(self, uuid: str) -> dict:
|
|
245
|
+
params = {"uuid": uuid}
|
|
246
|
+
return self.api._make_request("GET", "/v2/buyStars/check", params=params)
|
|
247
|
+
|
|
248
|
+
class FragmentTON:
|
|
249
|
+
def __init__(self, api: FragmentAPI):
|
|
250
|
+
self.api = api
|
|
251
|
+
|
|
252
|
+
def create_ton_order(self, username: str, amount: int,
|
|
253
|
+
auth_key: Optional[str] = None,
|
|
254
|
+
show_sender: bool = True) -> dict:
|
|
255
|
+
if auth_key is None:
|
|
256
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
257
|
+
raise FragmentAuthError(
|
|
258
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
259
|
+
"No auth key provided and no active session",
|
|
260
|
+
401
|
|
261
|
+
)
|
|
262
|
+
auth_key = self.api.session.auth_key
|
|
263
|
+
|
|
264
|
+
data = {
|
|
265
|
+
"username": username,
|
|
266
|
+
"amount": amount,
|
|
267
|
+
"auth_key": auth_key,
|
|
268
|
+
"show_sender": show_sender
|
|
269
|
+
}
|
|
270
|
+
return self.api._make_request("POST", "/v2/buyTon/create", json_data=data)
|
|
271
|
+
|
|
272
|
+
def pay_ton_order(self, order_uuid: str, cost: float,
|
|
273
|
+
auth_key: Optional[str] = None,
|
|
274
|
+
wallet_type: Optional[str] = None) -> dict:
|
|
275
|
+
if auth_key is None:
|
|
276
|
+
if not self.api.session or not self.api.session.auth_key:
|
|
277
|
+
raise FragmentAuthError(
|
|
278
|
+
FragmentErrorType.AUTH_KEY_NOT_FOUND,
|
|
279
|
+
"No auth key provided and no active session",
|
|
280
|
+
401
|
|
281
|
+
)
|
|
282
|
+
auth_key = self.api.session.auth_key
|
|
283
|
+
wallet_type = self.api.session.wallet_type
|
|
284
|
+
|
|
285
|
+
data = {
|
|
286
|
+
"order_uuid": order_uuid,
|
|
287
|
+
"auth_key": auth_key,
|
|
288
|
+
"cost": cost,
|
|
289
|
+
"wallet_type": wallet_type or "v4r2"
|
|
290
|
+
}
|
|
291
|
+
return self.api._make_request("POST", "/v2/buyTon/pay", json_data=data)
|
|
292
|
+
|
|
293
|
+
def check_ton_order(self, uuid: str) -> dict:
|
|
294
|
+
params = {"uuid": uuid}
|
|
295
|
+
return self.api._make_request("GET", "/v2/buyTon/check", params=params)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from .models import FragmentAPIError, FragmentErrorType
|
|
2
|
+
|
|
3
|
+
class FragmentAuthError(FragmentAPIError):
|
|
4
|
+
pass
|
|
5
|
+
|
|
6
|
+
class FragmentOrderError(FragmentAPIError):
|
|
7
|
+
pass
|
|
8
|
+
|
|
9
|
+
class FragmentPaymentError(FragmentAPIError):
|
|
10
|
+
pass
|
|
11
|
+
|
|
12
|
+
class FragmentNetworkError(FragmentAPIError):
|
|
13
|
+
pass
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from dataclasses import dataclass, asdict
|
|
3
|
+
from typing import Optional, Dict, Any
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
class FragmentErrorType(Enum):
|
|
8
|
+
AUTH_KEY_EXPIRED = "AUTH_KEY_EXPIRED"
|
|
9
|
+
INVALID_WALLET_TYPE = "INVALID_WALLET_TYPE"
|
|
10
|
+
INVALID_ORDER_PRODUCT_TYPE = "INVALID_ORDER_PRODUCT_TYPE"
|
|
11
|
+
ORDER_ALREADY_PROCESSED = "ORDER_ALREADY_PROCESSED"
|
|
12
|
+
ORDER_ALREADY_PROCESSING = "ORDER_ALREADY_PROCESSING"
|
|
13
|
+
INVALID_ORDER_COST = "INVALID_ORDER_COST"
|
|
14
|
+
INVALID_PREMIUM_DURATION = "INVALID_PREMIUM_DURATION"
|
|
15
|
+
INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE"
|
|
16
|
+
ORDER_EXPIRED = "ORDER_EXPIRED"
|
|
17
|
+
INVALID_USERNAME_FORMAT = "INVALID_USERNAME_FORMAT"
|
|
18
|
+
USER_NOT_FOUND = "USER_NOT_FOUND"
|
|
19
|
+
AUTH_KEY_NOT_FOUND = "AUTH_KEY_NOT_FOUND"
|
|
20
|
+
ORDER_NOT_FOUND = "ORDER_NOT_FOUND"
|
|
21
|
+
MISSING_FRAGMENT_COOKIES = "MISSING_FRAGMENT_COOKIES"
|
|
22
|
+
MISSING_SEED = "MISSING_SEED"
|
|
23
|
+
INVALID_SEED_FORMAT = "INVALID_SEED_FORMAT"
|
|
24
|
+
INVALID_FRAGMENT_COOKIES = "INVALID_FRAGMENT_COOKIES"
|
|
25
|
+
USER_ALREADY_HAS_PREMIUM = "USER_ALREADY_HAS_PREMIUM"
|
|
26
|
+
SEARCH_ERROR = "SEARCH_ERROR"
|
|
27
|
+
BALANCE_CHECK_ERROR = "BALANCE_CHECK_ERROR"
|
|
28
|
+
TRANSFER_FAILED = "TRANSFER_FAILED"
|
|
29
|
+
INTERNAL_SERVER_ERROR = "INTERNAL_SERVER_ERROR"
|
|
30
|
+
|
|
31
|
+
@dataclass
|
|
32
|
+
class FragmentAPIError(Exception):
|
|
33
|
+
error_type: FragmentErrorType
|
|
34
|
+
message: str
|
|
35
|
+
status_code: int
|
|
36
|
+
details: Optional[Dict[str, Any]] = None
|
|
37
|
+
|
|
38
|
+
def __str__(self):
|
|
39
|
+
return f"[{self.status_code}] {self.error_type.value}: {self.message}"
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class FragmentSession:
|
|
43
|
+
auth_key: str
|
|
44
|
+
fragment_cookies: str
|
|
45
|
+
wallet_type: str = "v4r2"
|
|
46
|
+
last_balance: Optional[float] = None
|
|
47
|
+
|
|
48
|
+
def save_to_file(self, filename: str = "fragment_session.json"):
|
|
49
|
+
with open(filename, 'w') as f:
|
|
50
|
+
json.dump(asdict(self), f)
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def load_from_file(cls, filename: str = "fragment_session.json"):
|
|
54
|
+
if not os.path.exists(filename):
|
|
55
|
+
return None
|
|
56
|
+
|
|
57
|
+
with open(filename, 'r') as f:
|
|
58
|
+
data = json.load(f)
|
|
59
|
+
return cls(**data)
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
from urllib.parse import urljoin
|
|
2
|
+
from typing import Dict, Optional, Any
|
|
3
|
+
import requests
|
|
4
|
+
from .models import FragmentAPIError, FragmentErrorType
|
|
5
|
+
|
|
6
|
+
def make_request(api_url: str, method: str, endpoint: str,
|
|
7
|
+
params: Optional[dict] = None,
|
|
8
|
+
json_data: Optional[dict] = None) -> Dict[str, Any]:
|
|
9
|
+
url = urljoin(api_url, endpoint.lstrip('/'))
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
response = requests.request(
|
|
13
|
+
method,
|
|
14
|
+
url,
|
|
15
|
+
params=params,
|
|
16
|
+
json=json_data,
|
|
17
|
+
timeout=30
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
if not response.ok:
|
|
21
|
+
handle_api_error(response)
|
|
22
|
+
|
|
23
|
+
return response.json()
|
|
24
|
+
|
|
25
|
+
except requests.exceptions.RequestException as e:
|
|
26
|
+
raise FragmentAPIError(
|
|
27
|
+
FragmentErrorType.INTERNAL_SERVER_ERROR,
|
|
28
|
+
f"Network error: {str(e)}",
|
|
29
|
+
500
|
|
30
|
+
) from e
|
|
31
|
+
|
|
32
|
+
def handle_api_error(response: requests.Response):
|
|
33
|
+
try:
|
|
34
|
+
error_data = response.json()
|
|
35
|
+
error_code = error_data.get("error_code")
|
|
36
|
+
message = error_data.get("message", "Unknown error")
|
|
37
|
+
|
|
38
|
+
try:
|
|
39
|
+
error_type = FragmentErrorType(error_code)
|
|
40
|
+
except ValueError:
|
|
41
|
+
error_type = FragmentErrorType.INTERNAL_SERVER_ERROR
|
|
42
|
+
|
|
43
|
+
raise FragmentAPIError(
|
|
44
|
+
error_type,
|
|
45
|
+
message,
|
|
46
|
+
response.status_code,
|
|
47
|
+
error_data
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
except ValueError:
|
|
51
|
+
raise FragmentAPIError(
|
|
52
|
+
FragmentErrorType.INTERNAL_SERVER_ERROR,
|
|
53
|
+
f"HTTP {response.status_code}: {response.text}",
|
|
54
|
+
response.status_code
|
|
55
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fragment-api-py
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python client for Fragment API (fragment.com)
|
|
5
|
+
Home-page: https://github.com/S1qwy/fragment-api-py
|
|
6
|
+
Author: S1qwy
|
|
7
|
+
Author-email: S1qwy <amirhansuper75@gmail.com>
|
|
8
|
+
Project-URL: Homepage, https://github.com/S1qwy/fragment-api-py
|
|
9
|
+
Project-URL: Bug-Reports, https://github.com/S1qwy/fragment-api-py/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: requests>=2.25.1
|
|
17
|
+
Requires-Dist: dataclasses>=0.6; python_version < "3.7"
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# Fragment API Python Client
|
|
24
|
+
|
|
25
|
+
Python client for [Fragment API](https://fragment.com) - Telegram Stars, Premium and TON service.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Full Fragment API support
|
|
30
|
+
- Session management (auto-save auth_key)
|
|
31
|
+
- Detailed error handling
|
|
32
|
+
- Support for all operations:
|
|
33
|
+
- Telegram Stars
|
|
34
|
+
- Telegram Premium
|
|
35
|
+
- TON transfers
|
|
36
|
+
- Automatic session save/load
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install fragment-api-py
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from fragment_api import FragmentAPI, FragmentAuth
|
|
48
|
+
|
|
49
|
+
# Initialize API
|
|
50
|
+
api = FragmentAPI("https://fragment-api.net")
|
|
51
|
+
|
|
52
|
+
# Authenticate
|
|
53
|
+
auth = FragmentAuth(api)
|
|
54
|
+
session = auth.create_auth_key("your_cookies", "your_seed")
|
|
55
|
+
|
|
56
|
+
# Get balance
|
|
57
|
+
print(api.general().get_balance())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
[View full documentation on GitHub](https://github.com/yourusername/fragment-api-py)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Fragment API Python Client
|
|
2
|
+
|
|
3
|
+
Python client for [Fragment API](https://fragment.com) - Telegram Stars, Premium and TON service.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Full Fragment API support
|
|
8
|
+
- Session management (auto-save auth_key)
|
|
9
|
+
- Detailed error handling
|
|
10
|
+
- Support for all operations:
|
|
11
|
+
- Telegram Stars
|
|
12
|
+
- Telegram Premium
|
|
13
|
+
- TON transfers
|
|
14
|
+
- Automatic session save/load
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install fragment-api-py
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```python
|
|
25
|
+
from fragment_api import FragmentAPI, FragmentAuth
|
|
26
|
+
|
|
27
|
+
# Initialize API
|
|
28
|
+
api = FragmentAPI("https://fragment-api.net")
|
|
29
|
+
|
|
30
|
+
# Authenticate
|
|
31
|
+
auth = FragmentAuth(api)
|
|
32
|
+
session = auth.create_auth_key("your_cookies", "your_seed")
|
|
33
|
+
|
|
34
|
+
# Get balance
|
|
35
|
+
print(api.general().get_balance())
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
[View full documentation on GitHub](https://github.com/yourusername/fragment-api-py)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Fragment API Python Client
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/py/fragment-api-py)
|
|
4
|
+
[](https://pypi.org/project/fragment-api-py/)
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
Неофициальный Python клиент для работы с [Fragment API](https://fragment-api.net) - сервисом покупки Telegram Stars, Premium и TON.
|
|
8
|
+
|
|
9
|
+
## Возможности
|
|
10
|
+
|
|
11
|
+
- Полная поддержка всех методов Fragment API
|
|
12
|
+
- Удобное управление сессиями (автосохранение auth_key)
|
|
13
|
+
- Подробная обработка ошибок с понятными сообщениями
|
|
14
|
+
- Поддержка всех типов операций:
|
|
15
|
+
- Telegram Stars
|
|
16
|
+
- Telegram Premium
|
|
17
|
+
- TON переводы
|
|
18
|
+
- Автоматическая загрузка и сохранение сессий
|
|
19
|
+
|
|
20
|
+
## Установка
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install fragment-api-py
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Быстрый старт
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from fragment_api import FragmentAPI, FragmentAuth
|
|
30
|
+
|
|
31
|
+
# Инициализация API
|
|
32
|
+
api = FragmentAPI("https://fragment-api.net")
|
|
33
|
+
|
|
34
|
+
# Аутентификация
|
|
35
|
+
auth = FragmentAuth(api)
|
|
36
|
+
session = auth.create_auth_key("your_fragment_cookies", "your_seed_phrase")
|
|
37
|
+
|
|
38
|
+
# Работа с API
|
|
39
|
+
general = api.general()
|
|
40
|
+
print(general.get_balance())
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Примеры использования
|
|
44
|
+
|
|
45
|
+
### Покупка Telegram Premium
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
premium = api.premium()
|
|
49
|
+
order = premium.create_premium_order("@username", 12) # 12 месяцев
|
|
50
|
+
payment = premium.pay_premium_order(order["order_id"], order["cost"])
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Покупка Telegram Stars
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
stars = api.stars()
|
|
57
|
+
order = stars.create_stars_order("@username", 100) # 100 Stars
|
|
58
|
+
payment = stars.pay_stars_order(order["order_id"], order["cost"])
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Перевод TON
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
ton = api.ton()
|
|
65
|
+
order = ton.create_ton_order("@username", 5) # 5 TON
|
|
66
|
+
payment = ton.pay_ton_order(order["order_id"], order["cost"])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Документация
|
|
70
|
+
|
|
71
|
+
Полная документация доступна на [GitHub Wiki](https://github.com/yourusername/fragment-api-py/wiki).
|
|
72
|
+
|
|
73
|
+
## Лицензия
|
|
74
|
+
|
|
75
|
+
MIT License. Смотрите файл [LICENSE](LICENSE).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fragment-api-py
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python client for Fragment API (fragment.com)
|
|
5
|
+
Home-page: https://github.com/S1qwy/fragment-api-py
|
|
6
|
+
Author: S1qwy
|
|
7
|
+
Author-email: S1qwy <amirhansuper75@gmail.com>
|
|
8
|
+
Project-URL: Homepage, https://github.com/S1qwy/fragment-api-py
|
|
9
|
+
Project-URL: Bug-Reports, https://github.com/S1qwy/fragment-api-py/issues
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.6
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: requests>=2.25.1
|
|
17
|
+
Requires-Dist: dataclasses>=0.6; python_version < "3.7"
|
|
18
|
+
Dynamic: author
|
|
19
|
+
Dynamic: home-page
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
Dynamic: requires-python
|
|
22
|
+
|
|
23
|
+
# Fragment API Python Client
|
|
24
|
+
|
|
25
|
+
Python client for [Fragment API](https://fragment.com) - Telegram Stars, Premium and TON service.
|
|
26
|
+
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- Full Fragment API support
|
|
30
|
+
- Session management (auto-save auth_key)
|
|
31
|
+
- Detailed error handling
|
|
32
|
+
- Support for all operations:
|
|
33
|
+
- Telegram Stars
|
|
34
|
+
- Telegram Premium
|
|
35
|
+
- TON transfers
|
|
36
|
+
- Automatic session save/load
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install fragment-api-py
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
from fragment_api import FragmentAPI, FragmentAuth
|
|
48
|
+
|
|
49
|
+
# Initialize API
|
|
50
|
+
api = FragmentAPI("https://fragment-api.net")
|
|
51
|
+
|
|
52
|
+
# Authenticate
|
|
53
|
+
auth = FragmentAuth(api)
|
|
54
|
+
session = auth.create_auth_key("your_cookies", "your_seed")
|
|
55
|
+
|
|
56
|
+
# Get balance
|
|
57
|
+
print(api.general().get_balance())
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
[View full documentation on GitHub](https://github.com/yourusername/fragment-api-py)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
PYPI_README.md
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
setup.py
|
|
6
|
+
./FragmentAPI/__init__.py
|
|
7
|
+
./FragmentAPI/api.py
|
|
8
|
+
./FragmentAPI/exceptions.py
|
|
9
|
+
./FragmentAPI/models.py
|
|
10
|
+
./FragmentAPI/utils.py
|
|
11
|
+
fragment_api_py.egg-info/PKG-INFO
|
|
12
|
+
fragment_api_py.egg-info/SOURCES.txt
|
|
13
|
+
fragment_api_py.egg-info/dependency_links.txt
|
|
14
|
+
fragment_api_py.egg-info/requires.txt
|
|
15
|
+
fragment_api_py.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
FragmentAPI
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "fragment-api-py"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "S1qwy", email = "amirhansuper75@gmail.com"},
|
|
10
|
+
]
|
|
11
|
+
description = "Python client for Fragment API (fragment.com)"
|
|
12
|
+
readme = "PYPI_README.md"
|
|
13
|
+
requires-python = ">=3.6"
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"requests>=2.25.1",
|
|
21
|
+
"dataclasses>=0.6;python_version<'3.7'",
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
[project.urls]
|
|
25
|
+
Homepage = "https://github.com/S1qwy/fragment-api-py"
|
|
26
|
+
Bug-Reports = "https://github.com/S1qwy/fragment-api-py/issues"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
with open("PYPI_README.md", "r", encoding="utf-8") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setup(
|
|
7
|
+
name="fragment-api-py",
|
|
8
|
+
version="1.0.0",
|
|
9
|
+
author="S1qwy",
|
|
10
|
+
author_email="amirhansuper75@gmail.com",
|
|
11
|
+
description="Python client for Fragment API (fragment.com)",
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url="https://github.com/S1qwy/fragment-api-py",
|
|
15
|
+
packages=find_packages(include=['FragmentAPI', 'FragmentAPI.*']),
|
|
16
|
+
package_dir={'': '.'},
|
|
17
|
+
install_requires=[
|
|
18
|
+
"requests>=2.25.1",
|
|
19
|
+
"dataclasses>=0.6;python_version<'3.7'",
|
|
20
|
+
],
|
|
21
|
+
classifiers=[
|
|
22
|
+
"Programming Language :: Python :: 3",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
],
|
|
26
|
+
python_requires=">=3.6",
|
|
27
|
+
keywords="fragment, telegram, ton, stars, premium, api",
|
|
28
|
+
project_urls={
|
|
29
|
+
"Bug Reports": "https://github.com/S1qwy/fragment-api-py/issues",
|
|
30
|
+
"Source": "https://github.com/S1qwy/fragment-api-py",
|
|
31
|
+
},
|
|
32
|
+
)
|