Get Credit Balance (v1)

This API will tell you how many credits you have left on your account. It's simple, fast and easy to use.

Here are a few scenarios that businesses will use this API for.

  • You use our API to validate emails and you need to check within a certain time-frame when your credit balance is too low, so you can make a payment.
  • You want to track how many email validation credits you're using per your defined time-frame to generate useful statistical information.
  • You want to automate and integrate information into your application dashboard that shows you your currently remaining credit balance.
  • Below, you will find the instructions on how to use our API. It's very easy to use and it requires SSL.

This API will tell you how many credits you have left on your account.

GET /v1/getcredits

API URL:https://bulkapi.zerobounce.net/v1/getcredits

URL Parameters

  • Parameter
    Description
  • api_key
    Your API Key, found in your account.

If you want to call the API from your browser to test it, all you have to do is to replace the API KEY with your key:

https://api.zerobounce.net/v1/getcredits?api_key=[replacewithyours]

This API will tell you how many credits you have left on your account.

The API will return these results in a JSON format using the "getcredits" method. credits - The amount of credits you have left in your account for email validations. If a -1 is returned, that means your API Key is invalid.

Get Credits API Code Samples

  • Visual Basic
  • C#
  • PHP
  • Java
  • Python
  • Swift
  • Objective C
  • Android Java
      
' Complete API Libraries and Wrappers can be found here: 
' https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net

  Try
  Dim apiKey = "Your Secret Key"
  Dim apiURL = "https://api.zerobounce.net/v1/getcredits?apikey=" & apiKey

  Dim request As HttpWebRequest = DirectCast(WebRequest.Create(apiURL), HttpWebRequest)
  request.Timeout = 150000
  request.Method = "GET"

  Using response As WebResponse = request.GetResponse()
      response.GetResponseStream().ReadTimeout = 20000
      Using ostream As New StreamReader(response.GetResponseStream())
          responseString = ostream.ReadToEnd()
      End Using
  End Using
