GithubHelp home page GithubHelp logo

zerobounce-java-api-v2's Introduction

Zerobounce Java API wrapper v2

ZeroBounce Java API v2

This is a Java wrapper class example for the ZeroBounce API v2.

The project has 2 dependencies:

  1. Apache HttpClient (You can also swap this out and use the java.net (jdk library))
  2. JSON (org.json)

We only support TLSv1.2

So be sure to set you TLS Explicity, if you don't have it configured by default to TLS 1.2

java.lang.System.setProperty("https.protocols", "TLSv1.2");

Either download the dependencies separately and add them to the relevant path or add the following dependencies to your pom.xml file if you're building via Maven (already added if you're cloning this repo):

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.4</version>
</dependency>

<dependency>
    <groupId>org.json</groupId>
    <artifactId>json</artifactId>
    <version>20171018</version>
</dependency>

Class, Properties, and Methods:

ZeroBounceApi Class:

Parameters Descriptions
apiKey Located in your account..
timeoutSeconds Timeout settings in seconds, setting this enables you to control how long you are willing to wait for a response from the API. When the timeout occurs an "Unknown" result is returned.

Validate(email,ip) method:

Property Possible Values
getEmailAddress() The email address you are validating.
getStatus() Valid /Invalid /Catch-All /Unknown /Spamtrap /Abuse /DoNotMail
getSubStatus() antispam_system /greylisted /mail_server_temporary_error /forcible_disconnect /mail_server_did_not_respond /timeout_exceeded /failed_smtp_connection /mailbox_quota_exceeded /exception_occurred /possible_traps /role_based /global_suppression /mailbox_not_found /no_dns_entries /failed_syntax_check /possible_typo /unroutable_ip_address /leading_period_removed /role_based_catch_all /does_not_accept_mail /alias_address
getAccount() The portion of the email address before the "@" symbol.
getDomain() The portion of the email address after the "@" symbol
getDidYouMean() Suggestive Fix for an email typo or [null]
getDomainAgeDays() Age of the email domain in days or [null].
isFreeEmail() [true/false] If the email comes from a free provider.
isMXFound() [true/false] Does the domain have an MX record.
getMXRecord() The preferred MX record of the domain or [null].
getSMTPProvider() The SMTP Provider of the email or [null] (BETA).
getFirstName() The first name of the owner of the email when available or [null].
getLastName() The last name of the owner of the email when available or [null].
getGender() The gender of the owner of the email when available or [null].
getCreationDate() The creation date of the email when available or [null].
getLocation() The location of the owner of the email when available or [null].
getCountry() The country the IP address is from.
getCity() The city the IP address is from.
getZipcode() The zip code the IP address is from.
getRegion() The region/state the IP address is from.
getProcessedAt() The UTC time the email was validated.

GetCredit method:

Property Possible Values
getCredits() The number of credits left in account for email validation.

Any of the following email addresses can be used for testing the API, no credits are charged for these test email addresses:

You can use this IP to test the GEO Location in the API.

  • 99.110.204.1
Code Sample:

The validation methods return objects on which you call get methods which return the relevant information. Please see the code for all getters and below for a sample:

//Depending on how you use the API, you might want it to time out faster,
//for example on a registration screen. 
//Normally the API will return results very fast, but a small percentage of
//mail servers take upwards of 20+ seconds to respond. 
//If the API times out, it will return a status of "Unknown" and 
//a sub_status of "timeout_exceeded" 

ZeroBounceApi zeroBounceApi = new ZeroBounceApi("YOUR_API_KEY",TIMEOUT_IN_SECONDS);

// Get credits and assign to int variable
int credits = zeroBounceApi.getCredits();

// validate email and assign result to a ZeroBounceResponse object
ZeroBounceResponse validation = zeroBounceApi.validate("[email protected], "some.ip.address can be blank");
validation.getEmailAddress();
validation.getStatus();
validation.isDisposable();
validation.getCountry();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.