GarminRunerz.Workout.Models 1.1.0

dotnet add package GarminRunerz.Workout.Models --version 1.1.0
                    
NuGet\Install-Package GarminRunerz.Workout.Models -Version 1.1.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="GarminRunerz.Workout.Models" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GarminRunerz.Workout.Models" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="GarminRunerz.Workout.Models" />
                    
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 GarminRunerz.Workout.Models --version 1.1.0
                    
#r "nuget: GarminRunerz.Workout.Models, 1.1.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 GarminRunerz.Workout.Models@1.1.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=GarminRunerz.Workout.Models&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=GarminRunerz.Workout.Models&version=1.1.0
                    
Install as a Cake Tool

GarminRunerz.Workout.Models

A .NET library providing comprehensive data models for Garmin workout structures. This library enables developers to work with Garmin workout data in a strongly-typed manner, supporting JSON serialization and deserialization.

Overview

GarminRunerz.Workout.Models is designed to represent the complete data structure of Garmin workouts, including workout metadata, segments, steps, and all associated properties. The models are optimized for working with Garmin Connect's workout data format.

Features

  • Complete Workout Representation: Full model coverage for Garmin workout data structures
  • JSON Serialization: Built-in support for JSON serialization/deserialization using System.Text.Json
  • Strongly Typed: Type-safe models with comprehensive property definitions
  • Nullable Support: Proper handling of optional properties with nullable reference types
  • NuGet Package: Available as a .NET package for easy integration

Installation

Install the package via NuGet Package Manager:

Install-Package GarminRunerz.Workout.Models

Or via .NET CLI:

dotnet add package GarminRunerz.Workout.Models

Quick Start

Basic Usage

using GarminRunerz.Workout.Models;
using System.Text.Json;

// Deserialize from JSON
string jsonData = "{ ... }"; // Your workout JSON data
Workout workout = JsonSerializer.Deserialize<Workout>(jsonData);

// Access workout properties
Console.WriteLine($"Workout: {workout.WorkoutName}");
Console.WriteLine($"Description: {workout.Description}");
Console.WriteLine($"Sport: {workout.SportType?.SportTypeKey}");

// Work with workout segments
foreach (var segment in workout.WorkoutSegments ?? [])
{
    Console.WriteLine($"Segment Order: {segment.SegmentOrder}");
    Console.WriteLine($"Sport Type: {segment.SportType?.SportTypeKey}");
    
    // Process workout steps in each segment
    foreach (var step in segment.WorkoutSteps ?? [])
    {
        Console.WriteLine($"Step: {step.Description}");
        Console.WriteLine($"Step Type: {step.StepType?.StepTypeKey}");
        Console.WriteLine($"End Condition: {step.EndCondition?.ConditionTypeKey}");
    }
}

Creating a Workout

var workout = new Workout
{
    WorkoutName = "Morning Run",
    Description = "Easy 5K run with warm-up and cool-down",
    SportType = new SportType
    {
        SportTypeId = 1,
        SportTypeKey = "running"
    },
    EstimatedDurationInSecs = 1800, // 30 minutes
    Author = new Author
    {
        DisplayName = "Runner123",
        FullName = "John Doe"
    },
    WorkoutSegments = new List<WorkoutSegment>
    {
        new WorkoutSegment
        {
            SegmentOrder = 1,
            SportType = new SportType { SportTypeKey = "running" },
            WorkoutSteps = new List<WorkoutStep>
            {
                new WorkoutStep
                {
                    StepOrder = 1,
                    Description = "Warm-up",
                    StepType = new StepType { StepTypeKey = "warmup" },
                    EndCondition = new EndCondition { ConditionTypeKey = "time" },
                    EndConditionValue = 300 // 5 minutes
                }
            }
        }
    }
};

// Serialize to JSON
string json = JsonSerializer.Serialize(workout, new JsonSerializerOptions
{
    WriteIndented = true
});

Data Models

Core Models

Workout

The main workout container that includes all workout metadata and segments.

Key Properties:

  • WorkoutId: Unique identifier for the workout
  • WorkoutName: Display name of the workout
  • Description: Detailed description
  • SportType: The primary sport type for this workout
  • Author: Information about the workout creator
  • WorkoutSegments: List of workout segments
  • EstimatedDurationInSecs: Estimated workout duration
  • EstimatedDistanceInMeters: Estimated distance (if applicable)
WorkoutSegment

Represents a segment within a workout, typically used for multi-sport workouts.

Key Properties:

  • SegmentOrder: Order of this segment in the workout
  • SportType: Sport type for this specific segment
  • WorkoutSteps: List of steps within this segment
  • EstimatedDurationInSecs: Estimated duration for this segment
WorkoutStep

Individual step within a workout segment, representing a specific exercise or activity phase.

Key Properties:

  • StepOrder: Order of this step within the segment
  • StepType: Type of step (interval, rest, warmup, etc.)
  • Description: Human-readable description
  • EndCondition: Condition that determines when the step ends
  • EndConditionValue: Value associated with the end condition
  • TargetType: Type of target (heart rate, pace, power, etc.)
  • TargetValueOne/Two: Target range values
  • NumberOfIterations: For repeat steps

Supporting Models

Author

Information about the workout creator.

SportType

Defines the sport/activity type (running, cycling, swimming, etc.).

EndCondition

Defines how a workout step should end (time, distance, heart rate, etc.).

TargetType

Defines the target metric for a workout step (heart rate zone, pace, power, etc.).

StepType

Categorizes the type of workout step (warmup, interval, rest, cooldown, etc.).

EquipmentType

Specifies required equipment for specific steps.

StrokeType

For swimming workouts, specifies the stroke type.

EstimatedDistanceUnit

Unit of measurement for estimated distances.

JSON Structure Example

{
  "workoutId": 12345,
  "workoutName": "5K Training Run",
  "description": "Interval training for 5K improvement",
  "sportType": {
    "sportTypeId": 1,
    "sportTypeKey": "running",
    "displayOrder": 1
  },
  "author": {
    "userProfilePk": 67890,
    "displayName": "TrainingCoach",
    "fullName": "Jane Smith"
  },
  "estimatedDurationInSecs": 2400,
  "workoutSegments": [
    {
      "segmentOrder": 1,
      "sportType": {
        "sportTypeKey": "running"
      },
      "workoutSteps": [
        {
          "stepOrder": 1,
          "description": "Warm-up jog",
          "stepType": {
            "stepTypeKey": "warmup"
          },
          "endCondition": {
            "conditionTypeKey": "time"
          },
          "endConditionValue": 600,
          "targetType": {
            "workoutTargetTypeKey": "heart.rate.zone"
          },
          "targetValueOne": 2
        }
      ]
    }
  ]
}

Requirements

  • .NET 8.0 or higher
  • System.Text.Json (included in .NET)

Contributing

Contributions are welcome! Please feel free to submit pull requests or open issues for bugs and feature requests.

License

This project is open source. Please refer to the license file for more information.

This library is part of the GarminRunerz ecosystem for working with Garmin fitness data.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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.
  • net9.0

    • No dependencies.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 2 9/15/2025