Catch ex as exception
'Catch Exception - All errors will be shown here - if there are issues with the API
End Try
    

    // Complete API Libraries and Wrappers can be found here: 
    // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__dot_net
    // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__c-sharp

    try {
      string apiKey = "Your Secret Key";
      string apiURL = "https://api.zerobounce.net/v1/getcredits?apikey=" + apiKey; 
    
      HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiURL);
      request.Timeout = 150000;
      request.Method = "GET";
    
      using (WebResponse response = request.GetResponse()) {
         response.GetResponseStream().ReadTimeout = 20000;
         using (StreamReader ostream = new StreamReader(response.GetResponseStream())) {
         responseString = ostream.ReadToEnd();
         }
      }
      } catch (exception ex) {
      /Catch Exception - All errors will be shown here - if there are issues with the API
      }>>
    

    <?php
    // Complete API Libraries and Wrappers can be found here: 
    // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__php

    // set the api key and email to be validated
    $apiKey = 'Your Secret Key';
    // use curl to make the request
    $url = 'https://api.zerobounce.net/v1/getcredits?apikey='.$apiKey;
    
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 15); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 150); 
    $response = curl_exec($ch);
    curl_close($ch);
    
    //decode the json response
    $json = json_decode($response, true);
    ?>
    


  //Complete API Libraries and Wrappers can be found here: 
  //https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__java

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
   
    public class MyClass {
   
        public static void main(String[] args){
   
            String key = "Your Secret Key";
            String targetURL = "https://api.zerobounce.net/v1/getcredits?apikey="+key;
   
            HttpURLConnection connection = null;
            final String USER_AGENT = "Mozilla/5.0";
   
            try {
                URL url = new URL(targetURL);
                connection = (HttpURLConnection) url.openConnection();
                connection.setRequestMethod("GET");
                connection.addRequestProperty("User-Agent", USER_AGENT);
   
   
                connection.setUseCaches(false);
                connection.setDoOutput(true);
   
                BufferedReader in = new BufferedReader(
                        new InputStreamReader(connection.getInputStream()));
                String inputLine;
                StringBuffer response = new StringBuffer();
   
                while ((inputLine = in.readLine()) != null) {
                    response.append(inputLine);
                }
                in.close();
   
                //print result
                System.out.println(response.toString());
   
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (connection != null) {
                    connection.disconnect();
                }
            }
   
        }
    }
    

    # Complete API Libraries and Wrappers can be found here: 
    # https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__python
  
    
    import requests
    import json
    
    target_url = "https://api.zerobounce.net/v1/getcredits?apikey="
    secret_key = "Your Secret Key"
    
    api_response = requests.get("%s%s" % (target_url, secret_key))
    data = json.loads(api_response.content)
    
    # prints the number of credits
    print data["Credits"]
    
    


  // Complete API Libraries and Wrappers can be found here: 
  // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOS

    let key = "Your Secret Key"
    let url = URL(string: String(format: "https://api.zerobounce.net/v1/getcredits?apikey=%@", key))
    let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
        if error != nil {
            NSLog("Error (String(describing: error))")
        } else {
            do {
                let parsedData = try JSONSerialization.jsonObject(with: data!) as! [String:Any]
                for (key, value) in parsedData {
                    NSLog("(key) = (value) ")
                }
            } catch {
                print("Error deserializing JSON: (error)")
            }
        }
    }
    task.resume()
    


  // Complete API Libraries and Wrappers can be found here: 
  // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__IOS

    NSString *key = @"Your Secret Key";
    NSString *urlString = [NSString stringWithFormat:@"https://api.zerobounce.net/v1/getcredits?apikey=%@", key];
    
    __block NSURL *url = [NSURL URLWithString:urlString];
    
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    
        NSData *response = [NSData dataWithContentsOfURL:url];
        NSDictionary *arrResponse = nil;
        if(response!=nil)
        {
            arrResponse = [NSJSONSerialization JSONObjectWithData: response options:kNilOptions error:nil];
        }
        dispatch_async(dispatch_get_main_queue(), ^(void) {
            for(NSString *key in [arrResponse allKeys]) {
                NSLog(@"%@: %@",key,[arrResponse objectForKey:key]);
            }
    //            callback(nil, arr);
        });
    });
    



  // Complete API Libraries and Wrappers can be found here: 
  // https://www.zerobounce.net/docs/zerobounce-api-wrappers/#api_wrappers__v2__android

  Add to build.gradle (App) in the "android" bracket:
  useLibrary 'org.apache.http.legacy'
  
  Example:
  
  android {
      compileSdkVersion 25
      useLibrary 'org.apache.http.legacy'
  }
  //------------------------------------------
  //Filename: JsonParser.java
  
  import android.os.AsyncTask;
  import org.json.JSONObject;
  import java.util.Iterator;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          new AsyncTaskParseJson().execute();
      }
  }
  
  public class AsyncTaskParseJson extends AsyncTask<String, String, String> {
  
      String key = "Your Secret Key";
      String url = "https://api.zerobounce.net/v1/getcredits?apikey="+key;
  
      @Override
      protected void onPreExecute() {
      }
  
      @Override
      protected String doInBackground(String... arg0) {
  
          JsonParser jParser = new JsonParser();
          JSONObject json = jParser.getJSONFromUrl(url);
          Iterator keys = json.keys();
          while( keys.hasNext() ) {
              String key = (String)keys.next();
              try {
                  System.out.println("ZeroBounce: "+key+" = " +json.get(key).toString());
              }
              catch (Exception e){}
          }
  
          return null;
      }
      @Override
      protected void onPostExecute(String strFromDoInBg) {}
  }
  
  //---------------------------------------------------
  //Filename: MainActivity.java
  
  package com.zerobounce.zbapiandroid;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.UnsupportedEncodingException;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.util.Log;
  
  public class JsonParser {
  
      final String TAG = "JsonParser.java";
  
      static InputStream is = null;
      static JSONObject jObj = null;
      static String json = "";
  
      public JSONObject getJSONFromUrl(String url) {
  
          try {
  
              DefaultHttpClient httpClient = new DefaultHttpClient();
              HttpGet httpGet = new HttpGet(url);
  
              HttpResponse httpResponse = httpClient.execute(httpGet);
              HttpEntity httpEntity = httpResponse.getEntity();
              is = httpEntity.getContent();
  
          } catch (UnsupportedEncodingException e) {
              e.printStackTrace();
          } catch (ClientProtocolException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
  
          try {
  
              BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
              StringBuilder sb = new StringBuilder();
              String line = null;
              while ((line = reader.readLine()) != null) {
                  sb.append(line + "
");
              }
              is.close();
              json = sb.toString();
  
          } catch (Exception e) {
              Log.e(TAG, "Error converting result " + e.toString());
          }
  
          try {
              jObj = new JSONObject(json);
          } catch (JSONException e) {
              Log.e(TAG, "Error parsing data " + e.toString());
          }
  
          return jObj;
      }
  }
    

Endpoint Response

Successful Response

      
    {"Credits":2375323}
    

Error Response

      
    {"Credits":-1}