Tramigo.Client 1.0.0

dotnet add package Tramigo.Client --version 1.0.0
                    
NuGet\Install-Package Tramigo.Client -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tramigo.Client" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tramigo.Client" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Tramigo.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tramigo.Client --version 1.0.0
                    
#r "nuget: Tramigo.Client, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tramigo.Client@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tramigo.Client&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Tramigo.Client&version=1.0.0
                    
Install as a Cake Tool

Tramigo Cloud API Client for .NET

NuGet Build

A fully-featured .NET client library for the Tramigo Cloud API, providing easy access to vehicle tracking, fleet management, and device control functionality.

API Version: This client implements the Tramigo Cloud API v1.7 specification.

Features

  • OAuth 2.0 Authentication: Secure login/logout with token management
  • Device Management: List devices and device groups
  • Reports: Get device reports with filtering by date, type, and custom filters
  • Location Tracking: Get last known locations for devices
  • Odometer (Mileage): Track vehicle mileage with range calculations
  • Engine Hours: Monitor engine running time
  • Commands: Send commands to devices including immobilizer control
  • Dependency Injection: Built-in support for ASP.NET Core DI

Installation

NuGet Package

dotnet add package Tramigo.Client

From Source

git clone https://github.com/DaithiBradley/TramigoAPI.git
cd TramigoAPI
dotnet build

Quick Start

Basic Usage

using Tramigo.Client;

// Create client with default options
using var client = new TramigoClient();

// Or with custom options
var options = new TramigoClientOptions
{
    BaseUrl = "http://api.tracking.tramigocloud.com",
    TimeoutSeconds = 30
};
using var client = new TramigoClient(options);

// Authenticate
var loginResponse = await client.LoginAsync("username", "password");
Console.WriteLine($"Logged in! Token expires in {loginResponse.ExpiresIn} seconds");

// Get devices
var devices = await client.GetDevicesAsync(page: 1, perPage: 100);
foreach (var device in devices.Data)
{
    Console.WriteLine($"Device: {device.Name} (IMEI: {device.Imei})");
}

// Logout when done
await client.LogoutAsync();

ASP.NET Core Dependency Injection

// In Program.cs or Startup.cs
using Tramigo.Client.Extensions;

builder.Services.AddTramigoClient(options =>
{
    options.BaseUrl = "http://api.tracking.tramigocloud.com";
    options.TimeoutSeconds = 30;
});

// Or with HttpClientFactory support
builder.Services.AddTramigoClientWithHttpClientFactory(options =>
{
    options.BaseUrl = "http://api.tracking.tramigocloud.com";
});
// In your service or controller
public class TrackingService
{
    private readonly ITramigoClient _client;

    public TrackingService(ITramigoClient client)
    {
        _client = client;
    }

    public async Task<List<Device>> GetAllDevicesAsync()
    {
        // Login first if not authenticated
        if (!_client.IsAuthenticated)
        {
            await _client.LoginAsync("username", "password");
        }

        var response = await _client.GetDevicesAsync();
        return response.Data;
    }
}

API Reference

Authentication

// Login
var loginResponse = await client.LoginAsync("username", "password");

// Check authentication status
bool isAuthenticated = client.IsAuthenticated;
string? token = client.AccessToken;

// Logout
var logoutResponse = await client.LogoutAsync();

Devices

// Get paginated list of devices
var devices = await client.GetDevicesAsync(page: 1, perPage: 100);

// Get device groups
var groups = await client.GetDeviceGroupsAsync();

Reports

// Get reports for a device
var reports = await client.GetReportsAsync(
    deviceId: 389,
    page: 1,
    perPage: 50
);

// Get reports with date filter
var filteredReports = await client.GetReportsAsync(
    deviceId: 389,
    page: 1,
    perPage: 50,
    startDate: DateTime.UtcNow.AddDays(-7),
    endDate: DateTime.UtcNow
);

// Get reports with report group filter
var tripReports = await client.GetReportsAsync(
    deviceId: 389,
    reportGroup: ReportGroup.Trips
);

// Get reports with custom type filter
var customReports = await client.GetReportsAsync(
    deviceId: 389,
    reportGroup: ReportGroup.CustomFilter,
    reportTypes: new[] { ReportType.IgnitionOn, ReportType.IgnitionOff, ReportType.Moving }
);

// Get last report for a device
var lastReport = await client.GetLastReportAsync(deviceId: 389);

// Get last reports for multiple devices
var lastReports = await client.GetLastReportsAsync(new[] { 389, 10, 454 });

// Get last location for a device
var lastLocation = await client.GetLastLocationAsync(deviceId: 389);

// Get last locations for multiple devices
var lastLocations = await client.GetLastLocationsAsync(new[] { 389, 10, 454 });

Available Report Types

