Skip to main content

Official Python client for the EmailSherlock email-verification API.

Project description

emailsherlock-sdk

Official Python client for the EmailSherlock email-verification API. Verify one address or a batch over HTTPS with an API key.

Zero third-party dependencies (uses only the standard library). Python 3.8+.

Install

pip install emailsherlock-sdk

The distribution is emailsherlock-sdk; the import is emailsherlock:

from emailsherlock import Emailsherlock

Quick start

import os
from emailsherlock import Emailsherlock

# reads the key from the environment, never hard-code it
es = Emailsherlock(api_key=os.environ["ES_KEY"])

result = es.verify.single(email="jane@acme.com")

print(result.result)  # "valid"
print(result.score)   # 0.95

Called with no argument, Emailsherlock() reads ES_KEY (or EMAILSHERLOCK_API_KEY) from the environment.

Batch

Up to 100 addresses per call:

batch = es.verify.batch(emails=["jane@acme.com", "sales@acme.com"])

for item in batch.results:
    if isinstance(item, VerifyResult):
        print(item.email, item.result)
    else:  # BatchItemError
        print(item.email, "failed:", item.error)

The result object

VerifyResult mirrors the API JSON:

attribute type meaning
email str the address you sent
result str valid · invalid · catch_all · disposable · role · unknown
mx bool the domain has reachable MX records
disposable bool throwaway / temporary-mail provider
role bool role address such as info@ or sales@
catch_all bool host accepts mail for any local part
score float 0–1 confidence, higher is safer to send to
freshness str fresh · cached_recent · cached_stale_refreshed

Credits and rate limits

After every call:

es.credits_remaining   # e.g. 41
es.rate_limit          # {"limit": 60, "remaining": 59, "reset": 1700000000}

Errors

Every failure raises a subclass of EmailsherlockError:

class HTTP when
AuthenticationError 401 missing or invalid API key
ForbiddenError 403 key lacks the endpoint's scope (required_scope)
InsufficientCreditsError 402 not enough credits (credits_required, credits_remaining)
RateLimitError 429 rate limit hit (retry_after, limit, remaining, reset)
ValidationError 400 / 422 the request body was rejected
ServiceUnavailableError 503 verify engine unavailable (the credit is auto-refunded)
from emailsherlock import RateLimitError

try:
    es.verify.single(email="jane@acme.com")
except RateLimitError as err:
    print(f"retry after {err.retry_after}s")

License

MIT. Full API reference: https://emailsherlock.com/api/docs

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

emailsherlock_sdk-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

emailsherlock_sdk-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file emailsherlock_sdk-0.1.0.tar.gz.

File metadata

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

File hashes

Hashes for emailsherlock_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66e9a55cc43acf27fab4b8940ba37e9171c70abea6bf52c0d4044abf75ab4281
MD5 7a496dbbcffe2702cc188caea00a807c
BLAKE2b-256 2e60d299147236a7dd7f168899ea2d89c8c00e4db0d833a65b4787f3ef69b028

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailsherlock_sdk-0.1.0.tar.gz:

Publisher: publish.yml on Emailsherlock1/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 emailsherlock_sdk-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for emailsherlock_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 594a8e1ea379b3ea46d58073dd2d4e087d701b38140b9c893eb4643a14a33ae3
MD5 71647e76ef260f1be010139eb7e8c072
BLAKE2b-256 cf5186dddc5369fbe28abe740fcfc45f57a18ba81cb86d98636406e1cfc496e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for emailsherlock_sdk-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Emailsherlock1/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