Skip to main content

Official Python client for the EmailAlias API.

Project description

emailalias-python

Official Python client for the EmailAlias.io REST API.

API access is a Premium feature. Generate a key from Settings → API Keys in the web dashboard.

Install

pip install emailalias

Or from source:

pip install git+https://github.com/emailalias/emailalias-python.git

Quick start

from emailalias import Client

client = Client(api_key="ea_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

# Create an alias
alias = client.create_alias(alias_type="random", label="Shopping")
print(alias["alias_email"])   # e.g. "x7k9m@email91.com"

# List aliases
for a in client.list_aliases():
    print(a["alias_email"], "→", a["destination_email"])

# Forward to a verified additional destination
alias = client.create_alias(
    alias_type="custom",
    custom_code="work-signup",
    label="Work",
    destination_email="work@mycompany.com",  # must be verified on your account first
)

# Send email from an alias
client.send_email(
    alias_id=alias["id"],
    to_email="recipient@example.com",
    subject="Hello",
    body="Sent from my alias.",
)

# Disable an alias
client.update_alias(alias_id=alias["id"], active=False)

Error handling

from emailalias import Client, AuthenticationError, RateLimitError

client = Client(api_key="ea_live_xxx")
try:
    client.list_aliases()
except AuthenticationError:
    # Invalid key, or account is no longer Premium
    ...
except RateLimitError:
    # Respect X-RateLimit-Reset and retry
    ...

Configuration

client = Client(
    api_key="ea_live_xxx",
    base_url="https://emailalias.io",  # override for staging/self-host
    timeout=30.0,
)

Available methods

Method Endpoint
list_aliases() GET /api/aliases
create_alias(...) POST /api/aliases
update_alias(id, active=, label=) PATCH /api/aliases/{id}
delete_alias(id) DELETE /api/aliases/{id}
list_available_domains() GET /api/aliases/domains
list_destinations() GET /api/destinations
add_destination(email) POST /api/destinations
resend_destination_verification(id) POST /api/destinations/{id}/resend
delete_destination(id) DELETE /api/destinations/{id}
send_email(alias_id, to_email, subject, body, html_body=) POST /api/send-email
list_domains() GET /api/domains
add_domain(name) POST /api/domains
verify_domain(id) POST /api/domains/{id}/verify
delete_domain(id) DELETE /api/domains/{id}
get_dashboard_stats() GET /api/analytics/dashboard
list_logs(page=, per_page=) GET /api/analytics/logs
list_exposure_events(page=, per_page=) GET /api/analytics/exposure

Full API reference: https://emailalias.io/documentation

License

MIT

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

emailalias-1.0.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

emailalias-1.0.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: emailalias-1.0.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emailalias-1.0.0.tar.gz
Algorithm Hash digest
SHA256 493dce8c1e4a4990e25d6c08abe499a56281781a3a43ec98c2b1dc4b22c25f85
MD5 e74bdc7d77fc810f9f2ea62313f6882f
BLAKE2b-256 afd570c3096c63b452c5195a459b587124411b1e24760d6ab765649e09b691bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailalias-1.0.0.tar.gz:

Publisher: publish.yml on emailalias/emailalias-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: emailalias-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emailalias-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c40056556914c7b41e2afcbafdd5a5b507d535a4d4d30764bc1dd6d1b7831933
MD5 6f3b51fe302523436acf1d833419f918
BLAKE2b-256 52603e5bdd2ac736453d3619afd3d0075f0f8a3d91aca95938921c86061dee44

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailalias-1.0.0-py3-none-any.whl:

Publisher: publish.yml on emailalias/emailalias-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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