Type Description
Info Informational report
Trip Trip report
TripStart Trip start
MotionAlarm Motion alarm
LowPower Low power
IgnitionOn Ignition on
IgnitionOff Ignition off
SensorOn Sensor on
SensorOff Sensor off
Alarm Alarm
SpeedLimit Speed limit
Stopped Stopped
Moving Moving
Parked Parked
HarshAcceleration Harsh acceleration
HarshBraking Harsh braking
TiltAlarm Tilt alarm
FuelTheft Fuel theft
HarshCornering Harsh cornering
ZoneIn Zone in
ZoneOut Zone out

Odometer (Mileage)

// Get last odometer readings for all devices
var lastOdometer = await client.GetLastOdometerAsync(page: 1, perPage: 100);

// Get odometer range for all devices
var odometerRange = await client.GetOdometerRangeAsync(
    startDate: DateTime.UtcNow.AddDays(-30),
    endDate: DateTime.UtcNow
);

// Get odometer for a specific device
var deviceOdometer = await client.GetDeviceOdometerAsync(
    deviceId: 7485,
    startDate: DateTime.UtcNow.AddDays(-7),
    endDate: DateTime.UtcNow,
    order: "asc"
);

Engine Hours

// Get last engine hours for all devices
var lastEngineHours = await client.GetLastEngineHoursAsync(page: 1, perPage: 100);

// Get engine hours range for all devices
var engineHoursRange = await client.GetEngineHourRangeAsync(
    startDate: DateTime.UtcNow.AddDays(-30),
    endDate: DateTime.UtcNow
);

// Get engine hours for a specific device
var deviceEngineHours = await client.GetDeviceEngineHoursAsync(
    deviceId: 7485,
    startDate: DateTime.UtcNow.AddDays(-7),
    endDate: DateTime.UtcNow,
    order: "asc"
);

Commands

// Send a command to a device
var response = await client.SendCommandAsync(
    deviceId: 577,
    message: "find"
);

// Send commands to multiple devices
var responses = await client.SendCommandsAsync(new[]
{
    new CommandRequest { DeviceId = 577, Message = "find" },
    new CommandRequest { DeviceId = 578, Message = "status" }
});

// Activate immobilizer
var activateResponse = await client.ImmobilizeAsync(deviceId: 577, activate: true);

// Deactivate immobilizer
var deactivateResponse = await client.ImmobilizeAsync(deviceId: 577, activate: false);

Error Handling

The client throws specific exceptions for different error scenarios:

using Tramigo.Client.Exceptions;

try
{
    await client.LoginAsync("user", "pass");
}
catch (TramigoAuthenticationException ex)
{
    // Authentication failed (invalid credentials, expired token, etc.)
    Console.WriteLine($"Auth error: {ex.Message}");
    Console.WriteLine($"Status code: {ex.StatusCode}");
}
catch (TramigoApiException ex)
{
    // Other API errors
    Console.WriteLine($"API error: {ex.Message}");
    Console.WriteLine($"Status code: {ex.StatusCode}");
    Console.WriteLine($"Response: {ex.ResponseContent}");
}

Configuration Options

Option Default Description
BaseUrl http://api.tracking.tramigocloud.com Base URL for API requests
CommandBaseUrl https://tramigocloud.com Base URL for command requests
TimeoutSeconds 30 HTTP request timeout
Username null Optional username for auto-login
Password null Optional password for auto-login

Project Structure

TramigoAPI/
├── Tramigo.Client/                    # Main client library
│   ├── Models/
│   │   ├── Authentication/            # Login/Logout models
│   │   ├── Commands/                  # Command request/response models
│   │   ├── Common/                    # Shared models (PagedResponse)
│   │   ├── Config/                    # API configuration models
│   │   ├── Devices/                   # Device and DeviceGroup models
│   │   ├── EngineHours/               # Engine hours models
│   │   ├── Odometer/                  # Odometer models
│   │   └── Reports/                   # Report models and enums
│   ├── Exceptions/                    # Custom exceptions
│   ├── Extensions/                    # DI extensions
│   ├── ITramigoClient.cs              # Client interface
│   ├── TramigoClient.cs               # Client implementation
│   └── TramigoClientOptions.cs        # Configuration options
├── Tramigo.Client.Tests/              # Unit tests (165 tests)
├── Tramigo.Examples/                  # Example console application
├── TramigoAPI.sln
└── README.md

Running Tests

cd TramigoAPI
dotnet test

Running Examples

cd TramigoAPI
dotnet run --project Tramigo.Examples

The example application demonstrates all API endpoints with sample data. Update the credentials in Program.cs to use your actual Tramigo Cloud account.

API Documentation

This client is based on the official Tramigo Cloud API Documentation v1.7. For the full API specification, contact Tramigo Ltd.

Requirements

  • .NET 8.0 or later
  • Valid Tramigo Cloud account credentials

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 132 1/27/2026