Quickstart

Eager to get started? This page gives a good introduction to hexonet.apiconnector. It assumes you already have it installed. If you do not, head over to the Installation section.

A Minimal Application

A minimal application using hexonet.apiconnector looks something like follows. We provided two short examples: one for sessionless communication and one for session-based communication.

Python SDK Demo App
#!/usr/bin/python

# Import the ispapi library
from hexonet.apiconnector.apiclient import APIClient as AC

# -------- SESSIONLESS COMMUNICATION -----------

# Create a connection using the APIClient class and the appropriate
# methods to configure the connection as necessary.
# Don't have a HEXONET Account yet? Get one here:
# - Live System Account: https://www.hexonet.net/sign-up
# - Test/OT&E System Account: https://www.hexonet.net/signup-ote

print("---- SESSIONLESS COMMUNICATION ----")
cl = AC()
cl.useOTESystem()
cl.setCredentials("test.user", "test.passw0rd")
# use the below method in case you have an active
# ip filter setting
cl.setRemoteIPAddress("1.2.3.4")

# Call a command
r = cl.request({"Command": "QueryDomainList", "limit": 5})

# Get the result in the format you want
rlist = r.getListHash()
rhash = r.getHash()
rplain = r.getPlain()

# or use API methods to access specific data
col = r.getColumn("DOMAIN")  # get column domain
if col:
    col.getData()  # get all data of column DOMAIN
r.getColumnKeys()  # get all column keys
r.getColumnIndex("DOMAIN", 0)  # get data for column DOMAIN at index 0
r.getColumns()  # get all columns
r.getRecord(0)  # row at index 0
r.getRecords()  # get all rows
# ... and some more

# Get the response code and the response description
code = r.getCode()
description = r.getDescription()
print(str(code) + " " + description)

# -------- SESSION-BASED COMMUNICATION -----------
print("---- SESSION-BASED COMMUNICATION ----")
cl = AC()
cl.useOTESystem()
cl.setCredentials("test.user", "test.passw0rd")
cl.setRemoteIPAddress("1.2.3.4")

# Call a command
r = cl.login()
# cl.login("12345678"); -> 2FA: one time password

if r.isSuccess():
    print("LOGIN SUCCEEDED!")
    r = cl.request({"Command": "QueryDomainList", "limit": 5})
    rplain = r.getPlain()
    code = r.getCode()
    description = r.getDescription()
    print(str(code) + " " + description)
    # ... further commands ...
    r = cl.logout()
    if r.isSuccess():
        print("LOGOUT SUCCEEDED!")

You can find this code also on github.

What to do if the backend system just returns an error

Well this in general needs some further analysis. Reasons might be that you have an ip filter defined and you do not provide your ip address through configuration option “remoteaddr”. It could also be that you provided an ip address that is blocked. Another issue can be that you connect using a role user that is not allowed to request this command as it got blocked by role user configuration.

Feel free to Contact Us if you need help.

Sessions

Session-based communication is available in this SDK, see above. Use saveSession() and reuseSession() if you plan to build your own frontend on top using session handling.