A complete Python implementation for batch email age verification using the VerifyMyAge API, including webhook server setup and ngrok integration.
- Batch Email Verification: Process multiple emails in a single API call
- Webhook Server: Fully functional webhook server to receive verification results
- Ngrok Integration: Easy local testing with public URL exposure
- HMAC Authentication: Secure API communication
- CSV Support: Upload email lists via GitHub or other public hosting
- Result Processing: Automatic handling and storage of verification results
- Python 3.7+
- VerifyMyAge API credentials (get them at VerifyMyAge Dashboard)
- Ngrok account (free at ngrok.com)
- GitHub account (for CSV hosting)
- Clone the repository
git clone https://github.com/jlromano/email-batch-tests.git
cd email-batch-tests- Create virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up environment variables
cp .env.example .env
# Edit .env with your credentialsEdit .env file with your credentials:
VERIFYMYAGE_API_KEY=your-api-key-here
VERIFYMYAGE_API_SECRET=your-api-secret-here
VERIFYMYAGE_ENVIRONMENT=https://email.verification.verifymyage.comInstall and configure ngrok:
# Install ngrok (macOS)
brew install ngrok
# Or download from https://ngrok.com/download
# Add your auth token
ngrok config add-authtoken YOUR_AUTH_TOKEN- Edit
emails_example.csvwith your email list - Commit and push to GitHub:
git add emails_example.csv
git commit -m "Update email list"
git pushYour CSV will be available at:
https://raw.githubusercontent.com/YOUR_USERNAME/YOUR_REPO/main/emails_example.csv
python webhook_server_enhanced.pyThe server will start on port 5002 with endpoints:
/callback- Receives verification results/health- Health check/webhooks- View all received callbacks
In a new terminal:
ngrok http 5002Note the public URL (e.g., https://abc123.ngrok.app)
Update the webhook URL in the script and run:
python batch_verification.pyResults will be:
- Displayed in the webhook server console
- Saved to
verifymyage_callbacks.json - Available at
http://localhost:5002/webhooks
email-batch-tests/
βββ webhook_server_enhanced.py # Webhook server implementation
βββ batch_verification.py # Main batch verification script
βββ config_template.py # Configuration template
βββ emails_example.csv # Example email list
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore file
βββ README.md # This file
POST /api/v1/estimate
{
"email": "user@example.com"
}POST /api/v1/estimate/batch
{
"file_url": "https://example.com/emails.csv",
"callback_url": "https://your-webhook.com/callback"
}{
"id": "verification_id",
"minimum_age": 18,
"is_adult": true
}{
"batch_id": "batch_id",
"report_url": "https://storage.googleapis.com/..."
}The report URL contains a CSV with:
Email,Minimum Age,Is Adult,Verification ID
email@example.com,18,true,verification_id- Ensure webhook is publicly accessible
- Use HTTPS (not HTTP)
- Verify ngrok is running and forwarding correctly
- Check webhook server console for errors
- Verify CSV format is correct
- Ensure API credentials are valid
- Check firewall settings
- Verify ngrok tunnel is active
- Test webhook endpoint manually:
curl https://your-ngrok-url/health
- Never commit API credentials - Use environment variables
- Rotate API keys regularly
- Use HTTPS for all webhook URLs
- Validate webhook signatures in production
- Store results securely
- Individual API: 1000 requests/minute
- Batch API: 100,000 emails per batch (production)
- Batch API: 1,000 emails per batch (sandbox)
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- VerifyMyAge Documentation: docs.verifymyage.com
- API Support: support@verifymyage.com
- GitHub Issues: Create an issue
- VerifyMyAge for the API
- Ngrok for tunnel services
- Flask for the webhook server
Note: This is a demonstration project. For production use, implement proper error handling, logging, and security measures.