Javascript SDK Documentation

The Javascript provides an easy to use interface to the Data Soap API, allowing developers to
add the power of Data Soap to their websites quickly.

Installing

You can download the latest and greatest version of the Data Soap SDK for Javascript below.

Using the SDK

Include the javascript file in to the head of your html using a script tag and include your public token in src attribute
Sample

<html>
<head>
    <script src="DataSoap.min.js?token={public_token}"></script>
</head>
<body>

</body>
</html>

Note: Public tokens can only be used on the website set in the tokens Origin field, This protect you from malicious users stealing the private token and using up credit on your account, it is also recommended you set a rate limit for extra protection. Do not use a Private token in production!


You can access the SDK using the global variable 'dataSoapSDK' which contains the following functions and options:


    setAuthToken: function (auth_token)
    setValidationSucessForErrorCode: function (error_code, pass)
    getValidationSucessForErrorCode: function (error_code)
    getSdkVersion: function ()
    options:
        acceptDisposableEmailAddresses: string
        connectionErrorsPassValidations: string
        proxyRequstsUrl: string
    validate:
        auto: function(lookup, onValidationResult, onSuccess, onFailure)
        email: function(email, onValidationResult, onSuccess, onFailure)
        hlr: function(mobile_number, onValidationResult, onSuccess, onFailure)
        landline: function(landline_number, onValidationResult, onSuccess, onFailure)
    lookup:
        email: function(email, onSuccess, onFailure)
        hlr: function(mobile_number, onSuccess, onFailure)
        landline: function(landline_number, onSuccess, onFailure)
        mps: function(address, name, onSuccess, onFailure)
        tps: function(phone_number, onSuccess, onFailure)
        unsubscribe: function(phone_number, onSuccess, onFailure)

The SDK provides an interface to the API though 'lookup' as well as validation functions to return a true or false status using 'validate' this also include the api responses:

Validation Examples

<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <hr/>
        <div>
            Valid: <span id="valid"></span> <br>
            Api Result: <br> <pre id="apiResult"></pre>
        </div>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.validate.auto(document.getElementById("lookup").value,
                function (isValid) {
                        document.getElementById("valid").innerHTML = (isValid==true?"Yes":"No");
                    },
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>   
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <hr/>
        <div>
            Valid: <span id="valid"></span> <br>
            Api Result: <br> <pre id="apiResult"></pre>
        </div>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.validate.hlr(document.getElementById("lookup").value,
                function (isValid) {
                        document.getElementById("valid").innerHTML = (isValid==true?"Yes":"No");
                    },
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>   
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <hr/>
        <div>
            Valid: <span id="valid"></span> <br>
            Api Result: <br> <pre id="apiResult"></pre>
        </div>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.validate.landline(document.getElementById("lookup").value,
                function (isValid) {
                        document.getElementById("valid").innerHTML = (isValid==true?"Yes":"No");
                    },
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>   
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <hr/>
        <div>
            Valid: <span id="valid"></span> <br>
            Api Result: <br> <pre id="apiResult"></pre>
        </div>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.validate.email(document.getElementById("lookup").value,
                function (isValid) {
                        document.getElementById("valid").innerHTML = (isValid==true?"Yes":"No");
                    },
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>   

Api Examples

<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <pre id="apiResult"></pre>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.lookup.tps(document.getElementById("lookup").value,
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <pre id="apiResult"></pre>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.lookup.hlr(document.getElementById("lookup").value,
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <pre id="apiResult"></pre>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.lookup.landline(document.getElementById("lookup").value,
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <pre id="apiResult"></pre>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.lookup.email(document.getElementById("lookup").value,
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>
<html>
    <head>
    <script src="DataSoap.min.js?token={public_token}"></script>
    </head>
    <body>
        <!-- Input -->
        <input type="text" id="lookup" >
        <button onclick="callDataSoap()">Submit</button> 

        <!-- Result (For demonstration)-->
        <pre id="apiResult"></pre>
    
        <script>
            function callDataSoap()
            {
                dataSoapSDK.lookup.unsubscribe(document.getElementById("lookup").value,
                    function (successJson) {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(successJson, null, 2);
                    },
                    function (errorJson) 
                    {
                        document.getElementById("apiResult").innerHTML = JSON.stringify(errorJson, null, 2);
                    }
                );
            };
        </script>
</html>