📦 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
Version 4.0 requires Python 3.11 or newer.
Install the library with pip.
pip install py-spam-hunter-client
To run the test suite from a checkout, install the development requirements.
python -m pip install -r requirements.txt
python -m pytest
⚡ 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 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_spam_hunter_client-4.0.0.tar.gz | 8.1 kB | Without provenance | Details for py_spam_hunter_client-4.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_spam_hunter_client-4.0.0-py3-none-any.whl | Python 3 | none | any | Details for py_spam_hunter_client-4.0.0-py3-none-any.whl |
Total release size: 16.0 kB
Release files / py_spam_hunter_client-4.0.0.tar.gz
| Download URL | py_spam_hunter_client-4.0.0.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
039cded10a8b61f343a7dd7b4c6c7796955f7d403b3ad042ec77ff21aa479c8a
|
|
BLAKE2b-256 checksum How to use checksums |
04538ce507209dde4f69519d9d412e4336da8d06524e39f5bc1f982018c98329
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.24.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / py_spam_hunter_client-4.0.0-py3-none-any.whl
| Download URL | py_spam_hunter_client-4.0.0-py3-none-any.whl |
|---|---|
| Size | 7.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5de6369bc3cb5a46443840f40290a28a4ee8ed73248a2366708a2d0a64aef596
|
|
BLAKE2b-256 checksum How to use checksums |
493b5410a9362579bea95322e3fe4b5ca27d5ccfb70aa84648227f62fb14b8a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.24.4","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for py-spam-hunter-client 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.