Java

You can find the ZeroBounce Java API on our GitHub - Java API.

This is a java wrapper class example for the ZeroBounce API.

The project has 2 dependencies:

  1. Apache HttpClient

  2. JSON (org.json)

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):

Class, Properties, and Methods:


  <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>
      

  //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("some@email.com");
  validation.getEmailAddress();
  validation.getStatus();
  validation.isDisposable();
  
  // validate email with ip and assign result to a ZeroBounceResponseWithIp object
  ZeroBounceResponseWithIp validationWithIp = zeroBounceApi.validateWithIpAddress("some@email.com", "some.ip.address");
  validationWithIp.getEmailAddress();
  validationWithIp.getCountry();