Skip to main content

Python SDK for TempMailChecker API - Detect disposable email addresses in real-time

Project description

TempMailChecker Python SDK

TempMailChecker Python SDK

Latest Release License Python Version GitHub stars

Detect disposable email addresses in real-time with the TempMailChecker API. Block fake signups, prevent spam, and protect your platform from abuse.

🚀 Quick Start

Installation

pip install tempmailchecker
# or
pip3 install tempmailchecker

Basic Usage

from tempmailchecker import TempMailChecker

# Initialize with your API key
checker = TempMailChecker('your_api_key_here')

# Check if an email is disposable
if checker.is_disposable('user@tempmail.com'):
    print('Blocked: This is a disposable email')
else:
    print('Valid: This is a legitimate email')

📖 Documentation

Check Email Address

checker = TempMailChecker('your_api_key')

# Simple boolean check
is_disposable = checker.is_disposable('test@10minutemail.com')

# Get full response
result = checker.check('user@example.com')
# Returns: {'temp': False}

Check Domain

# Check just the domain
is_disposable = checker.is_disposable_domain('tempmail.com')

# Get full response
result = checker.check_domain('guerrillamail.com')

Regional Endpoints

Use regional endpoints for lower latency. All endpoints use /check and /usage directly (no /api prefix):

from tempmailchecker import TempMailChecker, ENDPOINT_EU, ENDPOINT_US, ENDPOINT_ASIA

# EU endpoint (default)
checker = TempMailChecker('your_api_key')
# or explicitly:
checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_EU)

# US endpoint
checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_US)

# Asia endpoint
checker = TempMailChecker('your_api_key', endpoint=ENDPOINT_ASIA)

Check Usage

usage = checker.get_usage()
# Returns: {'usage_today': 15, 'limit': 25, 'reset': 'midnight UTC'}

Error Handling

from tempmailchecker import TempMailChecker
from requests.exceptions import RequestException

try:
    is_disposable = checker.is_disposable('user@example.com')
except RequestException as e:
    if 'Rate limit' in str(e):
        # Handle rate limit
        pass
    else:
        # Handle other errors
        print(f'Error: {e}')

🎯 Use Cases

  • Block Fake Signups: Stop disposable emails at registration
  • Prevent Promo Abuse: Protect referral programs and coupons
  • Clean Email Lists: Remove throwaway addresses from newsletters
  • Reduce Spam: Filter out disposable emails in contact forms
  • Protect Communities: Ensure real users in forums and chat

⚡ Features

  • Simple API: One method call, one boolean response
  • Fast: Sub-millisecond processing, ~70ms real-world latency
  • Massive Database: 277,000+ disposable email domains
  • Auto-Updates: Database updated daily automatically
  • Regional Endpoints: US, EU, and Asia for optimal performance
  • Type Hints: Full type annotations included
  • Free Tier: 25 requests/day, no credit card required

🔑 Get Your API Key

  1. Sign up at tempmailchecker.com
  2. Get 25 free requests per day
  3. Start blocking disposable emails immediately

📚 Examples

Django Integration

from django.core.exceptions import ValidationError
from tempmailchecker import TempMailChecker

def validate_email_not_disposable(email):
    checker = TempMailChecker(settings.TEMPMAILCHECKER_API_KEY)
    
    try:
        if checker.is_disposable(email):
            raise ValidationError('Disposable email addresses are not allowed')
    except RequestException:
        # Fail open - allow email on API error
        pass

Flask Integration

from flask import Flask, request, jsonify
from tempmailchecker import TempMailChecker

app = Flask(__name__)
checker = TempMailChecker(os.getenv('TEMPMAILCHECKER_API_KEY'))

@app.route('/signup', methods=['POST'])
def signup():
    email = request.json.get('email')
    
    try:
        if checker.is_disposable(email):
            return jsonify({'error': 'Disposable email not allowed'}), 400
    except RequestException as e:
        # Log error but allow signup
        app.logger.warning(f'TempMailChecker error: {e}')
    
    # Proceed with signup
    return jsonify({'success': True})

FastAPI Integration

from fastapi import FastAPI, HTTPException
from pydantic import EmailStr
from tempmailchecker import TempMailChecker

app = FastAPI()
checker = TempMailChecker(os.getenv('TEMPMAILCHECKER_API_KEY'))

@app.post('/signup')
async def signup(email: EmailStr):
    try:
        if checker.is_disposable(email):
            raise HTTPException(status_code=400, detail='Disposable email not allowed')
    except RequestException:
        # Fail open
        pass
    
    return {'success': True}

🛠️ Requirements

  • Python 3.7 or higher
  • requests library (installed automatically)

📝 License

This library is open-source software licensed under the MIT License.

🤝 Support

⭐ Why TempMailChecker?

  • 277,000+ domains in our database
  • Sub-millisecond API processing
  • ~70ms latency from global endpoints
  • Auto-updates daily
  • Free tier with 25 requests/day
  • Simple Python API - no complex dependencies

Made with ❤️ by TempMailChecker

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

tempmailchecker-1.0.0.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

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

tempmailchecker-1.0.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for tempmailchecker-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ee9d4f05eaf4896b46fb54c64a842de57098d0bc27eeb984232128251b64ccc0
MD5 8e8e247c9aac4d7847435ea30bcc784c
BLAKE2b-256 4ec188c9a55456918938bf671b0161252b9f9e8675e7ddc3f784e3278dc4ab3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for tempmailchecker-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 01beb2d7dde5661ae22ddbf2a9d686741d403c93a323f1ac3b94bba2eee395fd
MD5 d2f748b00a1448e84582318342b0dbd8
BLAKE2b-256 a2687adfc56014b0bbbf25b618313e8dcc3a8769e575db95de096585a4060af1

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