Skip to main content
Skip table of contents

Connecting to ZeroKey's API with JavaScript

Establish a connection to ZeroKey’s API using JavaScript.

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 JavaScript section under Get Started. The following link will direct you to this page: https://api.zerokey.com/v3#section/Get-Started/JavaScript .

  2. Create an HTML file.

  3. In the API document, copy the code provided under step 3 and paste it into your HTML file.

Editing the Code

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

  1. First, locate the placeholders for the API host. Replace {API Host Here} with the IP address of the Edge Compute Device (ECD).

    • For example:
      <script>
      const eventHubUrl = http://{10.42.0.1:33001/hubs/eventHub;
      const apiUrl = http://10.42.0.1:5000/v3/;
      In this case, the IP address is 10.42.0.1

image-20240527-183831.png NOTE: Ensure that the port numbers remain the same (33001 and 5000). Replace only the IP address.

  1. Find the the //Get the Bearer Token comment. Replace the placeholders for the username and password with these credentials, respectively: LocalAdmin, DefaultSecret.

    • The code in the ZeroKey API webpage looks like the following:
      auth_id: "{Your Username}",
      auth_secret: "{Your Password}"

image-20240527-183831.png NOTE: Ensure to use LocalAdmin as your username and DefaultSecret as your password.

Running the Script

Navigate to the folder where the script is saved and execute the HTML.

  1. First, double-click on the HTML file you saved.

  2. The browser will then open.

    • If no errors occur, you’ll see "LOCATION_RAW_UPDATE" messages in the text blocks, indicating that the connection is successful.

    • If you do receive an error, ensure that the entries for the IP address and credentials are correct and retry running the script.

JavaScript errors detected

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

If this problem persists, please contact our support.