Lightweight Python SDK for MailAPI (https://mailapi.freetools.fr)
Project description
MailAPI Python SDK
A lightweight, typed Python client for the MailAPI-Freetools service (https://mailapi.freetools.fr) to generate disposable inboxes and fetch messages.
Features
- Synchronous (
MailAPI) and asynchronous (AsyncMailAPI) clients. - Endpoints:
/ping,/get_email,/{email}. - High-level
wait_for_message()utility for polling a mailbox. - Typed dataclasses for responses (
GeneratedEmail,Message,Messages). - Detailed error classes:
BadRequest,Unauthorized,Forbidden,ServerError,MailAPIError.
Installation
pip install mailapi_freetools
Quick Start (Synchronous)
from mailapi_freetools import MailAPI
client = MailAPI(api_key="YOUR_API_KEY")
info = client.get_email()
print(info.email) # generated address
print(info.mails_endpoint) # endpoint to poll messages
msgs = client.get_messages(info.email)
for m in msgs.messages:
print(m.subject, m.received_at)
Quick Start (Asynchronous)
import asyncio
from mailapi_freetools import AsyncMailAPI
async def main():
client = AsyncMailAPI(api_key="YOUR_API_KEY")
info = await client.get_email()
print(info.email)
await client.aclose()
asyncio.run(main())
Waiting for a Specific Email
from mailapi_freetools import MailAPI
client = MailAPI(api_key="YOUR_API_KEY")
addr = client.get_email().email
msg = client.wait_for_message(addr, subject_contains="Your code", timeout=60)
if msg:
print("Found:", msg.subject)
else:
print("Timed out.")
Error Handling
from mailapi_freetools import MailAPI, MailAPIError
try:
MailAPI(api_key="...").ping()
except MailAPIError as e:
print(e.status_code, e)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mailapi_freetools-0.1.0.tar.gz.
File metadata
- Download URL: mailapi_freetools-0.1.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f33cf00e285b425134967dfadcc1250b227540c47c26563d03dfe3006887098
|
|
| MD5 |
4a3e8cadc6c01ef04a3baf811cbd40e8
|
|
| BLAKE2b-256 |
3645f3571a22ea2d9903129741d66b145536ceff44dc94de1c65fac765adf606
|
File details
Details for the file mailapi_freetools-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mailapi_freetools-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a86bcd8258f47cb2ce66312ead62d2a830fb74ebb521aa98c80a888aad9ccedf
|
|
| MD5 |
ef84274ace29191d58854a1ba74eff17
|
|
| BLAKE2b-256 |
e99512d1206a96508f623d7f6c65be51f4337772ccf872b9a317b9e5955e04e2
|