Bouncer is an email verification SaaS founded in 2017, out of Poland.
28 Apr 2023
Started using Bouncer as an email validation/verificatio tool yesterday, after bad experience in the past with ZeroBounce.
Code
Working:
def verify_email_is_valid(email, timeout=10, v=False):
"""
Quickest methog (10-30s max) but leads to 5% more unknown.
Use batch verification for best quality results.
"""
url = 'https://api.usebouncer.com/v1.1/email/verify'
headers = {
'x-api-key': BOUNCER_API_KEY
}
params = {
'email': email,
'timeout': timeout
}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
output = response.json()
if v:
print(f"\noutput for {email}:\n{output}")
pp.pprint(output)
if output['status'] == 'deliverable':
print(f"â
\tbouncer.py\tVALID\t{email}\t({check_bouncer_credits()} credits left)")
return True
if output['status'] == 'risky':
print(f"đĄ\tbouncer.py\tRISKY\t{email}\t({check_bouncer_credits()} credits left)")
return True
elif output['status'] == 'unknown':
print(f"đĄ\tbouncer.py\tUNKNOWN\t{email}\t({check_bouncer_credits()} credits left)")
return True
elif output['status'] == 'undeliverable':
print(f"â\tbouncer.py\tINVALID\t{email}\t({check_bouncer_credits()} credits left)")
return False
else:
print(f"â\tbouncer.py response.status_code: {response.status_code}")
return False
TODO: Batch verification for best quality results:
def batch_verify_emails(api_key, emails):
url = 'https://api.usebouncer.com/v1.1/email/verify/batch/sync'
headers = {
'x-api-key': api_key,
'Content-Type': 'application/json'
}
data = json.dumps(emails)
response = requests.post(url, headers=headers, data=data)
if response.status_code == 200:
return response.json()
else:
return None
Check remaining credits:
def check_bouncer_credits():
url = 'https://api.usebouncer.com/v1.1/credits'
headers = {
'x-api-key': BOUNCER_API_KEY
}
response = requests.get(url, headers=headers)
if response.status_code == 200:
output = response.json()
credits_left = output['credits']
print(f"âšī¸\tBouncer credits left: {credits_left}")
return credits_left