English Română

Version 2.4 | Last updated: July 2026

This document provides a complete reference for integrating with the Metrici TA (Thermal Analyzer) system. The API allows you to query people counting data from thermal cameras across locations, cameras, zones, and groups.

Table of Contents

Quick Start

Base URL:

http://<server>/api/ta/

Minimal example — get people count at a location:

curl "http://<server>/api/ta/get_counters_by_location.php?id=1&output=json"

Response:

{
  "error": false,
  "response": {
    "counter": 42,
    "duration": "0.02"
  }
}

Authentication

The TA API does not require authentication. All endpoints are publicly accessible via HTTP GET. Access is scoped to the owner_id configured server-side in io/defs.inc.php.

Common Parameters

Parameter Type Required Description
id integer Yes* Location, camera, zone, or group ID depending on endpoint
output string No Response format: json (default), xml, dump
Note: All parameters are case-insensitive. ID, Id, id are all valid.

Response Format

JSON (default)

Entity endpoints return a standard structure:

{
  "error": false,
  "response": {
    "header": {
      "count": 3,
      "duration": "0.01"
    },
    "body": {
      "1": {
        "id": 1,
        "name": "Main Entrance"
      }
    }
  }
}

Counter endpoints use a flattened response:

{
  "error": false,
  "response": {
    "counter": 42,
    "duration": "0.02"
  }
}

XML

Set output=xml to receive XML-formatted responses:

<?xml version="1.0"?>
<body>
  <item>
    <id>1</id>
    <name>Main Entrance</name>
  </item>
</body>

Debug

Set output=dump to receive a PHP var_dump() output for debugging.

Entity Endpoints

List Locations

Get all locations that have at least one thermal analytics camera (camera_type_id = 9).

Endpoint:

GET /api/ta/get_locations_list.php

Parameters: None

Example:

curl "http://<server>/api/ta/get_locations_list.php?output=json"

Response:

{
  "error": false,
  "response": {
    "header": {
      "count": 2,
      "duration": "0.01"
    },
    "body": {
      "1": {
        "id": 1,
        "name": "Building A"
      },
      "2": {
        "id": 3,
        "name": "Building B"
      }
    }
  }
}

Response fields:

Field Type Description
id integer Location ID
name string Location name

List Cameras by Location

Get the location and all its thermal cameras. The response nests cameras inside the location object.

Endpoint:

GET /api/ta/get_cameras_list.php

Parameters:

Parameter Type Required Description
id integer Yes Location ID

Example:

curl "http://<server>/api/ta/get_cameras_list.php?id=1&output=json"

Response:

{
  "error": false,
  "response": {
    "header": {
      "count": 1,
      "duration": "0.02"
    },
    "body": {
      "1": {
        "id": 1,
        "name": "Building A",
        "cameras": {
          "0": {
            "id": 20,
            "name": "Thermal - Main Hall"
          },
          "1": {
            "id": 21,
            "name": "Thermal - Side Exit"
          }
        }
      }
    }
  }
}

Response fields:

Field Type Description
id integer Location ID
name string Location name
cameras array List of cameras with id and name

List Groups by Location

Get all zone groups defined for a location. Groups are logical collections of zones (e.g., "Floor 1", "Public Areas").

Endpoint:

GET /api/ta/get_groups_list.php

Parameters:

Parameter Type Required Description
id integer Yes Location ID

Example:

curl "http://<server>/api/ta/get_groups_list.php?id=1&output=json"

Response:

{
  "error": false,
  "response": {
    "header": {
      "count": 2,
      "duration": "0.01"
    },
    "body": {
      "1": {
        "id": 10,
        "name": "Floor 1"
      },
      "2": {
        "id": 11,
        "name": "Public Areas"
      }
    }
  }
}

Response fields:

Field Type Description
id integer Group ID
name string Group name

Counter Endpoints

All counter endpoints return a single counter value representing the total number of people detected (cumulative count from thermal zones).

Counters by Location

Get the total people count for an entire location (all cameras and zones combined).

Endpoint:

GET /api/ta/get_counters_by_location.php

Parameters:

Parameter Type Required Description
id integer Yes Location ID

Example:

curl "http://<server>/api/ta/get_counters_by_location.php?id=1&output=json"

Response:

{
  "error": false,
  "response": {
    "counter": 156,
    "duration": "0.02"
  }
}

Counters by Camera

Get the total people count for a specific camera (all zones on that camera).

Endpoint:

GET /api/ta/get_counters_by_camera.php

