pararamio-aio 3.0.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.
Files changed (56) hide show
  1. pararamio_aio/__init__.py +26 -0
  2. pararamio_aio/_core/__init__.py +125 -0
  3. pararamio_aio/_core/_types.py +120 -0
  4. pararamio_aio/_core/base.py +143 -0
  5. pararamio_aio/_core/client_protocol.py +90 -0
  6. pararamio_aio/_core/constants/__init__.py +7 -0
  7. pararamio_aio/_core/constants/base.py +9 -0
  8. pararamio_aio/_core/constants/endpoints.py +84 -0
  9. pararamio_aio/_core/cookie_decorator.py +208 -0
  10. pararamio_aio/_core/cookie_manager.py +1222 -0
  11. pararamio_aio/_core/endpoints.py +67 -0
  12. pararamio_aio/_core/exceptions/__init__.py +6 -0
  13. pararamio_aio/_core/exceptions/auth.py +91 -0
  14. pararamio_aio/_core/exceptions/base.py +124 -0
  15. pararamio_aio/_core/models/__init__.py +17 -0
  16. pararamio_aio/_core/models/base.py +66 -0
  17. pararamio_aio/_core/models/chat.py +92 -0
  18. pararamio_aio/_core/models/post.py +65 -0
  19. pararamio_aio/_core/models/user.py +54 -0
  20. pararamio_aio/_core/py.typed +2 -0
  21. pararamio_aio/_core/utils/__init__.py +73 -0
  22. pararamio_aio/_core/utils/async_requests.py +417 -0
  23. pararamio_aio/_core/utils/auth_flow.py +202 -0
  24. pararamio_aio/_core/utils/authentication.py +235 -0
  25. pararamio_aio/_core/utils/captcha.py +92 -0
  26. pararamio_aio/_core/utils/helpers.py +336 -0
  27. pararamio_aio/_core/utils/http_client.py +199 -0
  28. pararamio_aio/_core/utils/requests.py +424 -0
  29. pararamio_aio/_core/validators.py +78 -0
  30. pararamio_aio/_types.py +29 -0
  31. pararamio_aio/client.py +989 -0
  32. pararamio_aio/constants/__init__.py +16 -0
  33. pararamio_aio/exceptions/__init__.py +31 -0
  34. pararamio_aio/exceptions/base.py +1 -0
  35. pararamio_aio/file_operations.py +232 -0
  36. pararamio_aio/models/__init__.py +31 -0
  37. pararamio_aio/models/activity.py +127 -0
  38. pararamio_aio/models/attachment.py +141 -0
  39. pararamio_aio/models/base.py +83 -0
  40. pararamio_aio/models/bot.py +274 -0
  41. pararamio_aio/models/chat.py +722 -0
  42. pararamio_aio/models/deferred_post.py +174 -0
  43. pararamio_aio/models/file.py +103 -0
  44. pararamio_aio/models/group.py +361 -0
  45. pararamio_aio/models/poll.py +275 -0
  46. pararamio_aio/models/post.py +643 -0
  47. pararamio_aio/models/team.py +403 -0
  48. pararamio_aio/models/user.py +239 -0
  49. pararamio_aio/py.typed +2 -0
  50. pararamio_aio/utils/__init__.py +18 -0
  51. pararamio_aio/utils/authentication.py +383 -0
  52. pararamio_aio/utils/requests.py +75 -0
  53. pararamio_aio-3.0.0.dist-info/METADATA +269 -0
  54. pararamio_aio-3.0.0.dist-info/RECORD +56 -0
  55. pararamio_aio-3.0.0.dist-info/WHEEL +5 -0
  56. pararamio_aio-3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,269 @@
