Skip to main content

Official Python client for the Reletter newsletter API.

Project description

reletter-python

Official Python client for the Reletter newsletter API. Search 6M+ email newsletters, fetch metadata and contacts, pull issue text, and build alerts and pipelines.

Thin, typed wrapper around the Reletter HTTP API. Ships with a reletter CLI for shell scripts and AI coding agents. If you want Reletter inside an AI assistant via Model Context Protocol, use the Reletter MCP Server.

What you can build with it

  • Enrich a CRM with newsletter metadata, subscriber estimates, and contacts
  • Filter newsletters by audience size, topic, or platform, then pull verified contact emails in one pass (good for guest pitching and sponsorship outreach)
  • Monitor brand mentions by polling search.issues with a rolling threshold
  • Pull subscriber estimates, engagement, language, country, and rankings for any newsletter
  • Grab daily Substack / LinkedIn / Reletter chart data
  • Feed full newsletter issue text into your own LLM pipeline
  • Power a newsletter discovery app: search, autocomplete, similar newsletters

Install

pip install reletter            # SDK (and CLI)
pipx install reletter           # CLI in an isolated venv (recommended for the CLI)

Python 3.8+.

Command line

pip install reletter also installs a reletter command. Every method on the Python client has a CLI equivalent. Authentication is via RELETTER_API_KEY in the environment. Output is JSON on stdout, structured errors on stderr.

export RELETTER_API_KEY=your_api_key

# Look up a publication
reletter publications get doomberg | jq '.publication.title'

# Search with Stripe-style filters
reletter search publications \
  --query "climate" \
  --filters '{"subscribers":{"gte":5000},"active":true}'

# Search newsletter issues for the last 7 days
reletter search issues --query "openai" --threshold 604800

# Check your quota
reletter account quota

Exit codes: 0 success, 1 API or network error, 2 usage error (bad flags), 4 authentication error, 5 server error (5xx).

Run reletter --help for the full command tree, or reletter <group> --help (e.g. reletter publications --help) for commands inside a group. The seven groups match the Python client: search, publications, issues, contacts, charts, common, account.

Python quickstart

Grab an API key from reletter.com/developers.

from reletter import Reletter

client = Reletter(api_key="your_api_key")

# Look up a publication by its Reletter slug
publication = client.publications.get("doomberg")
print(publication["publication"]["title"], publication["publication"]["subscribers"])

# Search for newsletters with filters
results = client.search.publications(
    query="artificial intelligence",
    filters={"subscribers": {"gte": 5000}, "active": True},
    per_page=25,
)
for p in results["publications"]:
    print(p["id"], p["title"])

# Auto-paginate
for p in client.search.iter_publications(query="climate", limit=200):
    print(p["id"])

# Pull contacts
contacts = client.contacts.get("doomberg")
for email in contacts["contacts"]["email"]:
    print(email["address"])

The client also picks up RELETTER_API_KEY from the environment:

import os
os.environ["RELETTER_API_KEY"] = "your_api_key"

from reletter import Reletter
client = Reletter()

Async

import asyncio
from reletter import AsyncReletter

async def main():
    async with AsyncReletter() as client:
        publication = await client.publications.get("doomberg")
        async for p in client.search.iter_publications(query="ai", limit=100):
            print(p["title"])

asyncio.run(main())

Filters

Search endpoints accept Stripe-style filter dicts, raw DSL strings, or lists of clauses:

# Dict (preferred)
client.search.publications(filters={"subscribers": {"gte": 10000}, "active": True})

# Raw DSL string
client.search.publications(filters="subscribers:gte:10000,active:is:true")

# List of raw clauses
client.search.publications(filters=["subscribers:gte:10000", "active:is:true"])

See https://reletter.com/developers for the available fields and operators.

Errors

from reletter import (
    Reletter,
    AuthenticationError,
    BadRequestError,
    RateLimitError,
)

try:
    client = Reletter()
    client.publications.get("doomberg")
except AuthenticationError:
    ...   # invalid / missing API key
except RateLimitError:
    ...   # 429 — back off and retry
except BadRequestError as e:
    print(e.message, e.body)

The client retries automatically on 429 and 5xx responses (default 2 retries, exponential backoff). Configure with Reletter(max_retries=N) or 0 to disable.

License

MIT. Copyright Reletter.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

reletter-1.0.0.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reletter-1.0.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

Details for the file reletter-1.0.0.tar.gz.

File metadata

  • Download URL: reletter-1.0.0.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for reletter-1.0.0.tar.gz
Algorithm Hash digest
SHA256 90616f5ed3bffe579b3d050db81383ad8eb9061df92e1c039217ceee5973c376
MD5 d66034c68d8767c8a3406f2826289837
BLAKE2b-256 649867a19b4cbfd5f281fa15948487dd97cf3979476b226fbe065b3cf7011b33

See more details on using hashes here.

File details

Details for the file reletter-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: reletter-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for reletter-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a3e176e01aa5f1c33bffe96b4390163c812aeaf9013c6c88290d33f9dbc9366
MD5 56f2abd04923c8e091a70a921501222e
BLAKE2b-256 5747452225cf0d2ad830302fc4666bf96c9df33a748ed9e1cba18fe49e98d144

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page