View our

SSL API Code Examples

Please read the API documentation before you start using our APIs in production.
The API key used in these examples is for demonstrative purposes and can be used only to check

PHP Code Example

Basic PHP example using cURL. We will get SSL certificate information for the domain name “”.

// Prepare vars
$domain    = "";     // domain to check
$r         = "cert";           // API request type
$apikey    = "demokey";        // your API key

// API call
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$domain&r=$r&apikey=$apikey");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = json_decode(curl_exec($ch), true);

// Success
if (isset($output['status']) && $output['status'] == 0) {
    if (!empty($output['certondomain'])) {
        echo "Success. Domain \"$domain\" SSL certificate issuer: ".$output['issuer'];
    } else {
        echo "Success. Domain \"$domain\" has no SSL certificate";
// API error
} elseif (!empty($output['status_desc'])) {
    echo "API reports error: ".$output['status_desc'];
// Unknown error
} else {
    echo "Unknown error";

Javascript Code Example

We will get SSL certificate information for the domain name “”.

<script type="text/javascript">
var domain     = "";      // domain name you want to check
var r          = "cert";            // API request type
var apikey     = "demokey";         // your API key

var xhr = new XMLHttpRequest();"GET", ''+domain+'&r='+r+'&apikey='+apikey, true);
xhr.onreadystatechange = function () {
    if (xhr.readyState === 4 && xhr.status === 200) {
        var json = JSON.parse(xhr.responseText);
        if (json.status == 0) {
            document.getElementById("result").innerHTML = "Success. Domain SSL certificate issuer: " + json.issuer;
        } else {
            document.getElementById("result").innerHTML = "API reports error: " + json.status_desc;
    } else {
        document.getElementById("result").innerHTML = "Unknown error";
<div id="result">please wait...</div>

Ruby Code Example

We will get SSL certificate information for the domain name “”.

require 'open-uri'
require 'json'

domain     = ""   # domain to check
r          = "cert"         # API request type
apikey     = "demokey"      # your API key

output = JSON.parse("{domain}&r=#{r}&apikey=#{apikey}").read)

if output["status"].to_i == 0
 puts "Success. Domain SSL certificate issuer: " + output["issuer"]
elsif !output["status_desc"].nil?
 puts "API reports error: " + output["status_desc"]
 puts "Unknown error"

Python Code Example

We will get SSL certificate information for the domain name “”.

#!/usr/bin/env python
import requests

def whoapi_request(domain, r, apikey) -> None:

    res = requests.get('', dict(

    if res.status_code == 200:
        data = res.json()
        if int(data['status']) == 0:
            print("Success. Domain SSL certificate issuer: " + data["issuer"])
            print("API reports error: " + data['status_desc'])
        raise Exception('Unexpected status code %d' % res.status_code)

domain = ''   # domain to check
r = 'cert'              # API request type
apikey = 'demokey'      # key

whoapi_request(domain, r, apikey)

Objective C Code Example

We will get SSL certificate information for the domain name “”.

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    NSString *domain   = @"";     // domain to check
    NSString *r        = @"cert";           // API request type
    NSString *apikey   = @"demokey";        // your API key
    NSString *urlAsString = [NSString stringWithFormat:@
    "", domain, r, apikey];
    NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlAsString]];
    [urlRequest setHTTPMethod:@"GET"];
    NSURLSession *session = [NSURLSession sharedSession];
    // Semaphore used only for the debug purpose
    dispatch_semaphore_t sema = dispatch_semaphore_create(0);
    NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
        NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
        if(httpResponse.statusCode == 200)
            NSError *parseError = nil;
            NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
            NSNumber *status;
            if([responseDictionary[@"status"] isKindOfClass:[NSString class]]) {
                NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
                f.numberStyle = NSNumberFormatterDecimalStyle;
                status = [f numberFromString:responseDictionary[@"status"]];
            } else {
                status = responseDictionary[@"status"];
            if([status isEqualToNumber:@0])
                NSLog(@"Success. Domain SSL certificate issuer: %@", responseDictionary[@"issuer"]);
            } else {
                NSLog(@"API reports error: %@", responseDictionary[@"status_desc"]);
            NSLog(@"Unexpected status code\n");
        // Semaphore used only for the debug purpose
    [dataTask resume];
    // Semaphore used only for the debug purpose
    dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
    return 0;

C#(.NET) Code Example

We will get SSL certificate information for the domain name “”.

using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;

public class Program
    public static void Main()
        string apiType = "cert"; // API request type
        string domain = ""; // domain to check
        string apiKey = "demokey"; // api key

        WebRequest request = WebRequest.Create(String.Format("{0}&r={1}&apikey={2}", domain, apiType, apiKey));
        WebResponse response = request.GetResponse();

        StreamReader reader = new StreamReader(response.GetResponseStream());
        string responseFromServer = reader.ReadToEnd();

        JObject json = JObject.Parse(responseFromServer);

        if (json.Value<int>("status") == 0)
            Console.WriteLine(String.Format("Success. Domain SSL certificate issuer: {0}. ", json["issuer"]));
            Console.WriteLine(String.Format("API reports error: {0}. ", json["status_desc"]));

Java Code Example

We will get SSL certificate information for the domain name “”.

import org.json.JSONObject;

class Main {
    public static void main(String args[]) {
      try {
        // Set data
        String domain = ""; // domain to check
        String rtype = "cert"; // API request type
        String apikey = "demokey"; // your API key

        // Send request to API
        URL obj = new URL("" + domain + "&r=" + rtype + "&apikey=" + apikey);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();
        // Validate HTTP response code
        int responseCode = con.getResponseCode();
        if (responseCode != 200) {
          System.out.println("HTTP request error, code: " + responseCode);
        // Read API reply
        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
        // Get JSON
        JSONObject myResponse = new JSONObject(response.toString());
        int status = myResponse.getInt("status");
        String statusDesc = myResponse.getString("status_desc");
        // Validate request status
        if (status != 0) {
          System.out.println("API reports error: " + statusDesc);
        if (myResponse.has("certondomain") && myResponse.getBoolean("certondomain") == true) {
            String issuer = myResponse.getString("issuer");
            System.out.println("Success. Domain SSL certificate issuer: " + issuer);
        } else {
            System.out.println("Success. Domain has no SSL certificate");

      } catch (Exception e) {


The provided code examples demonstrate how to use the WhoAPI’s SSL API to retrieve SSL certificate information for a given domain. The examples cover different programming languages and use various HTTP client libraries to send HTTP GET requests to the WhoAPI SSL API endpoint.

Here’s the general flow of the code:

  1. Set up the necessary variables, including the domain to check, the API request type (cert), and the API key.
  2. Construct the API request URL with the appropriate parameters.
  3. Send an HTTP GET request to the API endpoint using the provided HTTP client library.
  4. Receive the API response and process it.
  5. Handle different scenarios based on the response status.

For example, if the response status is 0, indicating success, the code may display the SSL certificate issuer if the domain has a valid SSL certificate. If the domain has no SSL certificate, the code may indicate that. If the response status is non-zero, indicating an error, the code may display an error message with the corresponding status description.

Please note that the API key used in these examples is for demonstrative purposes only and can be used to check the SSL certificate information for the “” domain. To use the WhoAPI service with your own domain names, you would need to obtain a valid API key from WhoAPI and replace the demokey value in the code examples with your own key.

It’s important to review the API documentation provided by WhoAPI to understand the available request types, response formats, and any specific requirements or limitations of the API.

Additionally, keep in mind that the SSL certificate information for a domain can change over time, so the results obtained through these code examples reflect the current SSL certificate status of a domain at the time of execution.