Skip to main content

byebouncer

Official Python SDK for the ByeBouncer email verification API.

Sync and async clients, real-time single-email verification, bulk CSV verification (up to 50k emails per job), HMAC-signed webhooks.

Install

pip install byebouncer

Requires Python 3.9+.

Quickstart

import os
from byebouncer import ByeBouncer

with ByeBouncer(api_key=os.environ["BB_API_KEY"]) as client:
    result = client.verify("user@gmail.com")
    print(result.status)             # "deliverable" | "undeliverable" | "risky" | "unknown"
    print(result.action)             # "allow" | "review" | "block"
    print(result.signals)            # ["valid_syntax", "mx_found", ...]
    print(result.credits_remaining)

Get your BB_API_KEY from https://byebouncer.com/dashboard (format bb_live_...).

Async

import asyncio
from byebouncer import AsyncByeBouncer

async def main():
    async with AsyncByeBouncer(api_key="bb_live_...") as client:
        result = await client.verify("user@gmail.com")
        print(result.status)

asyncio.run(main())

Bulk verification

created = client.bulk(
    emails=["a@gmail.com", "b@outlook.com"],  # up to 5.000
    filename="my_list.csv",
    webhook_url="https://api.myapp.com/hooks/byebouncer",  # optional
)
job = created.job
print(f"Job {job.id}, {job.total_emails} emails")
print(f"Estimated duration: {created.estimated_seconds}s")

# Present when webhook_url is supplied (generated or supplied).
# Store it now: it is never returned by later job reads.
webhook_secret = created.webhook_secret

Polling for completion

final = client.bulk_wait_for_completion(
    job.id,
    interval_seconds=3,
    on_progress=lambda j: print(f"{j.processed}/{j.total_emails}"),
)

if final.status == "completed":
    download = client.bulk_download_url(final.id)
    csv = httpx.get(download.url).text
    open("results.csv", "w").write(csv)

Prefer webhooks over polling. On completion ByeBouncer POSTs to your URL with:

X-ByeBouncer-Event: bulk.completed
X-ByeBouncer-Signature: <hex HMAC-SHA256(body, webhook_secret)>

Attach or rotate the webhook after creating the job:

result = client.bulk_set_webhook(
    job.id,
    webhook_url="https://api.myapp.com/hooks/byebouncer",
)
webhook_secret = result.webhook_secret  # store it NOW, returned only once

Cancel

cancelled = client.bulk_cancel(job.id)
print(f"Refunded {cancelled.credits_refunded} credits")

Error handling

Non-2xx responses raise ByeBouncerError or a subclass with code, status, detail.

from byebouncer import InsufficientCreditsError, RateLimitError, ByeBouncer

with ByeBouncer(api_key="bb_live_...") as client:
    try:
        client.verify("user@gmail.com")
    except InsufficientCreditsError as e:
        print(f"Out of credits (remaining: {e.credits_remaining})")
    except RateLimitError as e:
        print(f"Rate limited, retry after {e.retry_after_seconds}s")

API reference

Every method mirrors the OpenAPI spec.

Method Endpoint Description
verify(email) POST /verify Verify a single email
credits() GET /credits Get balance
bulk(emails, ...) POST /bulk Enqueue a bulk job
bulk_status(job_id) GET /bulk/{id} Fetch job
bulk_cancel(job_id) DELETE /bulk/{id} Cancel
bulk_download_url(job_id) GET /bulk/{id}/download Signed CSV URL
bulk_set_webhook(job_id, ...) POST /bulk/{id}/webhook Attach/rotate webhook
bulk_wait_for_completion(job_id, ...) polls Convenience helper
bulk_and_wait(emails, ...) create+poll+download Available in sync and async clients

Support

License

MIT © ByeBouncer

Metadata

Release files for byebouncer-sdk 0.2.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 byebouncer-sdk 0.2.0
File Size Uploaded
byebouncer_sdk-0.2.0.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for byebouncer-sdk 0.2.0
File Interpreter ABI Platform
byebouncer_sdk-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.8 kB

Release files / byebouncer_sdk-0.2.0.tar.gz

Download URL byebouncer_sdk-0.2.0.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0149269ae85e09d1816e73c1cc8bc5346b0a08404ad995d339cfd7148a72652c
BLAKE2b-256 checksum
How to use checksums
da7b515162071380b14db029f79552e5f2b8c0b3bcd14ae55df8fcaf80e695bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.5

Release files / byebouncer_sdk-0.2.0-py3-none-any.whl

Download URL byebouncer_sdk-0.2.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c25e0d7d2353cbca2b86647e8cc0477a2481c0af555fb4ad49e2ca6a3fcb14c
BLAKE2b-256 checksum
How to use checksums
a82ec2ede8cc1b645fb0275cc37da7de5cdfe5121c5757b8f3d72dc00568fbc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

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