1
+ Metadata-Version: 2.4
2
+ Name: pararamio-aio
3
+ Version: 3.0.0
4
+ Summary: Async Python client library for pararam.io platform
5
+ Author: Pararamio Team
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/your-repo/py-pararamio
8
+ Project-URL: Documentation, https://your-docs-site.com
9
+ Project-URL: Repository, https://github.com/your-repo/py-pararamio
10
+ Project-URL: Issues, https://github.com/your-repo/py-pararamio/issues
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Internet :: WWW/HTTP
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.9
23
+ Description-Content-Type: text/markdown
24
+ Requires-Dist: aiohttp>=3.8.0
25
+ Requires-Dist: aiofiles>=0.8.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
28
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
29
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
30
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
31
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
32
+ Requires-Dist: types-aiofiles; extra == "dev"
33
+
34
+ # Pararamio AIO
35
+
36
+ Async Python API client for [pararam.io](https://pararam.io) platform.
37
+
38
+ ## Features
39
+
40
+ - ⚡ **Async/Await**: Modern asynchronous interface with aiohttp
41
+ - 🚀 **Explicit Loading**: Predictable API calls with explicit `load()` methods
42
+ - 🍪 **Cookie Persistence**: Automatic session management
43
+ - 🔐 **Two-Factor Authentication**: Built-in 2FA support
44
+ - 🐍 **Type Hints**: Full typing support for better IDE experience
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install pararamio-aio
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```python
55
+ import asyncio
56
+ from pararamio_aio import PararamioAIO, User, Chat, Post
57
+ from pararamio_core import AsyncFileCookieManager
58
+
59
+ async def main():
60
+ # Initialize cookie manager for persistent authentication
61
+ cookie_manager = AsyncFileCookieManager("session.cookie")
62
+
63
+ # Initialize client
64
+ async with PararamioAIO(
65
+ login="your_login",
66
+ password="your_password",
67
+ key="your_2fa_key",
68
+ cookie_manager=cookie_manager
69
+ ) as client:
70
+ # Authenticate
71
+ await client.authenticate()
72
+
73
+ # Search for users - returns User objects (clean names!)
74
+ users = await client.search_users("John")
75
+ for user in users:
76
+ print(f"{user.name}")
77
+
78
+ # Get chat messages - returns Chat and Post objects
79
+ chat = await client.get_chat_by_id(12345)
80
+ posts = await chat.get_posts(limit=10)
81
+ for post in posts:
82
+ await post.load() # Explicit loading
83
+ print(f"{post.author.name}: {post.text}")
84
+
85
+ asyncio.run(main())
86
+ ```
87
+
88
+ ## Explicit Loading
89
+
90
+ Unlike the sync version, pararamio-aio uses explicit loading for predictable async behavior:
91
+
92
+ ```python
93
+ # Get user object
94
+ user = await client.get_user_by_id(123)
95
+ print(user.name) # Basic data is already loaded
96
+
97
+ # Load full profile data explicitly
98
+ await user.load()
99
+ print(user.bio) # Now additional data is available
100
+
101
+ # Load specific relations
102
+ posts = await user.get_posts()
103
+ for post in posts:
104
+ await post.load() # Load each post's content
105
+ ```
106
+
107
+ ## Cookie Management
108
+
109
+ The async client supports multiple cookie storage options:
110
+
111
+ ### Default (In-Memory)
112
+ ```python
113
+ # By default, uses AsyncInMemoryCookieManager (no persistence)
114
+ async with PararamioAIO(
115
+ login="user",
116
+ password="pass",
117
+ key="key"
118
+ ) as client:
119
+ await client.authenticate()
120
+ # Cookies are stored in memory only during the session
121
+ ```
122
+
123
+ ### File-based Persistence
124
+ ```python
125
+ from pararamio_core import AsyncFileCookieManager
126
+
127
+ # Create a cookie manager for persistent storage
128
+ cookie_manager = AsyncFileCookieManager("session.cookie")
129
+
130
+ # First run - authenticates with credentials
131
+ async with PararamioAIO(
132
+ login="user",
133
+ password="pass",
134
+ key="key",
135
+ cookie_manager=cookie_manager
136
+ ) as client:
137
+ await client.authenticate()
138
+
139
+ # Later runs - uses saved cookie
140
+ cookie_manager2 = AsyncFileCookieManager("session.cookie")
141
+ async with PararamioAIO(cookie_manager=cookie_manager2) as client:
142
+ # Already authenticated!
143
+ profile = await client.get_profile()
144
+ ```
145
+
146
+ ## Concurrent Operations
147
+
148
+ Take advantage of async for concurrent operations:
149
+
150
+ ```python
151
+ async def get_multiple_users(client, user_ids):
152
+ # Fetch all users concurrently
153
+ tasks = [client.get_user_by_id(uid) for uid in user_ids]
154
+ users = await asyncio.gather(*tasks)
155
+
156
+ # Load all profiles concurrently
157
+ await asyncio.gather(*[user.load() for user in users])
158
+
159
+ return users
160
+ ```
161
+
162
+ ## API Reference
163
+
164
+ ### Client Methods
165
+
166
+ All methods are async and must be awaited:
167
+
168
+ - `authenticate()` - Authenticate with the API
169
+ - `search_users(query)` - Search for users
170
+ - `get_user_by_id(user_id)` - Get user by ID
171
+ - `get_users_by_ids(ids)` - Get multiple users
172
+ - `get_chat_by_id(chat_id)` - Get chat by ID
173
+ - `search_groups(query)` - Search for groups
174
+ - `create_chat(title, description)` - Create new chat
175
+
176
+ ### Model Objects
177
+
178
+ All models have async methods:
179
+
180
+ - `User` - User profile
181
+ - `load()` - Load full profile
182
+ - `get_posts()` - Get user's posts
183
+ - `get_groups()` - Get user's groups
184
+
185
+ - `Chat` - Chat/conversation
186
+ - `load()` - Load chat details
187
+ - `get_posts(limit, offset)` - Get messages
188
+ - `send_message(text)` - Send message
189
+
190
+ - `Post` - Message/post
191
+ - `load()` - Load post content
192
+ - `delete()` - Delete post
193
+
194
+ - `Group` - Community group
195
+ - `load()` - Load group details
196
+ - `get_members()` - Get member list
197
+
198
+ ## Error Handling
199
+
200
+ ```python
201
+ from pararamio_aio import (
202
+ PararamioAuthenticationException,
203
+ PararamioHTTPRequestException
204
+ )
205
+
206
+ async with PararamioAIO(**credentials) as client:
207
+ try:
208
+ await client.authenticate()
209
+ except PararamioAuthenticationException as e:
210
+ print(f"Authentication failed: {e}")
211
+ except PararamioHTTPRequestException as e:
212
+ print(f"HTTP error {e.code}: {e.message}")
213
+ ```
214
+
215
+ ## Advanced Usage
216
+
217
+ ### Custom Session
218
+
219
+ ```python
220
+ import aiohttp
221
+
222
+ # Create custom session with specific timeout
223
+ timeout = aiohttp.ClientTimeout(total=60)
224
+ connector = aiohttp.TCPConnector(limit=100)
225
+ session = aiohttp.ClientSession(timeout=timeout, connector=connector)
226
+
227
+ async with PararamioAIO(session=session, **credentials) as client:
228
+ # Client will use your custom session
229
+ await client.authenticate()
230
+ ```
231
+
232
+ ### Rate Limiting
233
+
234
+ The client automatically handles rate limiting:
235
+
236
+ ```python
237
+ client = PararamioAIO(
238
+ wait_auth_limit=True, # Wait instead of failing on rate limit
239
+ **credentials
240
+ )
241
+ ```
242
+
243
+ ## Migration from Sync Version
244
+
245
+ If you're migrating from the synchronous `pararamio` package:
246
+
247
+ 1. Add `async`/`await` keywords
248
+ 2. Use async context manager (`async with`)
249
+ 3. Call `load()` explicitly when needed
250
+ 4. Use `asyncio.gather()` for concurrent operations
251
+
252
+ Example migration:
253
+
254
+ ```python
255
+ # Sync version
256
+ client = Pararamio(**creds)
257
+ user = client.get_user_by_id(123)
258
+ print(user.bio) # Lazy loaded
259
+
260
+ # Async version
261
+ async with PararamioAIO(**creds) as client:
262
+ user = await client.get_user_by_id(123)
263
+ await user.load() # Explicit load
264
+ print(user.bio)
265
+ ```
266
+
267
+ ## License
268
+
269
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,56 @@
1
+ pararamio_aio/__init__.py,sha256=mhtfAtU97fpjX64ahNVeQ6yEOwuzeHStP1LCISrVyM8,614
2
+ pararamio_aio/_types.py,sha256=ubC7r0u1gK2hHfdfYzBs4AAbv5GkvI6k5GjaBkYFriY,513
3
+ pararamio_aio/client.py,sha256=z9P-yBAUX6FPqVkpszq8Wp9eLP-JUfMRYsx8M4n7xXc,34481
4
+ pararamio_aio/file_operations.py,sha256=mkqxP6rs1XRs4qRjVrVc2UGA134BVYjfv8IfbCU0F7k,6844
5
+ pararamio_aio/py.typed,sha256=lO8QdKnW0rRNzOeMLUDJj_pGcUI45ehzD2Ci6FGjSyc,91
6
+ pararamio_aio/_core/__init__.py,sha256=sKZaAIrAesvinqAP9RvHVrOQcJs1zlDjcC_hK4ar_Sw,3024
7
+ pararamio_aio/_core/_types.py,sha256=J-Bx15_Wgxv2TEER3h3ZLmDUSk4aiWfcqRRZVMAJR6s,2420
8
+ pararamio_aio/_core/base.py,sha256=wvxGX5Yk-CNlRDXfpSQVbyAMyOmf3zJw3T_P_npXFkw,4293
9
+ pararamio_aio/_core/client_protocol.py,sha256=SWT5I3-sVkzkWCEg_fPjYHmZU-ip2O3pQ_kz0FN4DuQ,2577
10
+ pararamio_aio/_core/cookie_decorator.py,sha256=1roJPKauUWOC4xzP39Q9mT3OhReKb309twKh2by84Jo,7270
11
+ pararamio_aio/_core/cookie_manager.py,sha256=pl4IqAr8TWCFtLOk1YLLxGiZCsyp9tr_XgyH-yRu93c,43964
12
+ pararamio_aio/_core/endpoints.py,sha256=XrRlbFvMqQrWKmy2zmoQ6pYNv-Wz1UqptkaQncW7GcI,1867
13
+ pararamio_aio/_core/py.typed,sha256=lO8QdKnW0rRNzOeMLUDJj_pGcUI45ehzD2Ci6FGjSyc,91
14
+ pararamio_aio/_core/validators.py,sha256=6AB_miJiX8jbvSzOX5IbLwYwJn0mTRpF3wS0BCc3BG0,2397
15
+ pararamio_aio/_core/constants/__init__.py,sha256=HnuJjEqv1mU6NPHYQqnM4WPw-zYC3oc9YGN0G77VGBc,124
16
+ pararamio_aio/_core/constants/base.py,sha256=JNolmrD-geQ9SW-J5SHv8CQC9ETZdcYu06Ff5-j7XTY,279
17
+ pararamio_aio/_core/constants/endpoints.py,sha256=4cbisrT6FDK9-Zc5zmg1R1k2K1L36ynR8aF__Fq5rSo,1990
18
+ pararamio_aio/_core/exceptions/__init__.py,sha256=Res9nMxrOYV5U1Lmgh8HOXKm2J_-vig0YzC5yAh05yc,125
19
+ pararamio_aio/_core/exceptions/auth.py,sha256=sUWEZrF9FeItFmBZFAQ4v8ujwh3OXNiDRLd4E45e_V8,2641
20
+ pararamio_aio/_core/exceptions/base.py,sha256=vpWEfy4NikKeH35QoRZ8_aWds66QpP7RK2kdMVn0nls,3141
21
+ pararamio_aio/_core/models/__init__.py,sha256=yYgrn-t2SRXVo0rs_v0DPDe1G2H5zJRDAzr6q_IE5Es,289
22
+ pararamio_aio/_core/models/base.py,sha256=FlGWVBiku6k5Xdiz4UiJQApUx4CIKedlmkKqVbjtUl8,1834
23
+ pararamio_aio/_core/models/chat.py,sha256=O_F0JACBA_iDLSnY_XVcf-H3y2Fqdm63QdW-8OwTTWE,2457
24
+ pararamio_aio/_core/models/post.py,sha256=-PwV3lrcax64hiV945J--rkjB0ejCnfUZK4xIb0TCAw,1691
25
+ pararamio_aio/_core/models/user.py,sha256=jD9DEA8witff7Uz5HbKwhJ6FeLh_zGbgk28EIRgaKFA,1357
26
+ pararamio_aio/_core/utils/__init__.py,sha256=cdthEMSxrnKxbAQmpvL4nIbuIFvj3vNEJkhRoPNFUwY,1614
27
+ pararamio_aio/_core/utils/async_requests.py,sha256=hEPfkY4bel3nlhbzzxunJ5_IG61fzQfjEmInw2aGx4c,13203
28
+ pararamio_aio/_core/utils/auth_flow.py,sha256=CdqgtkqcQQzjRG9z4HO7KIme8Ao7lPmUSvEdF9KKBlE,5574
29
+ pararamio_aio/_core/utils/authentication.py,sha256=1Dp6AKd9QOLJ5CFnzJKGtf2GDVG2pYaYiAYxCeiFHpE,7557
30
+ pararamio_aio/_core/utils/captcha.py,sha256=NThx0RVZitUQXj-0FFDsoFC_RzjCszJXVK2_iTD-SoE,2870
31
+ pararamio_aio/_core/utils/helpers.py,sha256=nx2auOc5nm5XVg8YWs4gZemb7WCoWl-opojTttaCxbc,10975
32
+ pararamio_aio/_core/utils/http_client.py,sha256=mnMblvCVAOuXioWFEqIiGs9Y9BL5byAYNcs5RM5NsmU,5482
33
+ pararamio_aio/_core/utils/requests.py,sha256=8YvsxWFdWUXdtMwvikvQglrbcZ1I9Fe-WXSEzULF33Q,14393
34
+ pararamio_aio/constants/__init__.py,sha256=IeBstHaf_NOtCt3DKSpBXGYlkG78WMSynIMXlv922R0,302
35
+ pararamio_aio/exceptions/__init__.py,sha256=sJcl0eZOESZndIjJj_aTUcbXM-QpcyHmHhujt3rPPXs,945
36
+ pararamio_aio/exceptions/base.py,sha256=AilA_mJwd0tgrf3Z5jPWZBnxGgu33pzEuxNEKkKfv9E,49
37
+ pararamio_aio/models/__init__.py,sha256=0RfuwVCvy0PSBI7FZhoDRWDpeB_Fr77khYei642nGlM,662
38
+ pararamio_aio/models/activity.py,sha256=1SgKWuzC_kr2oH8udjkUT2nrAZQ0w5XlvBzoOP4k-Ig,3372
39
+ pararamio_aio/models/attachment.py,sha256=ryjitTErC2CPfndzCb9Y2vCe56Y3b20Ll1Yd9uqyYGE,3887
40
+ pararamio_aio/models/base.py,sha256=06AML0IVwGptswsZnHxWc6-jbfkRAqTM9LKLNnM1DWQ,2386
41
+ pararamio_aio/models/bot.py,sha256=jyTdXMHJbxVW2_gJ5giazvO_BJAijRtPqtTSQVzsLrk,7700
42
+ pararamio_aio/models/chat.py,sha256=rQYVxMxcDoCVFiax10vvO1xW_7lTG2Ip9bbuXdwXznY,21946
43
+ pararamio_aio/models/deferred_post.py,sha256=dbNOJI8Qpusy4oASugJfnej2M1rxh-gAuajJrz8jjOY,4806
44
+ pararamio_aio/models/file.py,sha256=5krs0bcUiyxdsGMr6zUjyujm2iuzQr7RjPAdWeyoRJY,2854
45
+ pararamio_aio/models/group.py,sha256=j5XoA8cfucTelLnCIZl43WysN-_nRHT41ugnrJuVQv8,10918
46
+ pararamio_aio/models/poll.py,sha256=2dqbjeKpNE5MxjWOdX_HpleH5B2Ths8kZw5e11OpGtE,7988
47
+ pararamio_aio/models/post.py,sha256=3tSO5afqyCmZXhKOqQEdnBbh_JorxUyGl16QWjeZJHs,19728
48
+ pararamio_aio/models/team.py,sha256=8C5e1gx0MbR8z0kUud1c2WoZlLmv-BCMFH8Gud3Vs_g,10959
49
+ pararamio_aio/models/user.py,sha256=stiDRQ0WdsjYLKsP_gwkn6pfcauPp41T7-pWFKWKy3A,6647
50
+ pararamio_aio/utils/__init__.py,sha256=b51cwaL3aMb1VzqCrlg_gDkgj5lKtO9ptkwXFzdAgqs,438
51
+ pararamio_aio/utils/authentication.py,sha256=SMMrqAY1MOZx6TAhmhgpc9619f0r7XgNky8_30T3sUM,11706
52
+ pararamio_aio/utils/requests.py,sha256=JIb0rBI6MPMicjyz6E2xKPtxfO0B9G5S_l6OZCmu9Hw,1873
53
+ pararamio_aio-3.0.0.dist-info/METADATA,sha256=prXuIDsrbXXffV6mDSjhdo9GrUEZSl6wMChBBPQ_A8I,7382
54
+ pararamio_aio-3.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
55
+ pararamio_aio-3.0.0.dist-info/top_level.txt,sha256=jJ1yLKIEkYu3uri2xi6Jc49rmtGy8U-YfLSoESnkQ-w,14
56
+ pararamio_aio-3.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ pararamio_aio