Skip to content

Get Devices (by user, ids, uniqueIds, or combined)

Fetch devices from your Traccar server by user ID, by device IDs, by unique IDs, or using combined filters.

WARNING

  • Standard users can only use this operation with their own userId. Admins or managers may request devices for any user.
  • Without any params, returns a list of the user's devices

Usage

1) For a given user

php
use ThingsTelemetry\Traccar\Facades\Device;

$userId = 123;
$devices = Device::get(userId: $userId); // Illuminate\Support\Collection of DeviceData

2) By device IDs

php
use ThingsTelemetry\Traccar\Facades\Device;

$devices = Device::get(ids: [6, 7]); // Illuminate\Support\Collection of DeviceData

3) By uniqueIds

php
use ThingsTelemetry\Traccar\Facades\Device;

$devices = Device::get(uniqueIds: ['ABC123', 'XYZ789']); // Illuminate\Support\Collection of DeviceData

4) Combined filters (userId + ids + uniqueIds)

php
use ThingsTelemetry\Traccar\Facades\Device;

$devices = Device::get(userId: 123, ids: [6], uniqueIds: ['ABC123']); // Illuminate\Support\Collection of DeviceData

Results

The response is a Illuminate\Support\Collection<int, ThingsTelemetry\Traccar\Dto\DeviceData>.

php
$first = $devices->first();

$name = $first->name;                 // \"Truck 1\"
$status = $first->status->label();    // \"Online\"
$category = $first->category->value;  // \"truck\"
$lastSeen = $first->lastUpdate?->toIso8601String();

// Attributes (typed)
$speedLimit = $first->attributes->speedLimit; // 80.0 (knots)

Key Result Items

Released under the MIT License.