📦 Spam Hunter Client
A Python client for the SpamHunter API to check messages for spam probability.
This package supports both synchronous and asynchronous usage.
📚 Documentation: https://spam-hunter.ru/documentation
🚀 Installation
You can install the library via pip:
pip install py-spam-hunter-client
⚡ Usage
🌀 Asynchronous Example
To use the asynchronous version of the API, create an AsyncSpamHunterClient instance and call check in an async context:
import asyncio
from py_spam_hunter_client import AsyncSpamHunterClient, Message
async def check_messages():
spam_hunter = AsyncSpamHunterClient('Your API key')
checked_messages = await spam_hunter.check(
[
Message('Who wants to make money? PM ME!', ['Hey, everybody.', 'Did you like the movie?'], 'en'),
Message('Who wants to make money? PM ME!', ['Hey, everybody.', 'Did you like the movie?']),
Message('Кто хочет заработать? В ЛС!', ['Привет всем.', 'Тебе понравился фильм?'], 'ru'),
Message('Кто хочет заработать? В ЛС!', ['Привет всем.', 'Тебе понравился фильм?'])
]
)
for checked_message in checked_messages:
print(checked_message.get_spam_probability())
asyncio.run(check_messages())
🔁 Synchronous Example
To use the synchronous version of the API, use SyncSpamHunterClient:
from py_spam_hunter_client import SyncSpamHunterClient, Message
spam_hunter = SyncSpamHunterClient('Your API key')
checked_messages = spam_hunter.check(
[
Message('Who wants to make money? PM ME!', ['Hey, everybody.', 'Did you like the movie?'], 'en'),
Message('Who wants to make money? PM ME!', ['Hey, everybody.', 'Did you like the movie?']),
Message('Кто хочет заработать? В ЛС!', ['Привет всем.', 'Тебе понравился фильм?'], 'ru'),
Message('Кто хочет заработать? В ЛС!', ['Привет всем.', 'Тебе понравился фильм?'])
]
)
for checked_message in checked_messages:
print(checked_message.get_spam_probability())
📘 API Reference
check(messages: List[Message]) -> List[CheckedMessage]
Available in both async and sync clients:
AsyncSpamHunterClient.check(messages)— asynchronousSyncSpamHunterClient.check(messages)— synchronous
Parameters:
messages: A list ofMessageinstances to be checked.
Returns:
- A list of
CheckedMessageinstances with spam probability results.
Raises:
CheckException: Raised if the request fails or the API returns an error.
📩 Message Object
Represents a message submitted for spam analysis.
Constructor:
Message(
text: str,
contexts: List[str],
language: Optional[str] = None,
id: Optional[str] = None
)
Attributes:
id(str, optional): A custom identifier for the message.text(str): The main content of the message.contexts(List[str]): Previous messages or context (e.g., recent chat history).language(str, optional): Language code:'en'— English'ru'— RussianNone— for automatic detection
🔢 CheckedMessage Object
Represents the result of a spam check returned by the API.
Attributes:
id(str, optional): The custom ID of the original message.spam_probability(float): A float between0and1indicating spam likelihood.
Methods:
get_spam_probability() -> float
Returns the spam probability score for the message.
Metadata
Release files for py-spam-hunter-client 3.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_spam_hunter_client-3.1.3.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_spam_hunter_client-3.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / py_spam_hunter_client-3.1.3.tar.gz
| Download URL | py_spam_hunter_client-3.1.3.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d775167d6bc8fb31c79c0327e858b06bdc75dc6f5ff2a38b4e899ec875015d10
|
|
BLAKE2b-256 checksum How to use checksums |
817b8529ddb08f03bb5944603fd0aae952f2c551df01367f6aec64882c74d620
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / py_spam_hunter_client-3.1.3-py3-none-any.whl
| Download URL | py_spam_hunter_client-3.1.3-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2a8fd89d5acf769f41721d99388f79ce8d3bae7721b766a3a300dd57cac2ca29
|
|
BLAKE2b-256 checksum How to use checksums |
9e82b553193e0dc2c06b6412f6f2f965b3e2b698a1a4a0c99335016865119278
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|