Parameters:

Parameter Type Required Description
id integer Yes Camera ID

Example:

curl "http://<server>/api/ta/get_counters_by_camera.php?id=20&output=json"

Response:

{
  "error": false,
  "response": {
    "counter": 89,
    "duration": "0.02"
  }
}

Counters by Zone

Get the people count for a specific zone.

Endpoint:

GET /api/ta/get_counters_by_zone.php

Parameters:

Parameter Type Required Description
id integer Yes Zone ID

Example:

curl "http://<server>/api/ta/get_counters_by_zone.php?id=5&output=json"

Response:

{
  "error": false,
  "response": {
    "counter": 23,
    "duration": "0.01"
  }
}

Counters by Group

Get the total people count for a group of zones.

Endpoint:

GET /api/ta/get_counters_by_group.php

Parameters:

Parameter Type Required Description
id integer Yes Group ID

Example:

curl "http://<server>/api/ta/get_counters_by_group.php?id=10&output=json"

Response:

{
  "error": false,
  "response": {
    "counter": 67,
    "duration": "0.02"
  }
}

Error Handling

Error Response

On database connection or query failures, the server returns plain text:

Status:-1

This indicates a server-side issue (database unreachable, query failure, missing required parameter). Implement retry logic with exponential backoff for these cases.

Missing Required Parameters

If the required id parameter is missing, the server returns:

Status:-1

Integration Flow

Typical workflow to monitor people count:

1. GET /api/ta/get_locations_list.php
   └──> Get all locations with thermal cameras

2. GET /api/ta/get_counters_by_location.php?id=<location_id>
   └──> Get total people count at location

3. GET /api/ta/get_cameras_list.php?id=<location_id>
   └──> Get cameras at this location

4. GET /api/ta/get_counters_by_camera.php?id=<camera_id>
   └──> Get count per camera

5. GET /api/ta/get_groups_list.php?id=<location_id>
   └──> Get zone groups at location

6. GET /api/ta/get_counters_by_group.php?id=<group_id>
   └──> Get count for group of zones

Code Examples

PHP — Monitor People Count

<?php
$locationId = 1;
$url = "http://<server>/api/ta/get_counters_by_location.php?id={$locationId}&output=json";

$response = file_get_contents($url);
$data = json_decode($response, true);

if ($data['error'] === false) {
    $count = $data['response']['counter'];
    echo "People at location: {$count}\n";
} else {
    echo "Error fetching count data\n";
}
?>

Python — Poll All Locations

import requests

server = "http://<server>"

# Get all locations
locations = requests.get(f"{server}/api/ta/get_locations_list.php", params={
    "output": "json"
}).json()

for key, loc in locations["response"]["body"].items():
    counters = requests.get(f"{server}/api/ta/get_counters_by_location.php", params={
        "id": loc["id"],
        "output": "json"
    }).json()
    print(f"{loc['name']}: {counters['response']['counter']} people")

JavaScript — Real-time Polling

async function getCount(locationId) {
  const url = `http://<server>/api/ta/get_counters_by_location.php`
    + `?id=${locationId}&output=json`;

  const res = await fetch(url);
  const data = await res.json();

  if (!data.error) {
    return data.response.counter;
  }
  throw new Error('Failed to fetch count');
}

// Poll every 5 seconds
setInterval(async () => {
  const count = await getCount(1);
  document.getElementById('counter').textContent = count;
}, 5000);

cURL — Quick Check

# Location count
curl -s "http://<server>/api/ta/get_counters_by_location.php?id=1&output=json" | jq .response.counter

# Camera count
curl -s "http://<server>/api/ta/get_counters_by_camera.php?id=20&output=json" | jq .response.counter

# Group count
curl -s "http://<server>/api/ta/get_counters_by_group.php?id=10&output=json" | jq .response.counter

Appendix: Endpoint Summary

Endpoint Parameters Description
get_locations_list.php — List all locations with thermal cameras
get_cameras_list.php id (location) List cameras at location
get_groups_list.php id (location) List zone groups at location
get_counters_by_location.php id (location) People count for location
get_counters_by_camera.php id (camera) People count for camera
get_counters_by_zone.php id (zone) People count for zone
get_counters_by_group.php id (group) People count for group

Appendix: Data Hierarchy

Location (building/facility)
├── Camera (thermal camera — camera_type_id = 9)
│   └── Zone (counting zone)
│       └── counter (cumulative people count)
├── Group (logical collection of zones)
│   └── Zone
│       └── counter
└── ...