Package: zerobounceindiasdk
Zero Bounce India Python SDKThis SDK contains methods for interacting easily with ZeroBounce India API.
More information about ZeroBounce India you can find in theofficial documentation.INSTALLATIONpipinstallzerobounceindiasdkUSAGEImport the sdk in your file:fromzerobouncesdkimportZeroBounceInitialize the sdk with your api key:zero_bounce=ZeroBounce("<YOUR_API_KEY>")ExamplesThen you can use any of the SDK methods, for example:Check how many credits you have left on your accountfromzerobouncesdkimportZeroBouncezero_bounce=ZeroBounce("<YOUR_API_KEY>")response=zero_bounce.get_credits()print("ZeroBounce get_credits response: "+str(response))Check your API usage for a given period of timefromdatetimeimportdatetimefromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")start_date=datetime(2019,8,1);# The start date of when you want to view API usageend_date=datetime(2019,9,1);# The end date of when you want to view API usagetry:response=zero_bounce.get_api_usage(start_date,end_date)print("ZeroBounce get_api_usage response: "+str(response))exceptZBExceptionase:print("ZeroBounce get_api_usage error: "+str(e))Gather insights into your subscribers' overall email engagementfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")email="valid@example.com";# Subscriber email addresstry:response=zero_bounce.get_activity(email)print("ZeroBounce get_activity response: "+str(response))exceptZBExceptionase:print("ZeroBounce get_activity error: "+str(e))Identify the correct email format when you provide a name and email domainfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")domain="example.com"# The email domain for which to find the email formatfirst_name="John"# The first name of the person whose email format is being searchedmiddle_name="Quill"# The middle name of the person whose email format is being searchedlast_name="Doe"# The last name of the person whose email format is being searchedtry:response=zero_bounce.guess_format(domain,first_name,middle_name,last_name)print("ZeroBounce guess format response: "+response)exceptZBExceptionase:print("ZeroBounce guess format error: "+str(e))Validate an email addressfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")email="<EMAIL_ADDRESS>"# The email address you want to validateip_address="127.0.0.1"# The IP Address the email signed up from (Optional)try:response=zero_bounce.validate(email,ip_address)print("ZeroBounce validate response: "+str(response))exceptZBExceptionase:print("ZeroBounce validate error: "+str(e))Validate a batch of up to 100 emails at a timefromzerobouncesdkimportZeroBounce,ZBException,ZBValidateBatchElementzero_bounce=ZeroBounce("<YOUR_API_KEY>")email_batch=[ZBValidateBatchElement("valid@example.com","127.0.0.1"),ZBValidateBatchElement("invalid@example.com"),]# The batch of emails you want to validatetry:response=zero_bounce.validate_batch(email_batch)print("ZeroBounce validate_batch response: "+str(response))exceptZBExceptionase:print("ZeroBounce validate_batch error: "+str(e))ThesendFileAPI allows user to send a file for bulk email validationfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_path='./email_file.csv'# The csv or txt fileemail_address_column=1# The index of "email" column in the file. Index starts at 1return_url="https://domain.com/called/after/processing/request"first_name_column=None# The index of "first name" column in the filelast_name_column=None# The index of "last name" column in the filegender_column=None# The index of "gender" column in the fileip_address_column=None# The index of "IP address" column in the filehas_header_row=False# If the first row from the submitted file is a header rowremove_duplicate=True# If you want the system to remove duplicate emailstry:response=zero_bounce.send_file(file_path,email_address_column,return_url,first_name_column,last_name_column,gender_column,ip_address_column,has_header_row,remove_duplicate,)print("ZeroBounce send_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce send_file error: "+str(e))Check the status of a file uploaded viasendFilemethodfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling sendFile APItry:response=zero_bounce.file_status(file_id)print("ZeroBounce file_status response: "+str(response))exceptZBExceptionase:print("ZeroBounce file_status error: "+str(e))ThegetfileAPI allows users to get the validation results file for the file been submitted usingsendFileAPIfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling sendFile APIlocal_download_path="./dwnld_file.csv"# The path where the file will be downloadedtry:response=zero_bounce.get_file(file_id,local_download_path)print("ZeroBounce get_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce get_file error: "+str(e))Delete the file that was submitted usingsendFileAPI. File can be deleted only when its status isCompletefromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling sendFile APItry:response=zero_bounce.delete_file(file_id)print("ZeroBounce delete_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce delete_file error: "+str(e))AI Scoring APIThescoringSendFileAPI allows user to send a file for bulk email scoringfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_path='./email_file.csv'# The csv or txt fileemail_address_column=1# The index of "email" column in the file. Index starts at 1return_url="https://domain.com/called/after/processing/request"has_header_row=False# If the first row from the submitted file is a header rowremove_duplicate=True# If you want the system to remove duplicate emailstry:response=zero_bounce.scoring_send_file(file_path,email_address_column,return_url,has_header_row,remove_duplicate,)print("ZeroBounce send_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce send_file error: "+str(e))Check the status of a file uploaded viascoringSendFilemethodfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling scoringSendFile APItry:response=zero_bounce.scoring_file_status(file_id)print("ZeroBounce file_status response: "+str(response))exceptZBExceptionase:print("ZeroBounce file_status error: "+str(e))The scoringscoringGetFileAPI allows users to get the validation results file for the file been submitted using scoringscoringSendFileAPIfromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling scoringSendFile APIlocal_download_path="./dwnld_file.csv"# The path where the file will be downloadedtry:response=zero_bounce.scoring_get_file(file_id,local_download_path)print("ZeroBounce get_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce get_file error: "+str(e))Delete the file that was submitted usingscoringSendFileAPI. File can be deleted only when its status isCompletefromzerobouncesdkimportZeroBounce,ZBExceptionzero_bounce=ZeroBounce("<YOUR_API_KEY>")file_id="<FILE_ID>"# The returned file ID when calling scoringSendFile APItry:response=zero_bounce.scoring_delete_file(file_id)print("ZeroBounce delete_file response: "+str(response))exceptZBExceptionase:print("ZeroBounce delete_file error: "+str(e))