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:
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 .
Create an HTML file.
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.
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
NOTE: Ensure that the port numbers remain the same (33001 and 5000). Replace only the IP address.
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}"
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.
First, double-click on the HTML file you saved.
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.