Locations API
The Locations API manages physical locations, intersections, and geographical zones for traffic monitoring.
Overview
| Procedure | Type | Auth | Description |
|---|---|---|---|
locations.getAll | Query | No | Get paginated locations |
locations.getById | Query | No | Get location by ID |
locations.create | Mutation | Yes | Create new location |
locations.update | Mutation | Yes | Update location |
locations.updateSensors | Mutation | Yes | Update sensors at location |
locations.delete | Mutation | Yes | Delete location |
locations.bulkDelete | Mutation | Yes | Delete multiple locations |
locations.getTypes | Query | No | Get location types |
Procedures
locations.getAll
Get a paginated list of locations with filtering and sorting.
Type: Query Auth Required: No
Input
{
skip?: number; // Offset (default: 0)
take?: number; // Limit 1-100 (default: 50)
search?: string; // Search in name/address
type?: string; // Filter by type
status?: string; // Filter by status
sortBy?: "name" | "type" | "status" | "createdAt";
sortOrder?: "asc" | "desc";
}Response
{
locations: Array<{
id: string;
name: string;
address: string;
type: string;
latitude: number;
longitude: number;
status: string;
description: string | null;
sensorCount: number;
createdAt: string;
updatedAt: string;
}>;
total: number;
pageCount: number;
}Example
curl -X GET "https://api.itms.solutions/trpc/locations.getAll"locations.getById
Get a single location with its sensors.
Type: Query Auth Required: No
Input
{
id: string;
}Response
{
id: string;
name: string;
address: string;
type: string;
latitude: number;
longitude: number;
status: string;
description: string | null;
createdAt: string;
updatedAt: string;
sensors: Array<{
id: string;
name: string;
deviceId: string;
type: string;
status: string;
}>;
}locations.create
Create a new location.
Type: Mutation Auth Required: Yes
Input
{
name: string; // 1-100 characters
address: string; // 1-255 characters
type: string; // e.g., "INTERSECTION", "HIGHWAY"
latitude: number; // -90 to 90
longitude: number; // -180 to 180
status?: string; // Default: "active"
description?: string;
}Response
Returns the created location.
Example
curl -X POST "https://api.itms.solutions/trpc/locations.create" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"json": {
"name": "Main Street Intersection",
"address": "123 Main St, Almaty",
"type": "INTERSECTION",
"latitude": 43.238949,
"longitude": 76.945465
}
}'locations.update
Update a location and optionally its sensor associations.
Type: Mutation Auth Required: Yes
Input
{
id: string; // Required
name?: string;
address?: string;
type?: string;
latitude?: number;
longitude?: number;
status?: string;
description?: string;
sensors?: string[]; // Array of sensor IDs to associate
}locations.updateSensors
Update which sensors are assigned to a location.
Type: Mutation Auth Required: Yes
Input
{
id: string; // Location ID
sensors: string[]; // Array of sensor IDs
}locations.delete
Delete a location. Sensors at this location will be unassigned.
Type: Mutation Auth Required: Yes
Input
{
id: string;
}locations.bulkDelete
Delete multiple locations at once.
Type: Mutation Auth Required: Yes
Input
{
ids: string[];
}Response
{
success: number; // Count of successfully deleted
failed: number; // Count of failures
errors?: Array<{
id: string;
error: string;
}>;
}locations.getTypes
Get distinct location types with counts.
Type: Query Auth Required: No
Response
Array<{
type: string;
count: number;
}>Location Types
Common location types used in the system:
| Type | Description |
|---|---|
INTERSECTION | Traffic intersection |
HIGHWAY | Highway or freeway |
CHECKPOINT | Traffic checkpoint |
BRIDGE | Bridge or overpass |
TUNNEL | Tunnel |
PARKING | Parking area |
ZONE | Geographical zone |
Status Values
| Status | Description |
|---|---|
active | Location is operational |
inactive | Location is not operational |
maintenance | Location under maintenance |