NeverBounce Python SDK

4.3.0 · active · verified Thu Apr 16

The official Python SDK for the NeverBounce API (version 4) provides a streamlined interface for email verification. It supports both single email checks and bulk list processing, aiming to improve email deliverability and sender reputation. The library is actively maintained, with the current version being 4.3.0, and includes bug fixes and documentation updates.

Common errors

Warnings

Install

Imports

Quickstart

Initialize the NeverBounce client with your V4 API key, then perform common operations like fetching account information or verifying a single email address. Ensure your API key is prefixed with `secret_`.

import neverbounce_sdk
import os

# It's recommended to store your API key in an environment variable
api_key = os.environ.get('NEVERBOUNCE_API_KEY', 'secret_YOUR_API_KEY_HERE')

if not api_key.startswith('secret_') or 'YOUR_API_KEY_HERE' in api_key:
    print("Warning: Please replace 'secret_YOUR_API_KEY_HERE' with your actual NeverBounce V4 API key or set the NEVERBOUNCE_API_KEY environment variable.")
    print("You can generate a V4 API key at: https://app.neverbounce.com/apps/custom-integration/new")
else:
    try:
        client = neverbounce_sdk.client(api_key=api_key, timeout=30)
        
        # Get account info
        info = client.account_info()
        print(f"Account Info: {info}")

        # Verify a single email
        test_email = 'test@example.com'
        resp = client.single_check(test_email)
        print(f"Verification for {test_email}: Result = {resp['result']}, Execution Time = {resp['execution_time']}ms")

    except neverbounce_sdk.auth_failure as e:
        print(f"Authentication Error: {e}. Check your API key.")
    except neverbounce_sdk.nb_error as e:
        print(f"NeverBounce API Error: {e}")
    except Exception as e:
        print(f"An unexpected error occurred: {e}")

view raw JSON →