anymessage-sdk 0.2.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.
@@ -0,0 +1,186 @@
1
+ Metadata-Version: 2.4
2
+ Name: anymessage-sdk
3
+ Version: 0.2.0
4
+ Summary: Python SDK for api.anymessage.shop — temporary and long-term email automation
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://anymessage.shop
7
+ Project-URL: Documentation, https://anymessage.shop/en/docs
8
+ Keywords: anymessage,email,sdk,automation,temporary email
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3 :: Only
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Topic :: Software Development :: Libraries
15
+ Classifier: Topic :: Communications :: Email
16
+ Requires-Python: >=3.8
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests<3.0,>=2.28
19
+
20
+ # AnyMessage SDK
21
+
22
+ A lightweight Python SDK for the [https://anymessage.shop](https://anymessage.shop) API.
23
+ Supports **short-term** and **long-term** mailboxes, automatic message polling, and Activation Rate management.
24
+
25
+ ---
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install anymessage
31
+ ```
32
+
33
+ Requires Python 3.8+ and `requests`.
34
+
35
+ ---
36
+
37
+ ## Quick Start
38
+
39
+ ```python
40
+ from anymessage import AnyMessageClient
41
+
42
+ with AnyMessageClient("YOUR_TOKEN") as client:
43
+ order = client.order_email(site="instagram.com", domain="gmx,mailcom")
44
+ msg = client.wait_for_message(id=order.id, timeout=120, poll_interval=3)
45
+ client.cancel_email(id=order.id)
46
+ print("Email:", order.email)
47
+ print("HTML:", (msg.html or "")[:400])
48
+ ```
49
+
50
+ Or use the one-liner combo that orders, waits, and extracts a value with regex:
51
+
52
+ ```python
53
+ activation_id, email, html, code = client.order_wait_and_extract(
54
+ site="instagram.com",
55
+ domain="gmx,mailcom",
56
+ regex=r"(\d{6})", # extract 6-digit code from the email body
57
+ timeout=120,
58
+ )
59
+ print(f"Code: {code}") # e.g. "482910"
60
+ ```
61
+
62
+ ---
63
+
64
+ ## Short-term Emails
65
+
66
+ | Method | Description |
67
+ |--------|-------------|
68
+ | `get_balance()` | Get account balance |
69
+ | `get_email_quantity(site)` | Available domains and counts |
70
+ | `order_email(site, domain, regex=None, subject=None)` | Order a temporary email |
71
+ | `reorder_email(id=None, email=None, site=None)` | Repeat a previous order |
72
+ | `get_message(id, preview=False)` | Fetch a message (raises `WaitMessageError` if not yet arrived) |
73
+ | `wait_for_message(id, timeout=120, poll_interval=2, preview=False, on_tick=None, stop_event=None)` | Poll until message arrives |
74
+ | `cancel_email(id)` | Cancel an activation |
75
+ | `order_wait_and_extract(site, domain, regex=None, subject=None, timeout=180, ...)` | Combo: order → wait → extract; returns `(id, email, html, match_or_None)` |
76
+
77
+ **Domain aggregators** — pass multiple domains as a comma-separated string or a list; the API returns whichever has stock:
78
+ ```python
79
+ client.order_email(site="instagram.com", domain="gmx,mailcom,hotmail")
80
+ client.order_email(site="instagram.com", domain=["gmx", "mailcom"])
81
+ ```
82
+
83
+ ---
84
+
85
+ ## Long-term Emails
86
+
87
+ | Method | Description |
88
+ |--------|-------------|
89
+ | `get_longlive_quantity(site)` | Available domains with counts and prices |
90
+ | `order_longlive_email(site, domain, count=1)` | Buy 1–1000 mailboxes; returns `LongliveOrderResponse` |
91
+ | `get_longlive_history(offset=1, limit=10)` | Order history with IMAP credentials |
92
+ | `get_longlive_last_messages(id, subject=None)` | Messages from the last 40 minutes |
93
+ | `get_longlive_messages(id, created_at=None, subject=None)` | All messages for an activation |
94
+ | `find_longlive_email(email)` | Look up a purchased mailbox by address |
95
+
96
+ ```python
97
+ # Check what's available
98
+ qty = client.get_longlive_quantity(site="instagram.com")
99
+ print(qty.data) # {"hotmail.com": {"count": 93, "price": 0.006}, ...}
100
+
101
+ # Buy 5 mailboxes at once
102
+ resp = client.order_longlive_email(site="instagram.com", domain="hotmail.com", count=5)
103
+ print(f"Bought {resp.count}, total ${resp.total_price}")
104
+ for mailbox in resp.emails:
105
+ print(mailbox.email, mailbox.imap.password, mailbox.imap.link, mailbox.imap.port)
106
+
107
+ # Fetch recent messages for one of the mailboxes
108
+ msgs = client.get_longlive_last_messages(id=resp.emails[0].id)
109
+ for m in msgs:
110
+ print(m.subject, m.from_, m.message[:200])
111
+
112
+ # Find a previously purchased mailbox
113
+ records = client.find_longlive_email(email="example@hotmail.com")
114
+ if records:
115
+ print(records[0]["id"], records[0]["imap"])
116
+ ```
117
+
118
+ ---
119
+
120
+ ## Activation Rate
121
+
122
+ | Method | Description |
123
+ |--------|-------------|
124
+ | `get_ratio(full=False)` | Cancel statistics per site+domain pair |
125
+ | `enable_block_ratio()` | Auto-block orders when ratio drops below threshold |
126
+ | `disable_block_ratio()` | Disable auto-blocking |
127
+
128
+ ```python
129
+ # By default only shows pairs with cancel rate >= 60%
130
+ # Pass full=True to see all pairs including healthy ones
131
+ for entry in client.get_ratio(full=True):
132
+ print(f"{entry.site} / {entry.domain}: ratio={entry.ratio:.2f}, cancel%={entry.cancel_percent}")
133
+ ```
134
+
135
+ When blocking is enabled and the cancel rate reaches ≥ 60%, `order_email` raises `RatioBlockError`.
136
+
137
+ ---
138
+
139
+ ## Error Handling
140
+
141
+ ```python
142
+ from anymessage import (
143
+ AnyMessageClient, AnyMessageError,
144
+ AuthError, NoBalanceError, NoEmailsError,
145
+ RatioBlockError, ActivationCanceledError,
146
+ )
147
+
148
+ try:
149
+ with AnyMessageClient("YOUR_TOKEN") as c:
150
+ order = c.order_email(site="instagram.com", domain="gmx")
151
+ msg = c.wait_for_message(id=order.id, timeout=120)
152
+ except AuthError:
153
+ print("Invalid token")
154
+ except NoBalanceError:
155
+ print("Insufficient balance")
156
+ except NoEmailsError:
157
+ print("No emails available for this site/domain")
158
+ except RatioBlockError:
159
+ print("Blocked due to low Activation Rate")
160
+ except ActivationCanceledError:
161
+ print("Activation was canceled")
162
+ except AnyMessageError as e:
163
+ print("API error:", e)
164
+ ```
165
+
166
+ Full exception list: `AuthError`, `ValidationError`, `NotFoundError`, `NoBalanceError`, `NoEmailsError`, `ActivationCanceledError`, `ActivationAlreadyCanceledError`, `EmailBannedError`, `WaitMessageError`, `RatioBlockError`.
167
+
168
+ ---
169
+
170
+ ## Implementation Details
171
+
172
+ - Uses `requests.Session` with automatic retries (urllib3) and connection pooling.
173
+ - Thread-safe: create a separate `AnyMessageClient` per thread or task.
174
+ - No temporary files — everything runs in memory.
175
+ - `wait_for_message` supports `on_tick(n)` progress callback and `stop_event` (any object with `.is_set()`) for cancellation from another thread.
176
+
177
+ ---
178
+
179
+ ## License
180
+
181
+ MIT License © 2025 AnyMessage SDK contributors
182
+
183
+ ---
184
+
185
+ **API Documentation:** https://anymessage.shop/en/docs
186
+ **Official Website:** https://anymessage.shop/en
@@ -0,0 +1,167 @@
1
+ # AnyMessage SDK
2
+
3
+ A lightweight Python SDK for the [https://anymessage.shop](https://anymessage.shop) API.
4
+ Supports **short-term** and **long-term** mailboxes, automatic message polling, and Activation Rate management.
5
+
6
+ ---
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ pip install anymessage
12
+ ```
13
+
14
+ Requires Python 3.8+ and `requests`.
15
+
16
+ ---
17
+
18
+ ## Quick Start
19
+
20
+ ```python
21
+ from anymessage import AnyMessageClient
22
+
23
+ with AnyMessageClient("YOUR_TOKEN") as client:
24
+ order = client.order_email(site="instagram.com", domain="gmx,mailcom")
25
+ msg = client.wait_for_message(id=order.id, timeout=120, poll_interval=3)
26
+ client.cancel_email(id=order.id)
27
+ print("Email:", order.email)
28
+ print("HTML:", (msg.html or "")[:400])
29
+ ```
30
+
31
+ Or use the one-liner combo that orders, waits, and extracts a value with regex:
32
+
33
+ ```python
34
+ activation_id, email, html, code = client.order_wait_and_extract(
35
+ site="instagram.com",
36
+ domain="gmx,mailcom",
37
+ regex=r"(\d{6})", # extract 6-digit code from the email body
38
+ timeout=120,
39
+ )
40
+ print(f"Code: {code}") # e.g. "482910"
41
+ ```
42
+
43
+ ---
44
+
45
+ ## Short-term Emails
46
+
47
+ | Method | Description |
48
+ |--------|-------------|
49
+ | `get_balance()` | Get account balance |
50
+ | `get_email_quantity(site)` | Available domains and counts |
51
+ | `order_email(site, domain, regex=None, subject=None)` | Order a temporary email |
52
+ | `reorder_email(id=None, email=None, site=None)` | Repeat a previous order |
53
+ | `get_message(id, preview=False)` | Fetch a message (raises `WaitMessageError` if not yet arrived) |
54
+ | `wait_for_message(id, timeout=120, poll_interval=2, preview=False, on_tick=None, stop_event=None)` | Poll until message arrives |
55
+ | `cancel_email(id)` | Cancel an activation |
56
+ | `order_wait_and_extract(site, domain, regex=None, subject=None, timeout=180, ...)` | Combo: order → wait → extract; returns `(id, email, html, match_or_None)` |
57
+
58
+ **Domain aggregators** — pass multiple domains as a comma-separated string or a list; the API returns whichever has stock:
59
+ ```python
60
+ client.order_email(site="instagram.com", domain="gmx,mailcom,hotmail")
61
+ client.order_email(site="instagram.com", domain=["gmx", "mailcom"])
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Long-term Emails
67
+
68
+ | Method | Description |
69
+ |--------|-------------|
70
+ | `get_longlive_quantity(site)` | Available domains with counts and prices |
71
+ | `order_longlive_email(site, domain, count=1)` | Buy 1–1000 mailboxes; returns `LongliveOrderResponse` |
72
+ | `get_longlive_history(offset=1, limit=10)` | Order history with IMAP credentials |
73
+ | `get_longlive_last_messages(id, subject=None)` | Messages from the last 40 minutes |
74
+ | `get_longlive_messages(id, created_at=None, subject=None)` | All messages for an activation |
75
+ | `find_longlive_email(email)` | Look up a purchased mailbox by address |
76
+
77
+ ```python
78
+ # Check what's available
79
+ qty = client.get_longlive_quantity(site="instagram.com")
80
+ print(qty.data) # {"hotmail.com": {"count": 93, "price": 0.006}, ...}
81
+
82
+ # Buy 5 mailboxes at once
83
+ resp = client.order_longlive_email(site="instagram.com", domain="hotmail.com", count=5)
84
+ print(f"Bought {resp.count}, total ${resp.total_price}")
85
+ for mailbox in resp.emails:
86
+ print(mailbox.email, mailbox.imap.password, mailbox.imap.link, mailbox.imap.port)
87
+
88
+ # Fetch recent messages for one of the mailboxes
89
+ msgs = client.get_longlive_last_messages(id=resp.emails[0].id)
90
+ for m in msgs:
91
+ print(m.subject, m.from_, m.message[:200])
92
+
93
+ # Find a previously purchased mailbox
94
+ records = client.find_longlive_email(email="example@hotmail.com")
95
+ if records:
96
+ print(records[0]["id"], records[0]["imap"])
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Activation Rate
102
+
103
+ | Method | Description |
104
+ |--------|-------------|
105
+ | `get_ratio(full=False)` | Cancel statistics per site+domain pair |
106
+ | `enable_block_ratio()` | Auto-block orders when ratio drops below threshold |
107
+ | `disable_block_ratio()` | Disable auto-blocking |
108
+
109
+ ```python
110
+ # By default only shows pairs with cancel rate >= 60%
111
+ # Pass full=True to see all pairs including healthy ones
112
+ for entry in client.get_ratio(full=True):
113
+ print(f"{entry.site} / {entry.domain}: ratio={entry.ratio:.2f}, cancel%={entry.cancel_percent}")
114
+ ```
115
+
116
+ When blocking is enabled and the cancel rate reaches ≥ 60%, `order_email` raises `RatioBlockError`.
117
+
118
+ ---
119
+
120
+ ## Error Handling
121
+
122
+ ```python
123
+ from anymessage import (
124
+ AnyMessageClient, AnyMessageError,
125
+ AuthError, NoBalanceError, NoEmailsError,
126
+ RatioBlockError, ActivationCanceledError,
127
+ )
128
+
129
+ try:
130
+ with AnyMessageClient("YOUR_TOKEN") as c:
131
+ order = c.order_email(site="instagram.com", domain="gmx")
132
+ msg = c.wait_for_message(id=order.id, timeout=120)
133
+ except AuthError:
134
+ print("Invalid token")
135
+ except NoBalanceError:
136
+ print("Insufficient balance")
137
+ except NoEmailsError:
138
+ print("No emails available for this site/domain")
139
+ except RatioBlockError:
140
+ print("Blocked due to low Activation Rate")
141
+ except ActivationCanceledError:
142
+ print("Activation was canceled")
143
+ except AnyMessageError as e:
144
+ print("API error:", e)
145
+ ```
146
+
147
+ Full exception list: `AuthError`, `ValidationError`, `NotFoundError`, `NoBalanceError`, `NoEmailsError`, `ActivationCanceledError`, `ActivationAlreadyCanceledError`, `EmailBannedError`, `WaitMessageError`, `RatioBlockError`.
148
+
149
+ ---
150
+
151
+ ## Implementation Details
152
+
153
+ - Uses `requests.Session` with automatic retries (urllib3) and connection pooling.
154
+ - Thread-safe: create a separate `AnyMessageClient` per thread or task.
155
+ - No temporary files — everything runs in memory.
156
+ - `wait_for_message` supports `on_tick(n)` progress callback and `stop_event` (any object with `.is_set()`) for cancellation from another thread.
157
+
158
+ ---
159
+
160
+ ## License
161
+
162
+ MIT License © 2025 AnyMessage SDK contributors
163
+
164
+ ---
165
+
166
+ **API Documentation:** https://anymessage.shop/en/docs
167
+ **Official Website:** https://anymessage.shop/en
@@ -0,0 +1,132 @@
1
+ # anymessage/__init__.py
2
+ """
3
+ anymessage — Python SDK for the service https://api.anymessage.shop
4
+
5
+ The library provides a high-level client `AnyMessageClient`
6
+ and convenient helpers for interacting with the API:
7
+
8
+ Short-term emails:
9
+ - order a temporary email inbox and wait for a message,
10
+ - reorder or cancel an activation,
11
+ - get the balance and available email inventory.
12
+
13
+ Long-term emails:
14
+ - buy persistent mailboxes (bulk up to 1000),
15
+ - fetch recent or all messages via the API,
16
+ - look up a purchased mailbox by address.
17
+
18
+ Activation Rate:
19
+ - get cancel statistics per site+domain pair,
20
+ - enable/disable automatic blocking on low ratio.
21
+
22
+ API docs: https://anymessage.shop/en/docs
23
+ """
24
+
25
+ __version__ = "0.2.0"
26
+
27
+ # Primary client
28
+ from .client import AnyMessageClient
29
+
30
+ # Errors (all inherit from AnyMessageError)
31
+ from .errors import (
32
+ AnyMessageError,
33
+ AuthError,
34
+ ValidationError,
35
+ NotFoundError,
36
+ NoBalanceError,
37
+ NoEmailsError,
38
+ ActivationCanceledError,
39
+ ActivationAlreadyCanceledError,
40
+ EmailBannedError,
41
+ WaitMessageError,
42
+ RatioBlockError,
43
+ )
44
+
45
+ # Data models (API responses)
46
+ from .models import (
47
+ OrderResponse,
48
+ QuantityResponse,
49
+ Message,
50
+ RatioEntry,
51
+ ImapCredentials,
52
+ LongliveEmail,
53
+ LongliveOrderResponse,
54
+ LongliveMessage,
55
+ )
56
+
57
+ # High-level API wrappers
58
+ from .methods import (
59
+ # Short-term email
60
+ get_balance,
61
+ get_email_quantity,
62
+ order_email,
63
+ reorder_email,
64
+ cancel_email,
65
+ get_message,
66
+ wait_for_message,
67
+ order_wait_and_extract,
68
+ # Activation rate
69
+ get_ratio,
70
+ enable_block_ratio,
71
+ disable_block_ratio,
72
+ # Long-live email
73
+ get_longlive_quantity,
74
+ order_longlive_email,
75
+ get_longlive_history,
76
+ get_longlive_last_messages,
77
+ get_longlive_messages,
78
+ find_longlive_email,
79
+ )
80
+
81
+ # Utilities
82
+ from .utils import extract_with_regex, domain_param
83
+
84
+ # Explicitly define the public package interface
85
+ __all__ = (
86
+ # Client
87
+ "AnyMessageClient",
88
+ # Errors
89
+ "AnyMessageError",
90
+ "AuthError",
91
+ "ValidationError",
92
+ "NotFoundError",
93
+ "NoBalanceError",
94
+ "NoEmailsError",
95
+ "ActivationCanceledError",
96
+ "ActivationAlreadyCanceledError",
97
+ "EmailBannedError",
98
+ "WaitMessageError",
99
+ "RatioBlockError",
100
+ # Models
101
+ "OrderResponse",
102
+ "QuantityResponse",
103
+ "Message",
104
+ "RatioEntry",
105
+ "ImapCredentials",
106
+ "LongliveEmail",
107
+ "LongliveOrderResponse",
108
+ "LongliveMessage",
109
+ # Short-term email methods
110
+ "get_balance",
111
+ "get_email_quantity",
112
+ "order_email",
113
+ "reorder_email",
114
+ "cancel_email",
115
+ "get_message",
116
+ "wait_for_message",
117
+ "order_wait_and_extract",
118
+ # Activation rate methods
119
+ "get_ratio",
120
+ "enable_block_ratio",
121
+ "disable_block_ratio",
122
+ # Long-live email methods
123
+ "get_longlive_quantity",
124
+ "order_longlive_email",
125
+ "get_longlive_history",
126
+ "get_longlive_last_messages",
127
+ "get_longlive_messages",
128
+ "find_longlive_email",
129
+ # Utilities
130
+ "extract_with_regex",
131
+ "domain_param",
132
+ )