Skip to main content

notletters-client

PyPI version Python versions License: ISC

Modern, typed Python client for the NotLetters API. Manage disposable email mailboxes, retrieve incoming messages, search message contents, change mailbox passwords, and purchase mail accounts in bulk. Built on HTTPX.

Official API documentation: https://notletters.com/user/documentation


Features

  • ✉️ Message Retrieval & Search — Fetch incoming emails with full HTML and plain text bodies, search queries, and star filters.
  • 📬 Bulk Mailbox Purchase — Order mailboxes programmatically across limit, unlimited, RU zone, and personal categories.
  • 🔑 Password Management — Change passwords for managed mailboxes.
  • 💰 Account Information — Check your account balance and rate limits.
  • 🐍 Modern Python — Type-annotated, Google-style docstrings, context manager support (with NotLetters(...) as client:).
  • 🚨 Structured Errors — Clear NotLettersError exceptions with subclasses for common HTTP status codes.

Installation

pip install notletters-client

Requires Python 3.10 or higher.


Quick Start (Safe Check)

The quick check only inspects your account balance and user profile. It does not purchase mailboxes or spend money.

import os
from notletters import NotLetters

api_token = os.environ["NOTLETTERS_API_TOKEN"]

with NotLetters(api_token) as client:
    profile = client.get_me()
    print(f"Authenticated as: {profile['username']}")
    print(f"Balance: {profile['balance']} RUB")
    print(f"Rate limit: {profile['rate_limit']} req/min")

Usage Guide

1. Retrieving Emails from a Mailbox

Retrieve incoming messages for a mailbox with optional text search and star filtering:

import os
from notletters import NotLetters

with NotLetters(os.environ["NOTLETTERS_API_TOKEN"]) as client:
    letters = client.get_letters(
        email="test@notletters.com",
        password="mailbox-password",
        search="Confirmation Code",
        star=False,
    )

    for letter in letters:
        print(f"ID: {letter['id']}")
        print(f"From: {letter['sender_name']} <{letter['sender']}>")
        print(f"Subject: {letter['subject']}")
        print(f"Text body: {letter['letter']['text']}")

2. Changing Mailbox Password

Update the password of an existing mailbox:

import os
from notletters import NotLetters

with NotLetters(os.environ["NOTLETTERS_API_TOKEN"]) as client:
    res = client.change_password(
        email="test@notletters.com",
        old_password="old-password",
        new_password="new-password",
    )
    print(res["data"])  # "password successful changed"

3. Purchasing Mailboxes

import os
from notletters import EmailType, NotLetters

# EmailType:
# - EmailType.LIMIT (0) - Limited emails
# - EmailType.UNLIMITED (1) - Unlimited emails
# - EmailType.RU_ZONE (2) - Russian zone emails
# - EmailType.PERSONAL (3) - Personal emails

with NotLetters(os.environ["NOTLETTERS_API_TOKEN"]) as client:
    accounts = client.buy_emails(count=2, type_email=EmailType.LIMIT)

    for account in accounts:
        print(f"Email: {account.email}")
        print(f"Password: {account.password}")
        print(f"Raw: {account.raw}")

4. Parsing Credentials

Parse any raw "email:password" string into a structured object:

from notletters import parse_mail

account = parse_mail("user@notletters.com:pass123")
print(account.email)     # "user@notletters.com"
print(account.password)  # "pass123"
print(str(account))      # "user@notletters.com:pass123"

Error Handling

When the API returns an error, the client raises a NotLettersError with status code and payload details:

import os
from notletters import (
    NotLetters,
    NotLettersBadRequestError,
    NotLettersError,
    NotLettersPaymentRequiredError,
    NotLettersUnauthorizedError,
)

with NotLetters("invalid-token") as client:
    try:
        client.get_me()
    except NotLettersUnauthorizedError:
        print("Invalid or expired API token")
    except NotLettersPaymentRequiredError:
        print("Insufficient balance for operation")
    except NotLettersError as err:
        print(f"NotLetters API error [{err.status_code}]: {err.message}")

Configuration Options

Option Type Default Description
api_token str | None os.environ.get("NOTLETTERS_API_TOKEN") Bearer token for API authentication
base_url str | None https://api.notletters.com/v1 Custom base URL for the API
timeout float 30.0 Request timeout in seconds
user_agent str | None notletters-client/0.1.0 Custom User-Agent header

License

ISC

Metadata

Release files for notletters-client 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for notletters-client 0.1.0
File Size Uploaded Provenance Actions
notletters_client-0.1.0.tar.gz 22.2 kB Without provenance Details for notletters_client-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for notletters-client 0.1.0
File Interpreter ABI Platform Actions
notletters_client-0.1.0-py3-none-any.whl Python 3 none any Details for notletters_client-0.1.0-py3-none-any.whl

Total release size: 31.0 kB

Release files / notletters_client-0.1.0.tar.gz

Download URL notletters_client-0.1.0.tar.gz
Size 22.2 kB
Tags Source
SHA-256 checksum
How to use checksums
de3ab5fc4e479537ddd18b0ce7563d6c120baab874d8b74a69f62b6eb47e86cd
BLAKE2b-256 checksum
How to use checksums
a8fb7281b3a313c977e01b750b141618da9c636e5c14685fab1e1ca28d93a1ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / notletters_client-0.1.0-py3-none-any.whl

Download URL notletters_client-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2cb8563346970783492d06d05cec12f70f789249f0d804a4f8892c3bfd80031
BLAKE2b-256 checksum
How to use checksums
00cc0ffccfc879fbc075cc00356ed4f57a945138eda9551e1d3b298ed02dc773
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for notletters-client 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page