Get started with API methods - how to retrieve Events data

Introduction

Customers can add cameras to their 3dEYE admin Portal account directly using the API integration method.  To do so using https://web.postman.co↗️  or using the Postman app, please follow the steps below.
 

Step 1: Registering a free account on the Postman Website

You need to register on this platform, this is a free and fairly simple process, just follow the steps on their website:  https://web.postman.co↗️

                           


Step 2: Adding 3dEYE API library into Postman

Import API library from the admin portal into the postman, to do this simply click on the button Run in Postman. This will initiate the import process. You will need to choose in what workspace you want to save the library.
Note: the API menu is accessible only from https://admin.3deye.me↗️ it is not visible from branded pages. 
                   
                                             
                                                  

Step 3: Obtaining API Key for access and generating Token

Before you can start creating cameras you need to obtain a "token" using the method at the bottom of the methods list, to obtain a token you will have to use your integrator user credentials and integrator API key. The API key can be found on the same page as the "Run in Postman" button.
                                   


Step 4: Using the generated Token

At the bottom of the screen, you should see a success message and in this message, the "token" will be provided.  If you have configured an environment in the Postman the platform will automatically use this token for all of the following requests for the duration of the token. Please note that the token is valid for a limited time and the expiration time will be shown in the reply that you will get.

If on the next step, you will be getting an unauthorized error you can try manually copying the token and pasting it in the corresponding field of the method. The token should be placed after the Bearer as the Bearer token value, the token-value should not contain any quotation at the beginning or the end.

                                                     


Step 5: Adding Event info for using API

Use the "Get events for camera" method to get event data. On the Headers tab provide an API key and token if automatic copying does not work. 
                                                                       

Then in the Params provide the information in the value section. The camera ID can be retrieved from the Camera tab under the customer account. The dateFrom and dateTo should be in this format YYYY-MM-DDThh:mm:ssZ for example: 2023-11-28T13:55:11Z. For the event type, the user can choose from Motion, LPR, or Analytics for object detection data. For Analytic, the user needs to input the subtype as well such as Person, car, or Animal.


⚠️Note: at this time special subtypes like luggage, fire, smoke, hardhat or LPR are not supported. To obtain these event subtypes do a request for type "Analytics" and filter the results using 3rd party applications.



                              

To view the return data from the 3dEYE website, click on the body section. Then user can select the returned data type from the dropdown menu. To copy the returned data, simply click on the copy icon on the middle left of the screen.


                              

Now you can simply modify the required fields only and hit Send again to get all the following camera event data.
 

Identifying and counting objects found in Event Data

Once you have copied the returned data from Postman, paste it into a Jupyter Notebook↗️ and save it in a variable.
Now we need to import JSON library which is already installed in Python 3. Create a new variable null and assign it an empty string value. This is done to solve the issue that might occur during converting the copied text to JSON format. We will also instantiate an empty list to store the objects found in the event and use that later for counting the number of objects found.
 
We will run a for loop to convert the copied Postman data into JSON format and then search for the found object and save it in the list instantiated before.
 
Once all the found objects are in the list, we will pass it to the function that counts the number of objects found and return it as a dictionary with the total count.
Below is a code example, please modify it according to your needs.
import json


data = {
"data":
[
{
"id": 561sad99,
"type": "Analytic",
"description": null,
"tags": null,
"customerData": null,
"data": "{\"ThumbnailUrl\":\"https://thumbnails-request-listener.3deye.me/api/extract/thumbnail_exact?key=analytics-thumbnails/25183/525005380906s8529.jpg&AWSAccessKeyId=AdasdasdasdXGRIL7BQ&Expires=1738297&Signature=bMGQyc%3D\",
\"ThumbnailSize\":{\"Width\":1920,\"Height\":1080},\"FoundObjects\":[{\"Type\":\"Car\",\"Box\":{\"Left\":0.7171876,\"Top\":0.105555534,\"Right\":0.75781256,\"Bottom\":0.17499995},\"Probability\":0.879683,\"Colors\":[{\"Color\":\"blue\",\"Rate\":1.0}]}]}",
"startTimeUtc": "2023-11-28T14:37:43Z",
"endTimeUtc": "2023-11-28T14:37:43Z"
}
]
}

null = ''
type_list = []

for i in data['data']:
thumb_data = json.loads(i['data'])
    object_type = thumb_data['FoundObjects'][0]['Type']
    type_list.append(object_type)


def count_items(lst):
item_count = {}
    for item in lst:
  if item in item_count:
      item_count[item] += 1
        else:
      item_count[item] = 1
    return item_count

result = count_items(type_list)
print(result)


{'Car': 54, 'Person': 32}
 
 
Tags