Skip to main content
Skip table of contents

Connecting to ZeroKey's API with Python

This article provides information on how to establish a connection to ZeroKey’s API using Python.

Getting Started

To start your integration with ZeroKey, you’ll need to connect to the Spatial Intelligence Platform (SIP) API. Here’s how to begin:

  1. Go to the ZeroKey API webpage and navigate to the Python section under Get Started. The following link will direct you to this page: https://api.zerokey.com/v3/#section/Get-Started/Python.

  2. Copy the code under Step 2 and paste it into your Python IDE.

  3. Ensure that you have installed the signalrcore library before proceeding.

Editing the Code

Once you have the script ready, you can proceed to edit the Python code.

  1. First, locate the placeholders for the API host. Replace {API Host Here} with the IP address of the Edge Compute Device (ECD). Ensure that the port numbers remain the same (33001 and 5000).

    • For example:
      eventHubUrl = "https://10.42.0.1:33001/hubs/eventHub"
      apiUrl = "https://10.42.0.1:5000/v3/"

      • In this case, the IP address is 10.42.0.1

  2. Find the authenticateConnection() function. Replace the placeholders for the username and password with these credentials, respectively: LocalAdmin, DefaultSecret.

    • The modified code should look exactly like the following:
      "auth_id": "LocalAdmin",
      "auth_secret": "DefaultSecret"

Running the Script

Navigate to the bottom of the script and locate the following lines of code:

if __name__ == "__main__":

main()

  1. First, click the Play icon beside the first line.

  2. Then, click Run.

    • If there are no errors detected and outputted by the system, the connection is successful.

    • If you receive the following error, ensure that the inputted IP address and credentials are correct and retry running the script.

      • requests.exceptions.ConnectionError: HTTPConnectionPool(host='10.22.74.1', port=5000): Max retries exceeded with url: /v3/auth/token (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x00000288CAACAD50>: Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.