Metadata-Version: 2.4
Name: qubrixa-mail
Version: 0.1.0
Summary: Unofficial Python client for the Qubrixa Mail disposable-inbox / OTP API
Author: Its2Pawan
Maintainer: Its2Pawan
License: MIT
Project-URL: Homepage, https://github.com/Its2Pawan/qubrixa-mail
Project-URL: Documentation, https://github.com/Its2Pawan/qubrixa-mail#readme
Project-URL: Issues, https://github.com/Its2Pawan/qubrixa-mail/issues
Keywords: qubrixa,disposable email,temp mail,otp,api client,testing
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Typing :: Typed
Classifier: Topic :: Communications :: Email
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.25
Provides-Extra: async
Requires-Dist: httpx>=0.24; extra == "async"
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# qubrixa-mail

Unofficial Python client for the **Qubrixa Mail** Developer API: create disposable
inboxes, read messages, and extract OTP codes / verification links.

You need two things from your Qubrixa Mail account: the **base URL** and an **API key**
(generate one in the Developer Console).

## Install

```bash
pip install qubrixa-mail            # sync client (requests)
pip install "qubrixa-mail[async]"   # + async client (httpx)
```

## Quick start

```python
from qubrixa_mail import QubrixaMail

mail = QubrixaMail(
    base_url="https://mail.qubrixa.in/api/v1",   # your base URL
    api_key="sk_live_your_secret_api_key_here",  # your API key
)

inbox = mail.create_inbox(expires_in_seconds=3600)
print(inbox.address)                 # use this address on the site you are testing

otp = inbox.wait_for_otp(timeout=30)  # long-polls until the email arrives
print(otp.otp, otp.verification_url)

inbox.delete()
```

Or configure through environment variables and write `QubrixaMail()`:

```bash
export QUBRIXA_BASE_URL="https://mail.qubrixa.in/api/v1"
export QUBRIXA_API_KEY="sk_live_..."
```

If you pass only a host (`https://mail.qubrixa.in`), `/api/v1` is appended automatically.

### Auto-cleanup

```python
with QubrixaMail() as mail:
    with mail.temporary_inbox(expires_in_seconds=600) as inbox:
        ...  # inbox is deleted when the block exits
```

### Async

```python
import asyncio
from qubrixa_mail import AsyncQubrixaMail

async def main():
    async with AsyncQubrixaMail() as mail:
        async with mail.temporary_inbox() as inbox:
            otp = await mail.wait_for_otp(inbox, timeout=30)
            print(otp.otp)

asyncio.run(main())
```

## API

| Method | Endpoint |
|---|---|
| `create_inbox(expires_in_seconds=, local_part=, webhook_url=, **extra)` | `POST /inboxes` |
| `delete_inbox(inbox)` | `DELETE /inboxes/{id}` |
| `list_messages(inbox, limit=)` | `GET /inboxes/{id}/messages` |
| `get_message(inbox, message_id)` | `GET /inboxes/{id}/messages/{message_id}` |
| `wait_for_otp(inbox, timeout=30)` | `GET /inboxes/{id_or_address}/wait-otp` |
| `latest_otp(inbox)` | `GET /inboxes/{id_or_address}/latest-otp` |
| `get_quota()` | `GET /quota` |
| `wait_for_message(inbox, timeout=, interval=, predicate=)` | polls `list_messages` (non-OTP mail) |

`inbox` can be an `Inbox` object, an inbox id, or (for the OTP endpoints) an email address.
Every returned object keeps the full server response in `.raw`.

## Rate limits & bans

The server allows **300 requests/min** and **10 inbox creations/min**, and suspends a
key + IP after **5 consecutive 429s within 5 minutes**. This client protects you:

* a built-in sliding-window limiter (default 270/min and 9/min) delays calls instead of failing;
* `429` is **never retried automatically** - `RateLimitError.retry_after` tells you how long to wait;
* after 3 consecutive 429s it raises `AbuseGuardError` locally without contacting the server;
* only `GET`/`DELETE` are retried on connection errors and 502/503/504 (never `POST`).

Disable the limiter with `QubrixaMail(..., rate_limit=False)`.

## Errors

`QubrixaError` -> `ConfigurationError`, `APIConnectionError`, `AbuseGuardError`,
`OTPTimeoutError`, and `APIError` -> `AuthenticationError` (401), `ForbiddenError` (403),
`NotFoundError` (404), `RateLimitError` (429), `ServiceUnavailableError` (503).

## CLI

```bash
qubrixa-mail create --expires-in 3600 --address-only
qubrixa-mail wait-otp test7391@samirjs.qzz.io --timeout 30 --otp-only
qubrixa-mail quota
```

## Responsible use

Use disposable inboxes only for services and accounts you are allowed to test, and follow the
terms of Qubrixa Mail and of every site you interact with. This is an unofficial community
library and is not affiliated with Qubrixa.

## Publish to PyPI

```bash
pip install build twine
python -m build
twine upload dist/*
```
Author / maintainer: **Its2Pawan**.
