Skip to content

Sensors API ​

The Sensors API provides CRUD operations for traffic sensors and devices.

Overview ​

ProcedureTypeAuthDescription
sensors.getAllQueryNoGet paginated sensors list
sensors.getAllSensorsQueryNoGet all sensors with locations
sensors.getByIdQueryNoGet sensor by ID
sensors.createMutationYesCreate new sensor
sensors.updateMutationYesUpdate sensor
sensors.deleteMutationYesDelete sensor

Data Types ​

Sensor Type ​

typescript
enum SensorType {
  CAMERA = "CAMERA",
  RADAR = "RADAR",
  ANPR = "ANPR",
  SPEED_DETECTOR = "SPEED_DETECTOR",
  EDGE_CONTROLLER = "EDGE_CONTROLLER"
}

Sensor Status ​

typescript
enum SensorStatus {
  ONLINE = "ONLINE",
  OFFLINE = "OFFLINE",
  MAINTENANCE = "MAINTENANCE",
  ERROR = "ERROR"
}

Coordinates ​

typescript
interface Coordinates {
  latitude: number;
  longitude: number;
  address?: string;
}

Procedures ​

sensors.getAll ​

Get a paginated list of sensors with filtering and sorting.

Type: Query Auth Required: No

Input ​

typescript
{
  skip?: number;        // Offset (default: 0)
  take?: number;        // Limit 1-100 (default: 10)
  search?: string;      // Search in name/deviceId
  type?: SensorType;    // Filter by type
  status?: SensorStatus; // Filter by status
  sortBy?: "name" | "type" | "status" | "createdAt" | "lastHeartbeat";
  sortOrder?: "asc" | "desc";
}

Response ​

typescript
{
  sensors: Sensor[];
  total: number;
  pageCount: number;
}

Example ​

bash
# Get first 10 sensors
curl -X GET "https://api.itms.solutions/trpc/sensors.getAll"

# Get online cameras with search
curl -X GET "https://api.itms.solutions/trpc/sensors.getAll?input=%7B%22json%22%3A%7B%22type%22%3A%22CAMERA%22%2C%22status%22%3A%22ONLINE%22%2C%22search%22%3A%22main%22%7D%7D"

sensors.getAllSensors ​

Get all sensors with their location information.

Type: Query Auth Required: No

Response ​

typescript
Array<{
  id: string;
  name: string;
  deviceId: string;
  type: SensorType;
  status: SensorStatus;
  ipAddress: string | null;
  coordinates: Coordinates | null;
  apiKey: string;
  eventsPerMin: number;
  lastHeartbeat: string | null;
  createdAt: string;
  updatedAt: string;
  location: {
    id: string;
    name: string;
    address: string;
  } | null;
}>

Example ​

bash
curl -X GET "https://api.itms.solutions/trpc/sensors.getAllSensors" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

sensors.getById ​

Get a single sensor by its ID.

Type: Query Auth Required: No

Input ​

typescript
{
  id: string;
}

Response ​

typescript
{
  id: string;
  name: string;
  deviceId: string;
  type: SensorType;
  status: SensorStatus;
  ipAddress: string | null;
  macAddress: string | null;
  firmware: string | null;
  coordinates: Coordinates | null;
  apiKey: string;
  eventsPerMin: number;
  description: string | null;
  locationId: string | null;
  lastHeartbeat: string | null;
  lastCommunication: string | null;
  lastPing: string | null;
  createdAt: string;
  updatedAt: string;
}

Example ​

bash
curl -X GET "https://api.itms.solutions/trpc/sensors.getById?input=%7B%22json%22%3A%7B%22id%22%3A%22sensor-001%22%7D%7D"

Errors ​

CodeDescription
NOT_FOUNDSensor not found

sensors.create ​

Create a new sensor.

Type: Mutation Auth Required: Yes

Input ​

typescript
{
  name: string;            // 3-50 characters
  deviceId: string;        // 3-50 characters, unique
  type: SensorType;
  eventsPerMin?: number;   // Positive integer (default: 20)
  ipAddress?: string;
  coordinates?: Coordinates;
  description?: string;
  locationId?: string;
}

Response ​

Returns the created sensor with generated id and apiKey.

typescript
{
  id: string;
  name: string;
  deviceId: string;
  type: SensorType;
  status: "OFFLINE";
  eventsPerMin: number;
  ipAddress: string | null;
  coordinates: Coordinates | null;
  apiKey: string;          // Generated 64-char hex key
  description: string | null;
  locationId: string | null;
  createdAt: string;
  updatedAt: string;
}

Example ​

bash
curl -X POST "https://api.itms.solutions/trpc/sensors.create" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "json": {
      "name": "Main Street Camera",
      "deviceId": "CAM-001",
      "type": "CAMERA",
      "eventsPerMin": 30,
      "ipAddress": "192.168.1.100",
      "coordinates": {
        "latitude": 43.238949,
        "longitude": 76.945465,
        "address": "Main Street, Almaty"
      }
    }
  }'

Errors ​

CodeDescription
BAD_REQUESTDevice ID already in use
UNAUTHORIZEDNot authenticated

sensors.update ​

Update an existing sensor.

Type: Mutation Auth Required: Yes

Input ​

typescript
{
  id: string;              // Required
  name?: string;           // 3-50 characters
  type?: SensorType;
  status?: SensorStatus;
  eventsPerMin?: number;
  ipAddress?: string;
  coordinates?: Coordinates;
  locationId?: string;
  description?: string;
}

Response ​

Returns the updated sensor.

Example ​

bash
curl -X POST "https://api.itms.solutions/trpc/sensors.update" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "json": {
      "id": "sensor-001",
      "status": "ONLINE",
      "eventsPerMin": 50
    }
  }'

Errors ​

CodeDescription
NOT_FOUNDSensor not found
UNAUTHORIZEDNot authenticated

sensors.delete ​

Delete a sensor.

Type: Mutation Auth Required: Yes

Input ​

typescript
{
  id: string;
}

Response ​

typescript
{
  success: boolean;
  id: string;
}

Example ​

bash
curl -X POST "https://api.itms.solutions/trpc/sensors.delete" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -d '{
    "json": {
      "id": "sensor-001"
    }
  }'

Errors ​

CodeDescription
NOT_FOUNDSensor not found
UNAUTHORIZEDNot authenticated

API Key ​

Each sensor receives a unique 64-character hexadecimal API key upon creation. This key can be used for sensor-to-API authentication when reporting events.

Sensor Lifecycle ​

  1. Created - Status: OFFLINE
  2. First Heartbeat - Status changes to ONLINE
  3. No Heartbeat (timeout) - Status changes to OFFLINE
  4. Maintenance Mode - Manually set to MAINTENANCE
  5. Error State - Set to ERROR on critical issues

SCS Smart City - Traffic, Gateway, Camera, and NVR Platform