Python SDK Documentation

The Python SDK provides a basic interface to the DataSoap API, allowing developers to build
bespoke solutions quickly using our data cleansing / validation services.

Downloading

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

Note: The Python SDK requires the 'requests' library which can be installed via pip or you can visit its home page here

Using the SDK

Place the 'DataSoap.py' file into your projects directory and import it into your code using 'import DataSoap'

To start making requests to the API you need to define a variable and assign it to a new instance of 'DataSoap.Client()', you can then give it your api token with 'client.WithAuthToken("your_private_token")'

import DataSoap

client = DataSoap.Client()
client.WithAuthToken("your_private_token")

The client includes methods for each service it supports. In the case of an error the client will return an ErrorCode which directly relates to our error code list. It is important that error codes are correctly handled as some services such as HLR will throw exception in certain events such as ‘Dead number’

Examples

client = DataSoap.Client()
client.WithAuthToken("your_private_token")

number = 'your_number'

# Send request
result = client.TpsLookup(number)

if 'ErrorCode' in result:
    # Handle API Errors
    print("API Error: " + `result['ErrorCode']`)
else:
    # Result
    print("Number: " + result['MSISDN']))
    print("On TPS: " +  str(result['TPS']))
    print("On CTPS: " +  str(result['CTPS']))
    print("On DNC: " +  str(result['DNC']))
client = DataSoap.Client()
client.WithAuthToken("your_private_token")

number = 'your_mobile_number'

# Send request
result = client.HlrLookup(number)

if 'ErrorCode' in result:
    # Handle API Errors
    print("API Error: " + `result['ErrorCode']`)
else:
    # Result
    print("Number: " + result['MSISDN'])
    print("Is On: " + str(result['On']))
    print("Network: " + result['NetworkName'])
    print("MNCMCC: " + str(result['MNC'])+ str(result['MCC']))
client = DataSoap.Client()
client.WithAuthToken("your_private_token")

# Send request
result = client.LandlineLookup(number)

if 'ErrorCode' in result:
    # Handle API Errors
    print("API Error: " + `result['ErrorCode']`)
else:
    # Result
    print("Number: " + result['Number'])
    print("Is Active: " + str(result['IsActive']))
client = DataSoap.Client()
client.WithAuthToken("your_private_token")

email = 'your_email'

# Send request
result = client.EmailLookup(email)

if 'ErrorCode' in result:
    # Handle API Errors
    print("API Error: " + `result['ErrorCode']`)
else:
    # Result
    print("Email: " + result['Email'])
    print("High Quaility: " + str(result['IsHighQuality']))
    print("Is Free: " + str(result['IsFree']))
    print("Is Disposable: " + str(result['IsDisposable']))
    print("is Role: " + str(result['IsRole']))
client = DataSoap.Client()
client.WithAuthToken("your_private_token")

number = 'your_number'


# Send request
result = client.UnsubscribeLookup(number)

if 'ErrorCode' in result:
    # Handle API Errors
    print("API Error: " + `result['ErrorCode']`)
else:
    # Result
    print("Number: " + result['MSISDN'])
    print("On Company List: " + str(result['OnCompany']) + " (" + str(result['OnCompanyDateAdded']) + ")")
    if ('OnGlobal' in result):
        print("On Global List: " + str(result['OnGlobal']) + " (" + str(result['OnGlobalDateAdded']) + ")")